@@ -86,29 +86,37 @@ discard block |
||
86 | 86 | { |
87 | 87 | $icon = IconHelper::FILE; |
88 | 88 | |
89 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') |
|
90 | - $icon = IconHelper::FILE_WORD; |
|
89 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') { |
|
90 | + $icon = IconHelper::FILE_WORD; |
|
91 | + } |
|
91 | 92 | |
92 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') |
|
93 | - $icon = IconHelper::FILE_EXCEL; |
|
93 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') { |
|
94 | + $icon = IconHelper::FILE_EXCEL; |
|
95 | + } |
|
94 | 96 | |
95 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') |
|
96 | - $icon = IconHelper::FILE_POWERPOINT; |
|
97 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') { |
|
98 | + $icon = IconHelper::FILE_POWERPOINT; |
|
99 | + } |
|
97 | 100 | |
98 | - if ($this->content_type == 'application/x-zip-compressed') |
|
99 | - $icon = IconHelper::FILE_ARCHIVE; |
|
101 | + if ($this->content_type == 'application/x-zip-compressed') { |
|
102 | + $icon = IconHelper::FILE_ARCHIVE; |
|
103 | + } |
|
100 | 104 | |
101 | - if ($this->content_type == 'application/octet-stream') |
|
102 | - $icon = IconHelper::FILE_ARCHIVE; |
|
105 | + if ($this->content_type == 'application/octet-stream') { |
|
106 | + $icon = IconHelper::FILE_ARCHIVE; |
|
107 | + } |
|
103 | 108 | |
104 | - if (preg_match('/audio/', $this->content_type)) |
|
105 | - $icon = IconHelper::FILE_AUDIO; |
|
109 | + if (preg_match('/audio/', $this->content_type)) { |
|
110 | + $icon = IconHelper::FILE_AUDIO; |
|
111 | + } |
|
106 | 112 | |
107 | - if (preg_match('/pdf/', $this->content_type)) |
|
108 | - $icon = IconHelper::FILE_PDF; |
|
113 | + if (preg_match('/pdf/', $this->content_type)) { |
|
114 | + $icon = IconHelper::FILE_PDF; |
|
115 | + } |
|
109 | 116 | |
110 | - if ($this->type == FileType::VIDEO) |
|
111 | - $icon = IconHelper::FILE_VIDEO; |
|
117 | + if ($this->type == FileType::VIDEO) { |
|
118 | + $icon = IconHelper::FILE_VIDEO; |
|
119 | + } |
|
112 | 120 | |
113 | 121 | return $icon; |
114 | 122 | } |
@@ -232,8 +240,9 @@ discard block |
||
232 | 240 | |
233 | 241 | public function getRootPreviewPath() |
234 | 242 | { |
235 | - if ($this->isSvg()) |
|
236 | - return $this->getRootPath(); |
|
243 | + if ($this->isSvg()) { |
|
244 | + return $this->getRootPath(); |
|
245 | + } |
|
237 | 246 | |
238 | 247 | return Yii::$app->getModule('files')->storageFullPath . DIRECTORY_SEPARATOR . $this->filename . '.jpg'; |
239 | 248 | } |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | |
257 | 266 | public function getHref() |
258 | 267 | { |
259 | - if (Yii::$app->getModule('files')->hostStatic) |
|
260 | - return Yii::$app->getModule('files')->hostStatic . $this->filename; |
|
268 | + if (Yii::$app->getModule('files')->hostStatic) { |
|
269 | + return Yii::$app->getModule('files')->hostStatic . $this->filename; |
|
270 | + } |
|
261 | 271 | return Url::to(['/files/default/get', 'hash' => $this->hash]); |
262 | 272 | } |
263 | 273 | |
@@ -333,8 +343,9 @@ discard block |
||
333 | 343 | isset($this->behaviors['files']) && |
334 | 344 | isset($this->behaviors['files']->attributes[$this->field]) && |
335 | 345 | isset($this->behaviors['files']->attributes[$this->field]['watermark']) |
336 | - ) |
|
337 | - $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
346 | + ) { |
|
347 | + $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
348 | + } |
|
338 | 349 | } |
339 | 350 | |
340 | 351 | /** |
@@ -355,14 +366,17 @@ discard block |
||
355 | 366 | */ |
356 | 367 | public function getPreviewWebPath($width = 0, $height = 0, $webp = false) |
357 | 368 | { |
358 | - if (!file_exists($this->getRootPath())) |
|
359 | - return null; |
|
369 | + if (!file_exists($this->getRootPath())) { |
|
370 | + return null; |
|
371 | + } |
|
360 | 372 | |
361 | - if ($this->type != FileType::IMAGE) |
|
362 | - throw new \ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
373 | + if ($this->type != FileType::IMAGE) { |
|
374 | + throw new \ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
375 | + } |
|
363 | 376 | |
364 | - if (Yii::$app->getModule('files')->hostStatic) |
|
365 | - return Yii::$app->getModule('files')->hostStatic . $this->makeNameWithSize($this->filename, $width, $height, $webp = false); |
|
377 | + if (Yii::$app->getModule('files')->hostStatic) { |
|
378 | + return Yii::$app->getModule('files')->hostStatic . $this->makeNameWithSize($this->filename, $width, $height, $webp = false); |
|
379 | + } |
|
366 | 380 | |
367 | 381 | return Url::toRoute(['/files/default/image', 'hash' => $this->hash, 'width' => $width, 'height' => $height, 'webp' => $webp]); |
368 | 382 | } |
@@ -379,8 +393,9 @@ discard block |
||
379 | 393 | { |
380 | 394 | $extension = pathinfo($this->rootPath, PATHINFO_EXTENSION); |
381 | 395 | $rootPath = str_replace(".{$extension}", '', $name) . "_w" . $width . "h" . $height . ".{$extension}"; |
382 | - if ($webp) |
|
383 | - $rootPath = str_replace($extension, 'webp', $rootPath); |
|
396 | + if ($webp) { |
|
397 | + $rootPath = str_replace($extension, 'webp', $rootPath); |
|
398 | + } |
|
384 | 399 | return $rootPath; |
385 | 400 | } |
386 | 401 | |
@@ -395,8 +410,9 @@ discard block |
||
395 | 410 | */ |
396 | 411 | public function getPreviewRootPath($width = 0, $height = 0, $webp = false) |
397 | 412 | { |
398 | - if ($this->type != FileType::IMAGE) |
|
399 | - throw new \ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
413 | + if ($this->type != FileType::IMAGE) { |
|
414 | + throw new \ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
415 | + } |
|
400 | 416 | return $this->makeNameWithSize($this->rootPath, $width, $height, $webp); |
401 | 417 | } |
402 | 418 |