Passed
Push — master ( 1e5dec...59a50f )
by Mihail
06:40
created
Apps/Controller/Api/Content.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
         parent::before();
34 34
         $configs = AppRecord::getConfigs('app', 'Content');
35 35
         // prevent null-type config data
36
-        if ((int)$configs['gallerySize'] > 0) {
37
-            $this->maxSize = (int)$configs['gallerySize'] * 1024;
36
+        if ((int) $configs['gallerySize'] > 0) {
37
+            $this->maxSize = (int) $configs['gallerySize'] * 1024;
38 38
         }
39 39
 
40
-        if ((int)$configs['galleryResize'] > 0) {
41
-            $this->maxResize = (int)$configs['galleryResize'];
40
+        if ((int) $configs['galleryResize'] > 0) {
41
+            $this->maxResize = (int) $configs['galleryResize'];
42 42
         }
43 43
     }
44 44
     
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         // check if directory exist
120
-        if (!Directory::exist('/upload/gallery/' . $id)) {
121
-            Directory::create('/upload/gallery/' . $id);
120
+        if (!Directory::exist('/upload/gallery/'.$id)) {
121
+            Directory::create('/upload/gallery/'.$id);
122 122
         }
123 123
 
124 124
         // get file object
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
         // check file size
132 132
         if ($file->getSize() < 1 || $file->getSize() > $this->maxSize) {
133
-            throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => (int)($this->maxSize/1024)]));
133
+            throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => (int) ($this->maxSize / 1024)]));
134 134
         }
135 135
 
136 136
         // check file extension
@@ -139,41 +139,41 @@  discard block
 block discarded – undo
139 139
         }
140 140
 
141 141
         // create origin directory
142
-        $originPath = '/upload/gallery/' . $id . '/orig/';
142
+        $originPath = '/upload/gallery/'.$id.'/orig/';
143 143
         if (!Directory::exist($originPath)) {
144 144
             Directory::create($originPath);
145 145
         }
146 146
 
147 147
         // lets make a new file name
148
-        $fileName = App::$Security->simpleHash($file->getClientOriginalName() . $file->getSize());
149
-        $fileNewName = $fileName . '.' . $file->guessExtension();
148
+        $fileName = App::$Security->simpleHash($file->getClientOriginalName().$file->getSize());
149
+        $fileNewName = $fileName.'.'.$file->guessExtension();
150 150
         // check if image is already loaded
151
-        if (File::exist($originPath . $fileNewName)) {
151
+        if (File::exist($originPath.$fileNewName)) {
152 152
             throw new ForbiddenException(__('File is always exists!'));
153 153
         }
154 154
         // save file from tmp to gallery origin directory
155 155
         $file->move(Normalize::diskFullPath($originPath), $fileNewName);
156 156
 
157 157
         // lets resize preview image for it
158
-        $thumbPath = '/upload/gallery/' . $id . '/thumb/';
158
+        $thumbPath = '/upload/gallery/'.$id.'/thumb/';
159 159
         if (!Directory::exist($thumbPath)) {
160 160
             Directory::create($thumbPath);
161 161
         }
162 162
 
163 163
         $thumb = new Image();
164
-        $thumb->setCacheDir(root . '/Private/Cache/images');
164
+        $thumb->setCacheDir(root.'/Private/Cache/images');
165 165
 
166 166
         // open original file, resize it and save
167
-        $thumbSaveName = Normalize::diskFullPath($thumbPath) . '/' . $fileName . '.jpg';
168
-        $thumb->open(Normalize::diskFullPath($originPath) . DIRECTORY_SEPARATOR . $fileNewName)
167
+        $thumbSaveName = Normalize::diskFullPath($thumbPath).'/'.$fileName.'.jpg';
168
+        $thumb->open(Normalize::diskFullPath($originPath).DIRECTORY_SEPARATOR.$fileNewName)
169 169
             ->cropResize($this->maxResize)
170 170
             ->save($thumbSaveName, 'jpg', 90);
171 171
         $thumb = null;
172 172
 
173 173
         $this->setJsonHeader();
174 174
         return json_encode(['status' => 1, 'file' => [
175
-            'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg',
176
-            'url' => '/upload/gallery/' . $id . '/orig/' . $fileNewName,
175
+            'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg',
176
+            'url' => '/upload/gallery/'.$id.'/orig/'.$fileNewName,
177 177
             'name' => $fileNewName
178 178
         ]]);
179 179
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             throw new NativeException('Permission denied');
198 198
         }
