@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | Event::on( |
| 129 | 129 | CraftVariable::class, |
| 130 | 130 | CraftVariable::EVENT_INIT, |
| 131 | - function (Event $event) { |
|
| 131 | + function(Event $event) { |
|
| 132 | 132 | /** @var CraftVariable $variable */ |
| 133 | 133 | $variable = $event->sender; |
| 134 | 134 | $variable->set('transcoder', TranscoderVariable::class); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | Event::on( |
| 146 | 146 | Assets::class, |
| 147 | 147 | Assets::EVENT_GET_THUMB_PATH, |
| 148 | - function (AssetThumbEvent $event) { |
|
| 148 | + function(AssetThumbEvent $event) { |
|
| 149 | 149 | Craft::debug( |
| 150 | 150 | 'Assets::EVENT_GET_THUMB_PATH', |
| 151 | 151 | __METHOD__ |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | Event::on( |
| 162 | 162 | ClearCaches::class, |
| 163 | 163 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 164 | - function (RegisterCacheOptionsEvent $event) { |
|
| 164 | + function(RegisterCacheOptionsEvent $event) { |
|
| 165 | 165 | $event->options[] = [ |
| 166 | 166 | 'key' => 'transcoder', |
| 167 | 167 | 'label' => Craft::t('transcoder', 'Transcoder caches'), |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | Event::on( |
| 174 | 174 | Plugins::class, |
| 175 | 175 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 176 | - function (PluginEvent $event) { |
|
| 176 | + function(PluginEvent $event) { |
|
| 177 | 177 | if ($event->plugin === $this) { |
| 178 | 178 | $request = Craft::$app->getRequest(); |
| 179 | 179 | if ($request->isCpRequest) { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | Event::on( |
| 199 | 199 | UrlManager::class, |
| 200 | 200 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 201 | - function (RegisterUrlRulesEvent $event) { |
|
| 201 | + function(RegisterUrlRulesEvent $event) { |
|
| 202 | 202 | Craft::debug( |
| 203 | 203 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 204 | 204 | __METHOD__ |
@@ -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, '/ '); |
@@ -57,8 +57,8 @@ |
||
| 57 | 57 | // Use a md5 hash for the filenames instead of parameterized naming |
| 58 | 58 | 'useHashedNames' => false, |
| 59 | 59 | |
| 60 | - // if a upload location has a subfolder defined, add this to the transcoder paths too |
|
| 61 | - 'createSubfolders' => true, |
|
| 60 | + // if a upload location has a subfolder defined, add this to the transcoder paths too |
|
| 61 | + 'createSubfolders' => true, |
|
| 62 | 62 | |
| 63 | 63 | // Preset video encoders |
| 64 | 64 | 'videoEncoders' => [ |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $result = ''; |
| 97 | 97 | $settings = Transcoder::$plugin->getSettings(); |
| 98 | - $subfolder = ''; |
|
| 98 | + $subfolder = ''; |
|
| 99 | 99 | |
| 100 | - // sub folder check |
|
| 101 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 102 | - $subfolder = $filePath->folderPath; |
|
| 103 | - } |
|
| 100 | + // sub folder check |
|
| 101 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 102 | + $subfolder = $filePath->folderPath; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - // file path |
|
| 105 | + // file path |
|
| 106 | 106 | $filePath = $this->getAssetPath($filePath); |
| 107 | 107 | |
| 108 | 108 | if (!empty($filePath)) { |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | // skip encoding |
| 205 | 205 | } elseif (!$generate) { |
| 206 | - $result = ""; |
|
| 206 | + $result = ""; |
|
| 207 | 207 | } else { |
| 208 | 208 | // Kick off the transcoding |
| 209 | 209 | $pid = $this->executeShellCommand($ffmpegCmd); |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | { |
| 233 | 233 | $result = null; |
| 234 | 234 | $settings = Transcoder::$plugin->getSettings(); |
| 235 | - $subfolder = ''; |
|
| 235 | + $subfolder = ''; |
|
| 236 | 236 | |
| 237 | - // sub folder check |
|
| 238 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 239 | - $subfolder = $filePath->folderPath; |
|
| 240 | - } |
|
| 237 | + // sub folder check |
|
| 238 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 239 | + $subfolder = $filePath->folderPath; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | $filePath = $this->getAssetPath($filePath); |
| 243 | 243 | |
@@ -324,12 +324,12 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | $result = ''; |
| 326 | 326 | $settings = Transcoder::$plugin->getSettings(); |
| 327 | - $subfolder = ''; |
|
| 327 | + $subfolder = ''; |
|
| 328 | 328 | |
| 329 | - // sub folder check |
|
| 330 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 331 | - $subfolder = $filePath->folderPath; |
|
| 332 | - } |
|
| 329 | + // sub folder check |
|
| 330 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 331 | + $subfolder = $filePath->folderPath; |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | 334 | $filePath = $this->getAssetPath($filePath); |
| 335 | 335 | |
@@ -588,12 +588,12 @@ discard block |
||
| 588 | 588 | { |
| 589 | 589 | $result = ''; |
| 590 | 590 | $settings = Transcoder::$plugin->getSettings(); |
| 591 | - $subfolder = ''; |
|
| 591 | + $subfolder = ''; |
|
| 592 | 592 | |
| 593 | - // sub folder check |
|
| 594 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 595 | - $subfolder = $filePath->folderPath; |
|
| 596 | - } |
|
| 593 | + // sub folder check |
|
| 594 | + if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 595 | + $subfolder = $filePath->folderPath; |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | 598 | $filePath = $this->getAssetPath($filePath); |
| 599 | 599 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $subfolder = ''; |
| 99 | 99 | |
| 100 | 100 | // sub folder check |
| 101 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 101 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 102 | 102 | $subfolder = $filePath->folderPath; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $filePath = $this->getAssetPath($filePath); |
| 107 | 107 | |
| 108 | 108 | if (!empty($filePath)) { |
| 109 | - $destVideoPath = $settings['transcoderPaths']['video'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
| 109 | + $destVideoPath = $settings['transcoderPaths']['video'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
| 110 | 110 | $destVideoPath = Craft::getAlias($destVideoPath); |
| 111 | 111 | $videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions); |
| 112 | 112 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
| 200 | 200 | if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) { |
| 201 | - $url = $settings['transcoderUrls']['video'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 201 | + $url = $settings['transcoderUrls']['video'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 202 | 202 | $result = Craft::getAlias($url).$destVideoFile; |
| 203 | 203 | |
| 204 | 204 | // skip encoding |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | $subfolder = ''; |
| 236 | 236 | |
| 237 | 237 | // sub folder check |
| 238 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 238 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 239 | 239 | $subfolder = $filePath->folderPath; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $filePath = $this->getAssetPath($filePath); |
| 243 | 243 | |
| 244 | 244 | if (!empty($filePath)) { |
| 245 | - $destThumbnailPath = $settings['transcoderPaths']['thumbnail'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
| 245 | + $destThumbnailPath = $settings['transcoderPaths']['thumbnail'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
| 246 | 246 | $destThumbnailPath = Craft::getAlias($destThumbnailPath); |
| 247 | 247 | |
| 248 | 248 | $thumbnailOptions = $this->coalesceOptions('defaultThumbnailOptions', $thumbnailOptions); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | if ($asPath) { |
| 304 | 304 | $result = $destThumbnailPath; |
| 305 | 305 | } else { |
| 306 | - $url = $settings['transcoderUrls']['thumbnail'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 306 | + $url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 307 | 307 | $result = Craft::getAlias($url).$destThumbnailFile; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -327,14 +327,14 @@ discard block |
||
| 327 | 327 | $subfolder = ''; |
| 328 | 328 | |
| 329 | 329 | // sub folder check |
| 330 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 330 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 331 | 331 | $subfolder = $filePath->folderPath; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $filePath = $this->getAssetPath($filePath); |
| 335 | 335 | |
| 336 | 336 | if (!empty($filePath)) { |
| 337 | - $destAudioPath = $settings['transcoderPaths']['audio'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
| 337 | + $destAudioPath = $settings['transcoderPaths']['audio'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
| 338 | 338 | $destAudioPath = Craft::getAlias($destAudioPath); |
| 339 | 339 | |
| 340 | 340 | $audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions); |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | // If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
| 406 | 406 | if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) { |
| 407 | - $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 407 | + $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 408 | 408 | $result = Craft::getAlias($url).$destAudioFile; |
| 409 | 409 | } else { |
| 410 | 410 | // Kick off the transcoding |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | && (strpos($summaryResult['videoFrameRate'], '/') !== false) |
| 480 | 480 | ) { |
| 481 | 481 | $parts = explode('/', $summaryResult['videoFrameRate']); |
| 482 | - $summaryResult['videoFrameRate'] = (float)$parts[0] / (float)$parts[1]; |
|
| 482 | + $summaryResult['videoFrameRate'] = (float) $parts[0] / (float) $parts[1]; |
|
| 483 | 483 | } |
| 484 | 484 | $result = $summaryResult; |
| 485 | 485 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | $subfolder = ''; |
| 592 | 592 | |
| 593 | 593 | // sub folder check |
| 594 | - if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 594 | + if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) { |
|
| 595 | 595 | $subfolder = $filePath->folderPath; |
| 596 | 596 | } |
| 597 | 597 | |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | if (!empty($filePath)) { |
| 601 | 601 | // Dest path |
| 602 | - $destVideoPath = $settings['transcoderPaths']['gif'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
| 602 | + $destVideoPath = $settings['transcoderPaths']['gif'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
| 603 | 603 | $destVideoPath = Craft::getAlias($destVideoPath); |
| 604 | 604 | |
| 605 | 605 | // Options |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
| 655 | 655 | if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) { |
| 656 | - $url = $settings['transcoderUrls']['gif'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
| 656 | + $url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
| 657 | 657 | $result = Craft::getAlias($url).$destVideoFile; |
| 658 | 658 | } else { |
| 659 | 659 | // Kick off the transcoding |
@@ -739,14 +739,14 @@ discard block |
||
| 739 | 739 | // If it's local, get a path to the file |
| 740 | 740 | if ($assetVolume instanceof Local) { |
| 741 | 741 | $sourcePath = rtrim($assetVolume->path, DIRECTORY_SEPARATOR); |
| 742 | - $sourcePath .= '' === $sourcePath ? '': DIRECTORY_SEPARATOR; |
|
| 742 | + $sourcePath .= '' === $sourcePath ? '' : DIRECTORY_SEPARATOR; |
|
| 743 | 743 | $folderPath = ''; |
| 744 | 744 | try { |
| 745 | 745 | $folderPath = rtrim($asset->getFolder()->path, DIRECTORY_SEPARATOR); |
| 746 | 746 | } catch (InvalidConfigException $e) { |
| 747 | 747 | Craft::error($e->getMessage(), __METHOD__); |
| 748 | 748 | } |
| 749 | - $folderPath .= '' === $folderPath ? '': DIRECTORY_SEPARATOR; |
|
| 749 | + $folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR; |
|
| 750 | 750 | |
| 751 | 751 | $filePath = $sourcePath.$folderPath.$asset->filename; |
| 752 | 752 | } else { |