From 3d65a24d331e8a66af2c2352e2df2c52fc2078b4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 27 Apr 2019 12:05:33 +0200 Subject: [PATCH] php cs fixer --- Admin/Routes/Web/Api.php | 4 +- Admin/Routes/Web/Backend.php | 2 +- Controller/ApiController.php | 4 +- Models/FileStorageInterface.php | 2 +- Models/FtpFileStorage.php | 2 +- Models/LocalFileStorage.php | 2 +- Models/UploadFile.php | 14 +- Theme/Backend/Lang/Navigation.en.lang.php | 2 +- Theme/Backend/Lang/api.en.lang.php | 2 +- Theme/Backend/Lang/en.lang.php | 2 +- Theme/Backend/media-create.tpl.php | 2 +- Theme/Backend/media-list.tpl.php | 2 +- Theme/Backend/media-single.tpl.php | 4 +- Theme/Backend/template-functions.php | 60 ++++---- Views/MediaView.php | 170 +++++++++++----------- 15 files changed, 136 insertions(+), 138 deletions(-) diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index 57ae8c3..fd07fdc 100644 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -1,4 +1,4 @@ - [ 'field_name' => [ 'type' => 'string', 'default' => 'Hello', 'validation' => '[\\w]*', 'required' => false,'annotation' => [], - ] + ], ], ], ], diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 8e554bd..f242f1b 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -1,4 +1,4 @@ -getUploadError($f['error']); return $result; @@ -223,7 +223,7 @@ class UploadFile $sha .= '.' . $extension; $fileName = $sha; $rnd = \mt_rand(); - $limit++; + ++$limit; } while (\file_exists($path . '/' . $fileName) && $limit < self::PATH_GENERATION_LIMIT); if ($limit >= self::PATH_GENERATION_LIMIT) { @@ -282,7 +282,7 @@ class UploadFile private function findOutputDir(array $files) : string { do { - $rndPath = \str_pad(\dechex(\rand(0, 65535)), 4, '0', STR_PAD_LEFT); + $rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT); } while (\file_exists($this->outputDir . '/' . $rndPath)); return $this->outputDir . '/' . $rndPath; @@ -300,11 +300,11 @@ class UploadFile private function getUploadError($error) : int { switch ($error) { - case UPLOAD_ERR_NO_FILE: + case \UPLOAD_ERR_NO_FILE: // TODO: no file sent return UploadStatus::NOTHING_UPLOADED; - case UPLOAD_ERR_INI_SIZE: - case UPLOAD_ERR_FORM_SIZE: + case \UPLOAD_ERR_INI_SIZE: + case \UPLOAD_ERR_FORM_SIZE: return UploadStatus::UPLOAD_SIZE; default: return UploadStatus::UNKNOWN_ERROR; diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index a95e1b4..7d11c16 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -1,4 +1,4 @@ -getData('media'); echo $this->getData('nav')->render(); diff --git a/Theme/Backend/template-functions.php b/Theme/Backend/template-functions.php index e040c17..864f92f 100644 --- a/Theme/Backend/template-functions.php +++ b/Theme/Backend/template-functions.php @@ -1,30 +1,30 @@ -getPath() . $sub) - && StringUtils::startsWith( - \str_replace('\\', '/', \realpath($media->getPath() . $sub)), - $media->getPath() - ) - ) { - return $media->getPath() . $sub; - } - - return $media->getPath(); - } - - protected function dirPathFunction(Media $media, string $sub) : string - { - if (\is_dir($media->getPath() . $sub) - && StringUtils::startsWith( - \str_replace('\\', '/', \realpath($media->getPath() . $sub)), - $media->getPath() - ) - ) { - return $media->getPath() . $sub; - } - - return $media->getPath(); - } - - protected function isCollectionFunction(Media $media, string $sub) : bool - { - return ($media->getExtension() === 'collection' - && !\is_file($media->getPath() . $sub)) - || (\is_dir($media->getPath()) - && ($sub === null || \is_dir($media->getPath() . $sub)) - ); - } - - protected function lineContentFunction(string $path) : array - { - $output = \file_get_contents($path); - $output = \str_replace(["\r\n", "\r"], "\n", $output); - - return \explode("\n", $output); - } - - protected function isImageFunction(Media $media, string $path) : bool - { - return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE - || FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE; - } -} +getPath() . $sub) + && StringUtils::startsWith( + \str_replace('\\', '/', \realpath($media->getPath() . $sub)), + $media->getPath() + ) + ) { + return $media->getPath() . $sub; + } + + return $media->getPath(); + } + + protected function dirPathFunction(Media $media, string $sub) : string + { + if (\is_dir($media->getPath() . $sub) + && StringUtils::startsWith( + \str_replace('\\', '/', \realpath($media->getPath() . $sub)), + $media->getPath() + ) + ) { + return $media->getPath() . $sub; + } + + return $media->getPath(); + } + + protected function isCollectionFunction(Media $media, string $sub) : bool + { + return ($media->getExtension() === 'collection' + && !\is_file($media->getPath() . $sub)) + || (\is_dir($media->getPath()) + && ($sub === null || \is_dir($media->getPath() . $sub)) + ); + } + + protected function lineContentFunction(string $path) : array + { + $output = \file_get_contents($path); + $output = \str_replace(["\r\n", "\r"], "\n", $output); + + return \explode("\n", $output); + } + + protected function isImageFunction(Media $media, string $path) : bool + { + return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE + || FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE; + } +}