199 199
 
200
-        $thumbDir = Normalize::diskFullPath('/upload/gallery/' . $id . '/orig/');
200
+        $thumbDir = Normalize::diskFullPath('/upload/gallery/'.$id.'/orig/');
201 201
         if (!Directory::exist($thumbDir)) {
202 202
             throw new NotFoundException('Nothing found');
203 203
         }
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
             $fileExt = Str::lastIn($file, '.');
213 213
             $fileName = Str::sub($file, 0, -Str::length($fileExt));
214 214
             $output[] = [
215
-                'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg',
216
-                'url' => '/upload/gallery/' . $id . '/orig/' . $file,
215
+                'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg',
216
+                'url' => '/upload/gallery/'.$id.'/orig/'.$file,
217 217
                 'name' => $file,
218 218
                 'size' => File::size($file)
219 219
             ];
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
         }
247 247
 
248 248
         // generate path
249
-        $thumb = '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg';
250
-        $full = '/upload/gallery/' . $id . '/orig/' . $file;
249
+        $thumb = '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg';
250
+        $full = '/upload/gallery/'.$id.'/orig/'.$file;
251 251
 
252 252
         // check if file exists and remove
253 253
         if (File::exist($thumb) || File::exist($full)) {
Please login to merge, or discard this patch.
Apps/View/Admin/default/content/content_update.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 foreach (\App::$Properties->get('languages') as $lang) {
43 43
     $generalItems[] = [
44 44
         'type' => 'tab',
45
-        'text' => __('Lang') . ': ' . Str::upperCase($lang),
46
-        'content' => $form->field('title.' . $lang, 'text', ['class' => 'form-control'], __('Please, enter the title of your material for current language locale'), 'content/form/tab_content_update') .
47
-            $form->field('text.' . $lang, 'textarea', ['class' => 'form-control wysiwyg', 'rows' => 7, 'html' => true], null, 'content/form/tab_content_update'),
45
+        'text' => __('Lang').': '.Str::upperCase($lang),
46
+        'content' => $form->field('title.'.$lang, 'text', ['class' => 'form-control'], __('Please, enter the title of your material for current language locale'), 'content/form/tab_content_update').
47
+            $form->field('text.'.$lang, 'textarea', ['class' => 'form-control wysiwyg', 'rows' => 7, 'html' => true], null, 'content/form/tab_content_update'),
48 48
         'html' => true,
49 49
         'active' => $lang === \App::$Request->getLanguage(),
50 50
         '!secure' => true
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 
53 53
     $propertiesItems[] = [
54 54
         'type' => 'tab',
55
-        'text' => __('Lang') . ': ' . Str::upperCase($lang),
56
-        'content' => $form->field('metaTitle.' . $lang, 'text', ['class' => 'form-control'], __('Enter meta param title for page title. Recoomended: 50-70 characters')) .
57
-            $form->field('metaKeywords.' . $lang, 'text', ['class' => 'form-control'], __('Enter meta param keywords for this content, separated by comma. Example: home, door, dog')) .
58
-            $form->field('metaDescription.' . $lang, 'text', ['class' => 'form-control'], __('Enter meta param description for this content. Recommended is 100-150 characters')),
55
+        'text' => __('Lang').': '.Str::upperCase($lang),
56
+        'content' => $form->field('metaTitle.'.$lang, 'text', ['class' => 'form-control'], __('Enter meta param title for page title. Recoomended: 50-70 characters')).
57
+            $form->field('metaKeywords.'.$lang, 'text', ['class' => 'form-control'], __('Enter meta param keywords for this content, separated by comma. Example: home, door, dog')).
58
+            $form->field('metaDescription.'.$lang, 'text', ['class' => 'form-control'], __('Enter meta param description for this content. Recommended is 100-150 characters')),
59 59
         'html' => true,
60 60
         '!secure' => true,
61 61
         'active' => $lang === \App::$Request->getLanguage()
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     <div class="dropzone dropzone-previews" id="ffcms-dropzone"></div>
91 91
 </div>
92 92
 <div class="col-md-4">
93
-    ' . $form->field('poster', 'select', ['options' => [__('Not selected...')], 'class' => 'form-control'], __('Select image from gallery as a poster for this content')) . '
93
+    ' . $form->field('poster', 'select', ['options' => [__('Not selected...')], 'class' => 'form-control'], __('Select image from gallery as a poster for this content')).'
94 94
 </div>
95 95
 </div><br/><br/>';
96 96
 ?>
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         ['type' => 'tab', 'text' => __('Gallery'), 'content' => $galleryTab, 'html' => true, '!secure' => true],
104 104
         ['type' => 'tab', 'text' => __('Other'), 'content' => $otherTab, 'html' => true, '!secure' => true]
105 105
     ]
106
-]);?>
106
+]); ?>
107 107
 
108 108
 <?= $form->field('galleryFreeId', 'hidden') ?>
109 109
 <?= $form->submitButton(__('Save'), ['class' => 'btn btn-primary']) ?>&nbsp;
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 
113 113
 <?php
114 114
 // load max length display plugin
115
-\App::$Alias->setCustomLibrary('js', \App::$Alias->currentViewUrl . '/assets/js/plugins/maxlength.js');
115
+\App::$Alias->setCustomLibrary('js', \App::$Alias->currentViewUrl.'/assets/js/plugins/maxlength.js');
116 116
 // load datapicker plugin
117
-\App::$Alias->setCustomLibrary('css', \App::$Alias->currentViewUrl . '/assets/css/plugins/datapick/datapick.css');
118
-\App::$Alias->setCustomLibrary('js', \App::$Alias->currentViewUrl . '/assets/js/plugins/datapick.js');
117
+\App::$Alias->setCustomLibrary('css', \App::$Alias->currentViewUrl.'/assets/css/plugins/datapick/datapick.css');
118
+\App::$Alias->setCustomLibrary('js', \App::$Alias->currentViewUrl.'/assets/js/plugins/datapick.js');
119 119
 // load jquery-upload plugin
120
-\App::$Alias->setCustomLibrary('css', \App::$Alias->scriptUrl . '/vendor/bower/dropzone/dist/min/dropzone.min.css');
121
-\App::$Alias->setCustomLibrary('css', \App::$Alias->scriptUrl . '/vendor/bower/dropzone/dist/min/basic.min.css');
122
-\App::$Alias->setCustomLibrary('js', \App::$Alias->scriptUrl . '/vendor/bower/dropzone/dist/min/dropzone.min.js');
120
+\App::$Alias->setCustomLibrary('css', \App::$Alias->scriptUrl.'/vendor/bower/dropzone/dist/min/dropzone.min.css');
121
+\App::$Alias->setCustomLibrary('css', \App::$Alias->scriptUrl.'/vendor/bower/dropzone/dist/min/basic.min.css');
122
+\App::$Alias->setCustomLibrary('js', \App::$Alias->scriptUrl.'/vendor/bower/dropzone/dist/min/dropzone.min.js');
123 123
 ?>
124 124
 
125 125
 <script>
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             var DropzoneFiles = [];
217 217
             $('#ffcms-dropzone').dropzone({
218 218
                 url: script_url+'/api/content/galleryupload/<?= $model->galleryFreeId ?>?lang='+script_lang,
219
-                dictDefaultMessage: '<?= __('Drop files here to upload in gallery') . '<br />' . __('(or click here)') ?>',
219
+                dictDefaultMessage: '<?= __('Drop files here to upload in gallery').'<br />'.__('(or click here)') ?>',
220 220
                 acceptedFiles: ".jpeg,.jpg,.png,.gif,.webp",
221 221
                 addRemoveLinks: true,
222 222
                 removedfile: function (file) { // file remove click, lets try to remove file from server & make visual changes
Please login to merge, or discard this patch.