diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 0d6cda6..40f6261 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -175,6 +175,17 @@ final class ApiController extends Controller return $mediaCreated; } + /** + * Create db entry for uploaded file + * + * @param array $status Files + * @param int $account Uploader + * @param string $virtualPath Virtual path (not on the hard-drive) + * + * @return null|Media + * + * @since 1.0.0 + */ public static function createDbEntry(array $status, int $account, string $virtualPath = '/') : ?Media { $media = null; @@ -195,6 +206,15 @@ final class ApiController extends Controller return $media; } + /** + * Normalize the file path + * + * @param string $path Path to the file + * + * @return string + * + * @since 1.0.0 + */ private static function normalizeDbPath(string $path) : string { $realpath = \realpath(__DIR__ . '/../../../'); diff --git a/Models/FileStorageInterface.php b/Models/FileStorageInterface.php index 7b4d42a..4bb7c4b 100644 --- a/Models/FileStorageInterface.php +++ b/Models/FileStorageInterface.php @@ -1,4 +1,4 @@ -id; } - public function encrypt(string $password, string $outputPath) : void + /** + * Encrypt the media file + * + * @param string $password Password to encrypt the file with + * @param null|string $outputPath Output path of the encryption (null = replace file) + * + * @return void + * + * @since 1.0.0 + */ + public function encrypt(string $password, string $outputPath = null) : void { // todo: implement; } + /** + * Decrypt the media file + * + * @param string $password Password to encrypt the file with + * @param null|string $outputPath Output path of the encryption (null = replace file) + * + * @return void + * + * @since 1.0.0 + */ public function decrypt(string $password, string $outputPath) : string { // todo: implement; diff --git a/Models/UploadFile.php b/Models/UploadFile.php index f4b417c..749775f 100644 --- a/Models/UploadFile.php +++ b/Models/UploadFile.php @@ -179,6 +179,7 @@ class UploadFile return $result; } + /* if ($this->isInterlaced && \in_array($extension, FileUtils::IMAGE_EXTENSION)) { // todo: interlacing somehow messes up some images (tested with logo.png from assets) //$this->interlace($extension, $dest); @@ -187,7 +188,7 @@ class UploadFile if ($encoding !== '') { // changing encoding bugs out image files //FileUtils::changeFileEncoding($dest, $encoding); - } + }*/ $result[$key]['path'] = \realpath($this->outputDir); } diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index e642abb..14b3dd8 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -1,4 +1,4 @@ - [ 'Create' => 'Create', 'List' => 'List', diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php index 9956082..34aac3a 100644 --- a/Theme/Backend/Lang/api.en.lang.php +++ b/Theme/Backend/Lang/api.en.lang.php @@ -1,4 +1,4 @@ - 'Installation of the module {$1} was successful.', ]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 3d53b37..1b4a34b 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -1,4 +1,4 @@ - [ 'Account' => 'Account', 'Author' => 'Author', diff --git a/Theme/Backend/media-create.tpl.php b/Theme/Backend/media-create.tpl.php index a44e059..85351da 100644 --- a/Theme/Backend/media-create.tpl.php +++ b/Theme/Backend/media-create.tpl.php @@ -1,4 +1,4 @@ -getPath() . $sub) @@ -46,6 +56,16 @@ class MediaView extends View return $media->getPath(); } + /** + * Get directory path + * + * @param Media $media Media file + * @param string $sub Sub path + * + * @return string + * + * @since 1.0.0 + */ protected function dirPathFunction(Media $media, string $sub) : string { if (\is_dir($media->getPath() . $sub) @@ -60,6 +80,16 @@ class MediaView extends View return $media->getPath(); } + /** + * Check if media file is a collection + * + * @param Media $media Media file + * @param string $sub Sub path + * + * @return bool + * + * @since 1.0.0 + */ protected function isCollectionFunction(Media $media, string $sub) : bool { return ($media->getExtension() === 'collection' @@ -69,6 +99,15 @@ class MediaView extends View ); } + /** + * Get file content + * + * @param string $path File path + * + * @return string + * + * @since 1.0.0 + */ protected function getFileContent(string $path) : string { $output = \file_get_contents($path); @@ -77,6 +116,15 @@ class MediaView extends View return $output; } + /** + * Get file content + * + * @param string $path File path + * + * @return array + * + * @since 1.0.0 + */ protected function lineContentFunction(string $path) : array { $output = \file_get_contents($path); @@ -85,12 +133,32 @@ class MediaView extends View return \explode("\n", $output); } + /** + * Check if media file is image file + * + * @param Media $media Media file + * @param string $path File path + * + * @return bool + * + * @since 1.0.0 + */ protected function isImageFile(Media $media, string $path) : bool { return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE || FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE; } + /** + * Check if media file is text file + * + * @param Media $media Media file + * @param string $path File path + * + * @return bool + * + * @since 1.0.0 + */ protected function isTextFile(Media $media, string $path) : bool { $mediaExtension = FileUtils::getExtensionType($media->getExtension());