Passed
Push — master ( 81f334...c86e8c )
by Mihail
03:35
created
Apps/Controller/Api/Content/ActionGalleryUpload.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
         }
47 47
 
48 48
         // check if directory exist
49
-        if (!Directory::exist('/upload/gallery/' . $id)) {
50
-            Directory::create('/upload/gallery/' . $id);
49
+        if (!Directory::exist('/upload/gallery/'.$id)) {
50
+            Directory::create('/upload/gallery/'.$id);
51 51
         }
52 52
 
53 53
         // get file object
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         // check file size
61 61
         if ($file->getSize() < 1 || $file->getSize() > $this->maxSize) {
62
-            throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => (int)($this->maxSize/1024)]));
62
+            throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => (int) ($this->maxSize / 1024)]));
63 63
         }
64 64
 
65 65
         // check file extension
@@ -68,40 +68,40 @@  discard block
 block discarded – undo
68 68
         }
69 69
 
70 70
         // create origin directory
71
-        $originPath = '/upload/gallery/' . $id . '/orig/';
71
+        $originPath = '/upload/gallery/'.$id.'/orig/';
72 72
         if (!Directory::exist($originPath)) {
73 73
             Directory::create($originPath);
74 74
         }
75 75
 
76 76
         // lets make a new file name
77
-        $fileName = App::$Security->simpleHash($file->getClientOriginalName() . $file->getSize());
78
-        $fileNewName = $fileName . '.' . $file->guessExtension();
77
+        $fileName = App::$Security->simpleHash($file->getClientOriginalName().$file->getSize());
78
+        $fileNewName = $fileName.'.'.$file->guessExtension();
79 79
         // check if image is already loaded
80
-        if (File::exist($originPath . $fileNewName)) {
80
+        if (File::exist($originPath.$fileNewName)) {
81 81
             throw new ForbiddenException(__('File is always exists!'));
82 82
         }
83 83
         // save file from tmp to gallery origin directory
84 84
         $file->move(Normalize::diskFullPath($originPath), $fileNewName);
85 85
 
86 86
         // lets resize preview image for it
87
-        $thumbPath = '/upload/gallery/' . $id . '/thumb/';
87
+        $thumbPath = '/upload/gallery/'.$id.'/thumb/';
88 88
         if (!Directory::exist($thumbPath)) {
89 89
             Directory::create($thumbPath);
90 90
         }
91 91
 
92 92
         $thumb = new Image();
93
-        $thumb->setCacheDir(root . '/Private/Cache/images');
93
+        $thumb->setCacheDir(root.'/Private/Cache/images');
94 94
 
95 95
         // open original file, resize it and save
96
-        $thumbSaveName = Normalize::diskFullPath($thumbPath) . '/' . $fileName . '.jpg';
97
-        $thumb->open(Normalize::diskFullPath($originPath) . DIRECTORY_SEPARATOR . $fileNewName)
96
+        $thumbSaveName = Normalize::diskFullPath($thumbPath).'/'.$fileName.'.jpg';
97
+        $thumb->open(Normalize::diskFullPath($originPath).DIRECTORY_SEPARATOR.$fileNewName)
98 98
             ->cropResize($this->maxResize)
99 99
             ->save($thumbSaveName, 'jpg', 90);
100 100
         $thumb = null;
101 101
 
102 102
         return json_encode(['status' => 1, 'file' => [
103
-            'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg',
104
-            'url' => '/upload/gallery/' . $id . '/orig/' . $fileNewName,
103
+            'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg',
104
+            'url' => '/upload/gallery/'.$id.'/orig/'.$fileNewName,
105 105
             'name' => $fileNewName
106 106
         ]]);
107 107
     }
Please login to merge, or discard this patch.
Apps/Controller/Api/Content/ActionGalleryDelete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $this->setJsonHeader();
34 34
         if (!$file || Any::isEmpty($file)) {
35
-            $file = (string)$this->request->query->get('file', null);
35
+            $file = (string) $this->request->query->get('file', null);
36 36
         }
37 37
 
38 38
         // check passed data
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         // generate path
51
-        $thumb = '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg';
52
-        $full = '/upload/gallery/' . $id . '/orig/' . $file;
51
+        $thumb = '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg';
52
+        $full = '/upload/gallery/'.$id.'/orig/'.$file;
53 53
 
54 54
         // check if file exists and remove
55 55
         if (File::exist($thumb) || File::exist($full)) {
Please login to merge, or discard this patch.
Apps/Controller/Api/Content/ActionGalleryList.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             throw new NativeException('Permission denied');
39 39
         }
40 40
 
41
-        $thumbDir = Normalize::diskFullPath('/upload/gallery/' . $id . '/orig/');
41
+        $thumbDir = Normalize::diskFullPath('/upload/gallery/'.$id.'/orig/');
42 42
         if (!Directory::exist($thumbDir)) {
43 43
             throw new NotFoundException('Nothing found');
44 44
         }
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
             $fileExt = Str::lastIn($file, '.');
54 54
             $fileName = Str::sub($file, 0, -Str::length($fileExt));
55 55
             $output[] = [
56
-                'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg',
57
-                'url' => '/upload/gallery/' . $id . '/orig/' . $file,
56
+                'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg',
57
+                'url' => '/upload/gallery/'.$id.'/orig/'.$file,
58 58
                 'name' => $file,
59
-                'size' => File::size('/upload/gallery/' . $id . '/orig/' . $file)
59
+                'size' => File::size('/upload/gallery/'.$id.'/orig/'.$file)
60 60
             ];
61 61
         }
62 62
 
Please login to merge, or discard this patch.