@@ -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 | } |
@@ -257,8 +266,9 @@ discard block |
||
| 257 | 266 | |
| 258 | 267 | public function getHref() |
| 259 | 268 | { |
| 260 | - if (Yii::$app->getModule('files')->hostStatic) |
|
| 261 | - return Yii::$app->getModule('files')->hostStatic . $this->filename; |
|
| 269 | + if (Yii::$app->getModule('files')->hostStatic) { |
|
| 270 | + return Yii::$app->getModule('files')->hostStatic . $this->filename; |
|
| 271 | + } |
|
| 262 | 272 | return Url::to(['/files/default/get', 'hash' => $this->hash]); |
| 263 | 273 | } |
| 264 | 274 | |
@@ -334,8 +344,9 @@ discard block |
||
| 334 | 344 | isset($this->behaviors['files']) && |
| 335 | 345 | isset($this->behaviors['files']->attributes[$this->field]) && |
| 336 | 346 | isset($this->behaviors['files']->attributes[$this->field]['watermark']) |
| 337 | - ) |
|
| 338 | - return $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
| 347 | + ) { |
|
| 348 | + return $this->behaviors['files']->attributes[$this->field]['watermark']; |
|
| 349 | + } |
|
| 339 | 350 | } |
| 340 | 351 | |
| 341 | 352 | /** |
@@ -355,14 +366,17 @@ discard block |
||
| 355 | 366 | */ |
| 356 | 367 | public function getPreviewWebPath(int $width = 0, bool $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->isVideo() && !$this->isImage()) |
|
| 362 | - throw new ErrorException('Requiested file is not an image and its implsible to resize it.'); |
|
| 373 | + if (!$this->isVideo() && !$this->isImage()) { |
|
| 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, $webp = false); |
|
| 377 | + if (Yii::$app->getModule('files')->hostStatic) { |
|
| 378 | + return Yii::$app->getModule('files')->hostStatic . $this->makeNameWithSize($this->filename, $width, $webp = false); |
|
| 379 | + } |
|
| 366 | 380 | |
| 367 | 381 | return Url::toRoute(['/files/default/image', 'hash' => $this->hash, 'width' => $width, 'webp' => $webp]); |
| 368 | 382 | } |
@@ -406,8 +420,9 @@ discard block |
||
| 406 | 420 | */ |
| 407 | 421 | public function getPreviewRootPath($width = 0, $webp = false) |
| 408 | 422 | { |
| 409 | - if (!$this->isVideo() && !$this->isImage()) |
|
| 410 | - 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 | + } |
|
| 411 | 426 | return $this->makeNameWithSize($this->rootPath, $width, $webp); |
| 412 | 427 | } |
| 413 | 428 | |