@@ -155,7 +155,7 @@ |
||
| 155 | 155 | { |
| 156 | 156 | $result = ''; |
| 157 | 157 | $filePath = parse_url($url, PHP_URL_PATH); |
| 158 | - $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath; |
|
| 158 | + $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath; |
|
| 159 | 159 | if (file_exists($filePath)) { |
| 160 | 160 | $urlParams = [ |
| 161 | 161 | 'url' => $url, |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * |
| 31 | 31 | * @param $filePath |
| 32 | 32 | * @param $videoOptions |
| 33 | - * @bool $generate |
|
| 33 | + * @bool $generate |
|
| 34 | 34 | * |
| 35 | 35 | * @return string |
| 36 | 36 | */ |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // rawDuration is in 00:00:00.00 format. This converts it to seconds. |
| 86 | 86 | $ar = array_reverse(explode(':', $rawDuration)); |
| 87 | - $duration = (float)$ar[0]; |
|
| 87 | + $duration = (float) $ar[0]; |
|
| 88 | 88 | if (!empty($ar[1])) { |
| 89 | - $duration += (int)$ar[1] * 60; |
|
| 89 | + $duration += (int) $ar[1] * 60; |
|
| 90 | 90 | } |
| 91 | 91 | if (!empty($ar[2])) { |
| 92 | - $duration += (int)$ar[2] * 60 * 60; |
|
| 92 | + $duration += (int) $ar[2] * 60 * 60; |
|
| 93 | 93 | } |
| 94 | 94 | } else { |
| 95 | 95 | $duration = 'unknown'; // with GIF as input, duration is unknown |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | //rawTime is in 00:00:00.00 format. This converts it to seconds. |
| 108 | 108 | $ar = array_reverse(explode(':', $rawTime)); |
| 109 | - $time = (float)$ar[0]; |
|
| 109 | + $time = (float) $ar[0]; |
|
| 110 | 110 | if (!empty($ar[1])) { |
| 111 | - $time += (int)$ar[1] * 60; |
|
| 111 | + $time += (int) $ar[1] * 60; |
|
| 112 | 112 | } |
| 113 | 113 | if (!empty($ar[2])) { |
| 114 | - $time += (int)$ar[2] * 60 * 60; |
|
| 114 | + $time += (int) $ar[2] * 60 * 60; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | //calculate the progress |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $cache = Craft::$app->getCache(); |
| 301 | 301 | $file = $cache->getOrSet( |
| 302 | 302 | self::CACHE_KEY.$path, |
| 303 | - function () use ($path) { |
|
| 303 | + function() use ($path) { |
|
| 304 | 304 | $result = null; |
| 305 | 305 | $string = @file_get_contents($path); |
| 306 | 306 | if ($string) { |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | protected static function combinePaths(string ...$paths): string |
| 328 | 328 | { |
| 329 | 329 | $last_key = \count($paths) - 1; |
| 330 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
| 330 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
| 331 | 331 | switch ($key) { |
| 332 | 332 | case 0: |
| 333 | 333 | $val = rtrim($val, '/ '); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | Event::on( |
| 132 | 132 | CraftVariable::class, |
| 133 | 133 | CraftVariable::EVENT_INIT, |
| 134 | - function (Event $event) { |
|
| 134 | + function(Event $event) { |
|
| 135 | 135 | /** @var CraftVariable $variable */ |
| 136 | 136 | $variable = $event->sender; |
| 137 | 137 | $variable->set('transcoder', TranscoderVariable::class); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | Event::on( |
| 150 | 150 | Assets::class, |
| 151 | 151 | Assets::EVENT_GET_THUMB_PATH, |
| 152 | - function (AssetThumbEvent $event) { |
|
| 152 | + function(AssetThumbEvent $event) { |
|
| 153 | 153 | Craft::debug( |
| 154 | 154 | 'Assets::EVENT_GET_THUMB_PATH', |
| 155 | 155 | __METHOD__ |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | Event::on( |
| 167 | 167 | ClearCaches::class, |
| 168 | 168 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 169 | - function (RegisterCacheOptionsEvent $event) { |
|
| 169 | + function(RegisterCacheOptionsEvent $event) { |
|
| 170 | 170 | $event->options[] = [ |
| 171 | 171 | 'key' => 'transcoder', |
| 172 | 172 | 'label' => Craft::t('transcoder', 'Transcoder caches'), |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | Event::on( |
| 180 | 180 | Plugins::class, |
| 181 | 181 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 182 | - function (PluginEvent $event) { |
|
| 182 | + function(PluginEvent $event) { |
|
| 183 | 183 | if ($event->plugin === $this) { |
| 184 | 184 | $request = Craft::$app->getRequest(); |
| 185 | 185 | if ($request->isCpRequest) { |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | Event::on( |
| 205 | 205 | UrlManager::class, |
| 206 | 206 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 207 | - function (RegisterUrlRulesEvent $event) { |
|
| 207 | + function(RegisterUrlRulesEvent $event) { |
|
| 208 | 208 | Craft::debug( |
| 209 | 209 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 210 | 210 | __METHOD__ |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $result = ''; |
| 99 | 99 | $settings = Transcoder::$plugin->getSettings(); |
| 100 | - $subfolder = ''; |
|
| 100 | + $subfolder = ''; |
|
| 101 | 101 | |
| 102 | - // sub folder check |
|
| 103 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 104 | - $subfolder = $filePath->folderPath; |
|
| 105 | - } |
|
| 102 | + // sub folder check |
|
| 103 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 104 | + $subfolder = $filePath->folderPath; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // file path |
|
| 107 | + // file path |
|
| 108 | 108 | $filePath = $this->getAssetPath($filePath); |
| 109 | 109 | |
| 110 | 110 | if (!empty($filePath)) { |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | // skip encoding |
| 206 | 206 | } elseif (!$generate) { |
| 207 | - $result = ""; |
|
| 207 | + $result = ""; |
|
| 208 | 208 | } else { |
| 209 | 209 | // Kick off the transcoding |
| 210 | 210 | $pid = $this->executeShellCommand($ffmpegCmd); |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | $result = null; |
| 240 | 240 | $settings = Transcoder::$plugin->getSettings(); |
| 241 | - $subfolder = ''; |
|
| 241 | + $subfolder = ''; |
|
| 242 | 242 | |
| 243 | - // sub folder check |
|
| 244 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 245 | - $subfolder = $filePath->folderPath; |
|
| 246 | - } |
|
| 243 | + // sub folder check |
|
| 244 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 245 | + $subfolder = $filePath->folderPath; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | $filePath = $this->getAssetPath($filePath); |
| 249 | 249 | |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | { |
| 335 | 335 | $result = ''; |
| 336 | 336 | $settings = Transcoder::$plugin->getSettings(); |
| 337 | - $subfolder = ''; |
|
| 337 | + $subfolder = ''; |
|
| 338 | 338 | |
| 339 | - // sub folder check |
|
| 340 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 341 | - $subfolder = $filePath->folderPath; |
|
| 342 | - } |
|
| 339 | + // sub folder check |
|
| 340 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 341 | + $subfolder = $filePath->folderPath; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | 344 | $filePath = $this->getAssetPath($filePath); |
| 345 | 345 | |
@@ -603,12 +603,12 @@ discard block |
||
| 603 | 603 | { |
| 604 | 604 | $result = ''; |
| 605 | 605 | $settings = Transcoder::$plugin->getSettings(); |
| 606 | - $subfolder = ''; |
|
| 606 | + $subfolder = ''; |
|
| 607 | 607 | |
| 608 | - // sub folder check |
|
| 609 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 610 | - $subfolder = $filePath->folderPath; |
|
| 611 | - } |
|
| 608 | + // sub folder check |
|
| 609 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 610 | + $subfolder = $filePath->folderPath; |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | 613 | $filePath = $this->getAssetPath($filePath); |
| 614 | 614 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $subfolder = ''; |
| 101 | 101 | |
| 102 | 102 | // sub folder check |
| 103 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 103 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 104 | 104 | $subfolder = $filePath->folderPath; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $subfolder = ''; |
| 242 | 242 | |
| 243 | 243 | // sub folder check |
| 244 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 244 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 245 | 245 | $subfolder = $filePath->folderPath; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | if ($asPath) { |
| 314 | 314 | $result = $destThumbnailPath; |
| 315 | 315 | } else { |
| 316 | - $url = $settings['transcoderUrls']['thumbnail'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 316 | + $url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 317 | 317 | $result = Craft::getAlias($url).$destThumbnailFile; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $subfolder = ''; |
| 338 | 338 | |
| 339 | 339 | // sub folder check |
| 340 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 340 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 341 | 341 | $subfolder = $filePath->folderPath; |
| 342 | 342 | } |
| 343 | 343 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | |
| 414 | 414 | // If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
| 415 | 415 | if ($this->shouldGenerateAsset('audio', $destAudioPath, $filePath)) { |
| 416 | - $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 416 | + $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 417 | 417 | $result = Craft::getAlias($url).$destAudioFile; |
| 418 | 418 | } else { |
| 419 | 419 | // Kick off the transcoding |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | && (strpos($summaryResult['videoFrameRate'], '/') !== false) |
| 495 | 495 | ) { |
| 496 | 496 | $parts = explode('/', $summaryResult['videoFrameRate']); |
| 497 | - $summaryResult['videoFrameRate'] = (float)$parts[0] / (float)$parts[1]; |
|
| 497 | + $summaryResult['videoFrameRate'] = (float) $parts[0] / (float) $parts[1]; |
|
| 498 | 498 | } |
| 499 | 499 | $result = $summaryResult; |
| 500 | 500 | } |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | $subfolder = ''; |
| 607 | 607 | |
| 608 | 608 | // sub folder check |
| 609 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 609 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 610 | 610 | $subfolder = $filePath->folderPath; |
| 611 | 611 | } |
| 612 | 612 | |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
| 669 | 669 | if ($this->shouldGenerateAsset('gif', $destVideoPath, $filePath)) { |
| 670 | - $url = $settings['transcoderUrls']['gif'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 670 | + $url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 671 | 671 | $result = Craft::getAlias($url).$destVideoFile; |
| 672 | 672 | } else { |
| 673 | 673 | // Kick off the transcoding |
@@ -757,14 +757,14 @@ discard block |
||
| 757 | 757 | // If it's local, get a path to the file |
| 758 | 758 | if ($assetVolume instanceof Local) { |
| 759 | 759 | $sourcePath = rtrim($assetVolume->path, DIRECTORY_SEPARATOR); |
| 760 | - $sourcePath .= '' === $sourcePath ? '': DIRECTORY_SEPARATOR; |
|
| 760 | + $sourcePath .= '' === $sourcePath ? '' : DIRECTORY_SEPARATOR; |
|
| 761 | 761 | $folderPath = ''; |
| 762 | 762 | try { |
| 763 | 763 | $folderPath = rtrim($asset->getFolder()->path, DIRECTORY_SEPARATOR); |
| 764 | 764 | } catch (InvalidConfigException $e) { |
| 765 | 765 | Craft::error($e->getMessage(), __METHOD__); |
| 766 | 766 | } |
| 767 | - $folderPath .= '' === $folderPath ? '': DIRECTORY_SEPARATOR; |
|
| 767 | + $folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR; |
|
| 768 | 768 | |
| 769 | 769 | $filePath = $sourcePath.$folderPath.$asset->filename; |
| 770 | 770 | } else { |