@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $this->setJsonHeader(); |
32 | 32 | $configs = AppRecord::getConfigs('widget', 'Comments'); |
33 | 33 | |
34 | - $replayTo = (int)$this->request->request->get('replay-to'); |
|
34 | + $replayTo = (int) $this->request->request->get('replay-to'); |
|
35 | 35 | $model = null; |
36 | 36 | // check if its a answer (comment answer type) |
37 | 37 | if ($replayTo > 0) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | // pass general comment params to model |
46 | - $model->message = App::$Security->secureHtml((string)$this->request->request->get('message')); |
|
46 | + $model->message = App::$Security->secureHtml((string) $this->request->request->get('message')); |
|
47 | 47 | $model->guestName = App::$Security->strip_tags($this->request->request->get('guest-name')); |
48 | 48 | |
49 | 49 | // check model conditions before add new row |
@@ -46,8 +46,8 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -32,7 +32,7 @@ discard block |
||
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 |
||
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)) { |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $this->id = $this->_content->id; |
73 | 73 | $this->title = $this->_content->getLocaled('title'); |
74 | 74 | $this->text = $this->_content->getLocaled('text'); |
75 | - $this->display = (bool)$this->_content->display; |
|
75 | + $this->display = (bool) $this->_content->display; |
|
76 | 76 | |
77 | 77 | // check if title and text are exists |
78 | 78 | if (Str::length($this->title) < 1 || Str::length($this->text) < 1) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->source = $this->_content->source; |
105 | - $this->views = $this->_content->views+1; |
|
105 | + $this->views = $this->_content->views + 1; |
|
106 | 106 | |
107 | 107 | // build category nesting sorted array |
108 | 108 | $this->catNesting[] = $this->expandCategoryNesting(); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $this->rating = $this->_content->rating; |
114 | 114 | $ignoredRate = App::$Session->get('content.rate.ignore'); |
115 | 115 | $this->canRate = true; |
116 | - if (Any::isArray($ignoredRate) && Arr::in((string)$this->id, $ignoredRate)) { |
|
116 | + if (Any::isArray($ignoredRate) && Arr::in((string) $this->id, $ignoredRate)) { |
|
117 | 117 | $this->canRate = false; |
118 | 118 | } |
119 | 119 | if (!App::$User->isAuth()) { |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | private function prepareGallery() |
134 | 134 | { |
135 | 135 | // get gallery images and poster data |
136 | - $galleryPath = '/upload/gallery/' . $this->_content->id; |
|
136 | + $galleryPath = '/upload/gallery/'.$this->_content->id; |
|
137 | 137 | // check if gallery folder is exist |
138 | 138 | if (Directory::exist($galleryPath)) { |
139 | - $originImages = File::listFiles($galleryPath . '/orig/', ['.jpg', '.png', '.gif', '.jpeg', '.bmp', '.webp'], true); |
|
139 | + $originImages = File::listFiles($galleryPath.'/orig/', ['.jpg', '.png', '.gif', '.jpeg', '.bmp', '.webp'], true); |
|
140 | 140 | // generate poster data |
141 | 141 | if (Arr::in($this->_content->poster, $originImages)) { |
142 | 142 | // original poster |
143 | 143 | $posterName = $this->_content->poster; |
144 | - $this->posterFull = $galleryPath . '/orig/' . $posterName; |
|
144 | + $this->posterFull = $galleryPath.'/orig/'.$posterName; |
|
145 | 145 | if (!File::exist($this->posterFull)) { |
146 | 146 | $this->posterFull = null; |
147 | 147 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $posterSplit = explode('.', $posterName); |
151 | 151 | array_pop($posterSplit); |
152 | 152 | $posterCleanName = implode('.', $posterSplit); |
153 | - $this->posterThumb = $galleryPath . '/thumb/' . $posterCleanName . '.jpg'; |
|
153 | + $this->posterThumb = $galleryPath.'/thumb/'.$posterCleanName.'.jpg'; |
|
154 | 154 | if (!File::exist($this->posterThumb)) { |
155 | 155 | $this->posterThumb = null; |
156 | 156 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | continue; |
167 | 167 | } |
168 | 168 | |
169 | - $thumbPath = $galleryPath . '/thumb/' . $imageClearName . '.jpg'; |
|
169 | + $thumbPath = $galleryPath.'/thumb/'.$imageClearName.'.jpg'; |
|
170 | 170 | if (File::exist($thumbPath)) { |
171 | - $this->galleryItems[$thumbPath] = $galleryPath . '/orig/' . $image; |
|
171 | + $this->galleryItems[$thumbPath] = $galleryPath.'/orig/'.$image; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |