@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * Thumbnails image cache. |
| 28 | 28 | */ |
| 29 | - const TYPE_THUMB = 'thumb'; |
|
| 29 | + const TYPE_THUMB = 'thumb'; |
|
| 30 | 30 | /** |
| 31 | 31 | * Finder cache. |
| 32 | 32 | */ |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | self::rebuildCacheFolders(); |
| 57 | 57 | return self::getCachePath($type, true); |
| 58 | 58 | } else if (!$path) { |
| 59 | - throw new IOException('Cache folders are not writable: '. $cache); |
|
| 59 | + throw new IOException('Cache folders are not writable: '.$cache); |
|
| 60 | 60 | } |
| 61 | 61 | return $path; |
| 62 | 62 | } |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | self::createDomainThumbCacheFolder($domain, $type); |
| 79 | 79 | $domainFolder = FileUtils::getPath(self::getCachePath($type), $domain); |
| 80 | 80 | if ($type === self::TYPE_THUMB) { |
| 81 | - $suffix = $width . $height . ($crop ? '1' : '0') .'.png'; |
|
| 81 | + $suffix = $width.$height.($crop ? '1' : '0').'.png'; |
|
| 82 | 82 | } else { |
| 83 | - $suffix = $width . $height; |
|
| 83 | + $suffix = $width.$height; |
|
| 84 | 84 | } |
| 85 | - return $domainFolder . self::getThumbFilename($url) . $suffix; |
|
| 85 | + return $domainFolder.self::getThumbFilename($url).$suffix; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public static function isCacheValid($cacheFile, $domain, $type) { |
| 101 | 101 | $out = false; |
| 102 | - $cacheDuration = ConfigManager::get('settings.cache_duration', 3600*24*31); |
|
| 102 | + $cacheDuration = ConfigManager::get('settings.cache_duration', 3600 * 24 * 31); |
|
| 103 | 103 | |
| 104 | 104 | if (is_readable($cacheFile) |
| 105 | 105 | && ($cacheDuration < 0 || (time() - filemtime($cacheFile)) < $cacheDuration) |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected static function createDomainThumbCacheFolder($domain, $type) |
| 122 | 122 | { |
| 123 | - $domainFolder = self::getCachePath($type) . $domain; |
|
| 123 | + $domainFolder = self::getCachePath($type).$domain; |
|
| 124 | 124 | if (!file_exists($domainFolder)) { |
| 125 | 125 | mkdir($domainFolder, 0775, false); |
| 126 | - touch($domainFolder . '/' . self::$CLEAN_FILE); |
|
| 126 | + touch($domainFolder.'/'.self::$CLEAN_FILE); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | protected static function checkCacheType($type) |
| 151 | 151 | { |
| 152 | 152 | if ($type != self::TYPE_THUMB && $type != self::TYPE_FINDER) { |
| 153 | - throw new CacheException('Unknown cache type '. $type); |
|
| 153 | + throw new CacheException('Unknown cache type '.$type); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -160,19 +160,19 @@ discard block |
||
| 160 | 160 | protected static function rebuildCacheFolders() |
| 161 | 161 | { |
| 162 | 162 | $mainFolder = ConfigManager::get('settings.path.cache', 'cache/'); |
| 163 | - if (! is_dir($mainFolder)) { |
|
| 163 | + if (!is_dir($mainFolder)) { |
|
| 164 | 164 | mkdir($mainFolder, 0755); |
| 165 | 165 | } |
| 166 | - if (! is_dir($mainFolder.self::TYPE_THUMB)) { |
|
| 166 | + if (!is_dir($mainFolder.self::TYPE_THUMB)) { |
|
| 167 | 167 | mkdir($mainFolder.self::TYPE_THUMB, 0755); |
| 168 | 168 | } |
| 169 | - if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) { |
|
| 170 | - touch($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep'); |
|
| 169 | + if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) { |
|
| 170 | + touch($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep'); |
|
| 171 | 171 | } |
| 172 | - if (! is_dir($mainFolder.self::TYPE_FINDER)) { |
|
| 173 | - mkdir($mainFolder . self::TYPE_FINDER, 0755); |
|
| 172 | + if (!is_dir($mainFolder.self::TYPE_FINDER)) { |
|
| 173 | + mkdir($mainFolder.self::TYPE_FINDER, 0755); |
|
| 174 | 174 | } |
| 175 | - if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) { |
|
| 175 | + if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) { |
|
| 176 | 176 | touch($mainFolder.self::TYPE_FINDER.DIRECTORY_SEPARATOR.'.gitkeep'); |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @var string Path to resources folder. |
| 14 | 14 | */ |
| 15 | - const RESOURCES_PATH = __DIR__ . DIRECTORY_SEPARATOR .'..'. DIRECTORY_SEPARATOR .'resources'. DIRECTORY_SEPARATOR; |
|
| 15 | + const RESOURCES_PATH = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Build the real path from all given folders, with a trailing /. |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | if ($nbArgs == 0) { |
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | - for($i = 0; $i < $nbArgs; $i++) { |
|
| 33 | - $out .= rtrim(rtrim(func_get_arg($i), '/'), '\\') . DIRECTORY_SEPARATOR; |
|
| 32 | + for ($i = 0; $i < $nbArgs; $i++) { |
|
| 33 | + $out .= rtrim(rtrim(func_get_arg($i), '/'), '\\').DIRECTORY_SEPARATOR; |
|
| 34 | 34 | } |
| 35 | 35 | $out = realpath($out); |
| 36 | - return $out !== false ? $out . DIRECTORY_SEPARATOR : false; |
|
| 36 | + return $out !== false ? $out.DIRECTORY_SEPARATOR : false; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function rmdir($path) |
| 47 | 47 | { |
| 48 | - if (empty($path) || $path == '/' || ! self::getPath($path)) { |
|
| 48 | + if (empty($path) || $path == '/' || !self::getPath($path)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | if (preg_match($this->urlRegex, $this->url, $matches) !== 0) { |
| 61 | 61 | $total = count($matches); |
| 62 | 62 | for ($i = 1; $i < $total; $i++) { |
| 63 | - $this->thumbnailUrl = str_replace('${'. $i . '}', $matches[$i], $this->thumbnailUrl); |
|
| 63 | + $this->thumbnailUrl = str_replace('${'.$i.'}', $matches[$i], $this->thumbnailUrl); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Match only options (not ${number}) |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // With curl, the thumb is extracted during the download |
| 91 | - if ($this->webAccess instanceof WebAccessCUrl && ! empty($thumbnail)) { |
|
| 91 | + if ($this->webAccess instanceof WebAccessCUrl && !empty($thumbnail)) { |
|
| 92 | 92 | return $thumbnail; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | if (preg_match($this->urlRegex, $content, $matches) !== 0) { |
| 155 | 155 | $total = count($matches); |
| 156 | 156 | for ($i = 1; $i < $total; $i++) { |
| 157 | - $thumbnailUrl = str_replace('${'. $i . '}', $matches[$i], $thumbnailUrl); |
|
| 157 | + $thumbnailUrl = str_replace('${'.$i.'}', $matches[$i], $thumbnailUrl); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Match only options (not ${number}) |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function checkRules($rules) |
| 175 | 175 | { |
| 176 | - if (! FinderUtils::checkMandatoryRules($rules, [ |
|
| 176 | + if (!FinderUtils::checkMandatoryRules($rules, [ |
|
| 177 | 177 | 'image_regex', |
| 178 | 178 | 'thumbnail_url' |
| 179 | 179 | ])) { |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | try { |
| 34 | 34 | list($domain, $finder, $rules, $options) = self::getThumbnailMeta($domain, $url); |
| 35 | 35 | |
| 36 | - $className = '\\WebThumbnailer\\Finder\\' . $finder . 'Finder'; |
|
| 36 | + $className = '\\WebThumbnailer\\Finder\\'.$finder.'Finder'; |
|
| 37 | 37 | if (!class_exists($className)) { |
| 38 | 38 | throw new Exception\UnsupportedDomainException(); |
| 39 | 39 | } |
| 40 | - } catch(Exception\UnsupportedDomainException $e) { |
|
| 40 | + } catch (Exception\UnsupportedDomainException $e) { |
|
| 41 | 41 | $className = '\\WebThumbnailer\\Finder\\DefaultFinder'; |
| 42 | 42 | $rules = []; |
| 43 | 43 | $options = []; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $jsonFiles = ConfigManager::get('settings.rules_filename', ['rules.json']); |
| 64 | 64 | $allRules = []; |
| 65 | 65 | foreach ($jsonFiles as $file) { |
| 66 | - $allRules = array_merge($allRules, DataUtils::loadJson(FileUtils::RESOURCES_PATH . $file)); |
|
| 66 | + $allRules = array_merge($allRules, DataUtils::loadJson(FileUtils::RESOURCES_PATH.$file)); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $domain = null; |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if(!empty($value['url_exclude'])) { |
|
| 86 | + if (!empty($value['url_exclude'])) { |
|
| 87 | 87 | preg_match(FinderUtils::buildRegex($value['url_exclude'], 'i'), $url, $match); |
| 88 | - if(!empty($match)) { |
|
| 88 | + if (!empty($match)) { |
|
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if(!empty($value['url_require'])) { |
|
| 93 | + if (!empty($value['url_require'])) { |
|
| 94 | 94 | preg_match(FinderUtils::buildRegex($value['url_require'], 'i'), $url, $match); |
| 95 | - if(empty($match)) { |
|
| 95 | + if (empty($match)) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | } |