From f06eaa78fcb977d6f832441308da132e9a638084 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 12 Feb 2021 18:01:52 +0100 Subject: [PATCH] impl. more static translations --- Admin/Installer.php | 29 +++++++++++++------ Theme/Api/wordAsHtml.tpl.php | 6 ++-- .../Components/Media/spreadsheet.tpl.php | 9 +++--- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 4ba9006..1c07552 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -43,19 +43,19 @@ final class Installer extends InstallerAbstract * @param DatabasePool $dbPool Database pool * @param array $data Module info * - * @return void + * @return array * * @throws PathException This exception is thrown if the Navigation install file couldn't be found * @throws \Exception This exception is thrown if the Navigation install file is invalid json * * @since 1.0.0 */ - public static function installExternal(DatabasePool $dbPool, array $data) : void + public static function installExternal(DatabasePool $dbPool, array $data) : array { try { $dbPool->get()->con->query('select 1 from `media`'); } catch (\Exception $e) { - return; // @codeCoverageIgnore + return []; // @codeCoverageIgnore } if (!\is_file($data['path'] ?? '')) { @@ -76,18 +76,26 @@ final class Installer extends InstallerAbstract Directory::delete(__DIR__ . '/tmp'); } + $result = [ + 'collection' => [], + 'upload' => [], + ]; + \mkdir(__DIR__ . '/tmp'); foreach ($mediaData as $media) { switch ($media['type']) { case 'collection': - self::createCollection($dbPool, $media); + $result['collection'][] = self::createCollection($dbPool, $media); break; case 'upload': - self::uploadMedia($dbPool, $media); + $result['upload'][] = self::uploadMedia($dbPool, $media); break; + default: } } Directory::delete(__DIR__ . '/tmp'); + + return $result; } /** @@ -96,11 +104,11 @@ final class Installer extends InstallerAbstract * @param DatabasePool $dbPool Database instance * @param array $data Media info * - * @return void + * @return Collection * * @since 1.0.0 */ - private static function createCollection($dbPool, $data) : void + private static function createCollection($dbPool, $data) : Collection { $collection = new Collection(); $collection->name = (string) $data['name'] ?? ''; @@ -117,11 +125,11 @@ final class Installer extends InstallerAbstract * @param DatabasePool $dbPool Database instance * @param array $data Media info * - * @return void + * @return array * * @since 1.0.0 */ - private static function uploadMedia($dbPool, $data) : void + private static function uploadMedia($dbPool, $data) : array { $files = []; foreach ($data['files'] as $file) { @@ -189,6 +197,9 @@ final class Installer extends InstallerAbstract $collection->setSources($mediaFiles); CollectionMapper::create($collection); + return [$collection]; } + + return $mediaFiles; } } diff --git a/Theme/Api/wordAsHtml.tpl.php b/Theme/Api/wordAsHtml.tpl.php index c5f2bc1..bdb5c86 100644 --- a/Theme/Api/wordAsHtml.tpl.php +++ b/Theme/Api/wordAsHtml.tpl.php @@ -1,12 +1,12 @@ getData('media'); $reader = IOFactory::createReader('Word2007'); diff --git a/Theme/Backend/Components/Media/spreadsheet.tpl.php b/Theme/Backend/Components/Media/spreadsheet.tpl.php index e049ffd..5ab559c 100644 --- a/Theme/Backend/Components/Media/spreadsheet.tpl.php +++ b/Theme/Backend/Components/Media/spreadsheet.tpl.php @@ -1,13 +1,12 @@