@@ -87,29 +87,37 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $icon = IconHelper::FILE; |
| 89 | 89 | |
| 90 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') |
|
| 91 | - $icon = IconHelper::FILE_WORD; |
|
| 90 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') { |
|
| 91 | + $icon = IconHelper::FILE_WORD; |
|
| 92 | + } |
|
| 92 | 93 | |
| 93 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') |
|
| 94 | - $icon = IconHelper::FILE_EXCEL; |
|
| 94 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') { |
|
| 95 | + $icon = IconHelper::FILE_EXCEL; |
|
| 96 | + } |
|
| 95 | 97 | |
| 96 | - if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') |
|
| 97 | - $icon = IconHelper::FILE_POWERPOINT; |
|
| 98 | + if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') { |
|
| 99 | + $icon = IconHelper::FILE_POWERPOINT; |
|
| 100 | + } |
|
| 98 | 101 | |
| 99 | - if ($this->content_type == 'application/x-zip-compressed') |
|
| 100 | - $icon = IconHelper::FILE_ARCHIVE; |
|
| 102 | + if ($this->content_type == 'application/x-zip-compressed') { |
|
| 103 | + $icon = IconHelper::FILE_ARCHIVE; |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | - if ($this->content_type == 'application/octet-stream') |
|
| 103 | - $icon = IconHelper::FILE_ARCHIVE; |
|
| 106 | + if ($this->content_type == 'application/octet-stream') { |
|
| 107 | + $icon = IconHelper::FILE_ARCHIVE; |
|
| 108 | + } |
|
| 104 | 109 | |
| 105 | - if (preg_match('/audio/', $this->content_type)) |
|
| 106 | - $icon = IconHelper::FILE_AUDIO; |
|
| 110 | + if (preg_match('/audio/', $this->content_type)) { |
|
| 111 | + $icon = IconHelper::FILE_AUDIO; |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | - if (preg_match('/pdf/', $this->content_type)) |
|
| 109 | - $icon = IconHelper::FILE_PDF; |
|
| 114 | + if (preg_match('/pdf/', $this->content_type)) { |
|
| 115 | + $icon = IconHelper::FILE_PDF; |
|
| 116 | + } |
|
| 110 | 117 | |
| 111 | - if ($this->type == FileType::VIDEO) |
|
| 112 | - $icon = IconHelper::FILE_VIDEO; |
|
| 118 | + if ($this->type == FileType::VIDEO) { |
|
| 119 | + $icon = IconHelper::FILE_VIDEO; |
|
| 120 | + } |
|
| 113 | 121 | |
| 114 | 122 | return $icon; |
| 115 | 123 | } |
@@ -225,8 +233,9 @@ discard block |
||
| 225 | 233 | |
| 226 | 234 | public function getRootPreviewPath() |
| 227 | 235 | { |
| 228 | - if ($this->isSvg()) |
|
| 229 | - return $this->getRootPath(); |
|
| 236 | + if ($this->isSvg()) { |
|
| 237 | + return $this->getRootPath(); |
|
| 238 | + } |
|
| 230 | 239 | |
| 231 | 240 | return Yii::$app->getModule('files')->storageFullPath . $this->filename . '.jpg'; |
| 232 | 241 | } |
@@ -340,8 +349,9 @@ discard block |
||
| 340 | 349 | isset($this->behaviors['files']) && |
| 341 | 350 | isset($this->behaviors['files']->attributes[$this->field]) && |
| 342 | 351 | isset($this->behaviors['files']->attributes[$this->field]['watermark']) |
| 343 | - ) |
|
| 344 | - return $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
| 352 | + ) { |
|
| 353 | + return $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
| 354 | + } |
|
| 345 | 355 | } |
| 346 | 356 | |
| 347 | 357 | /** |
@@ -361,17 +371,20 @@ discard block |
||
| 361 | 371 | */ |
| 362 | 372 | public function getPreviewWebPath(int $width = 0, bool $webp = false) |
| 363 | 373 | { |
| 364 | - if (!file_exists($this->getRootPath())) |
|
| 365 | - return null; |
|
| 374 | + if (!file_exists($this->getRootPath())) { |
|
| 375 | + return null; |
|
| 376 | + } |
|
| 366 | 377 | |
| 367 | - if (!$this->isVideo() && !$this->isImage()) |
|
| 368 | - throw new ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
| 378 | + if (!$this->isVideo() && !$this->isImage()) { |
|
| 379 | + throw new ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
| 380 | + } |
|
| 369 | 381 | |
| 370 | - if (Yii::$app->getModule('files')->hostStatic) |
|
| 371 | - return |
|
| 382 | + if (Yii::$app->getModule('files')->hostStatic) { |
|
| 383 | + return |
|
| 372 | 384 | Yii::$app->getModule('files')->hostStatic . |
| 373 | 385 | $this->makeNameWithSize($this->filename, $width, $webp) . |
| 374 | 386 | "?hash={$this->hash}&width={$width}&webp=" . intval($webp); |
| 387 | + } |
|
| 375 | 388 | |
| 376 | 389 | return Url::toRoute(['/files/default/image', 'hash' => $this->hash, 'width' => $width, 'webp' => $webp]); |
| 377 | 390 | } |
@@ -407,8 +420,9 @@ discard block |
||
| 407 | 420 | */ |
| 408 | 421 | public function getPreviewRootPath($width = 0, $webp = false) |
| 409 | 422 | { |
| 410 | - if (!$this->isVideo() && !$this->isImage()) |
|
| 411 | - throw new ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
| 423 | + if (!$this->isVideo() && !$this->isImage()) { |
|
| 424 | + throw new ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
| 425 | + } |
|
| 412 | 426 | return $this->makeNameWithSize($this->rootPath, $width, $webp); |
| 413 | 427 | } |
| 414 | 428 | |