From 781f547c96f0b24144909f86f6e119f5c8c2f69b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 10 Feb 2023 18:20:57 +0100 Subject: [PATCH] many small fixes --- Controller/ApiController.php | 83 ++++++++++++++++++++--------- Theme/Backend/Lang/api.de.lang.php | 16 ------ Theme/Backend/Lang/api.en.lang.php | 16 ------ Theme/Backend/editor-single.tpl.php | 2 +- 4 files changed, 60 insertions(+), 57 deletions(-) delete mode 100755 Theme/Backend/Lang/api.de.lang.php delete mode 100755 Theme/Backend/Lang/api.en.lang.php diff --git a/Controller/ApiController.php b/Controller/ApiController.php index c1f454c..fcdaccf 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -276,19 +276,11 @@ final class ApiController extends Controller ); $collection = null; - foreach ($uploaded as $media) { - MediaMapper::create()->execute($media); - EditorDocMapper::writer()->createRelationTable('media', [$media->getId()], $doc->getId()); - - $ref = new Reference(); - $ref->name = $media->name; - $ref->source = new NullMedia($media->getId()); - $ref->createdBy = new NullAccount($request->header->account); - - $ref->setVirtualPath($accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->getId()); - - ReferenceMapper::create()->execute($ref); + $accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login + . '/Editor/' + . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') + . '/' . $doc->getId(); if ($collection === null) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( @@ -298,23 +290,39 @@ final class ApiController extends Controller ); } - CollectionMapper::writer()->createRelationTable('sources', [$ref->getId()], $collection->getId()); + $this->createModelRelation( + $request->header->account, + $doc->getId(), + $media->getId(), + EditorDocMapper::class, + 'media', + '', + $request->getOrigin() + ); + + $ref = new Reference(); + $ref->name = $media->name; + $ref->source = new NullMedia($media->getId()); + $ref->createdBy = new NullAccount($request->header->account); + $ref->setVirtualPath($accountPath); + + $this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin()); + + $this->createModelRelation( + $request->header->account, + $collection->getId(), + $ref->getId(), + CollectionMapper::class, + 'sources', + '', + $request->getOrigin() + ); } } if (!empty($mediaFiles = $request->getDataJson('media'))) { $collection = null; - foreach ($mediaFiles as $media) { - EditorDocMapper::writer()->createRelationTable('media', [(int) $media], $doc->getId()); - - $ref = new Reference(); - $ref->source = new NullMedia((int) $media); - $ref->createdBy = new NullAccount($request->header->account); - $ref->setVirtualPath($path); - - ReferenceMapper::create()->execute($ref); - if ($collection === null) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $path, @@ -323,7 +331,34 @@ final class ApiController extends Controller ); } - CollectionMapper::writer()->createRelationTable('sources', [$ref->getId()], $collection->getId()); + $this->createModelRelation( + $request->header->account, + $doc->getId(), + (int) $media, + EditorDocMapper::class, + 'media', + '', + $request->getOrigin() + ); + + $refMedia = MediaMapper::get()->where('id', $media)->execute(); + + $ref = new Reference(); + $ref->name = $refMedia->name; + $ref->source = new NullMedia((int) $media); + $ref->createdBy = new NullAccount($request->header->account); + $ref->setVirtualPath($path); + + $this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin()); + $this->createModelRelation( + $request->header->account, + $collection->getId(), + $ref->getId(), + CollectionMapper::class, + 'sources', + '', + $request->getOrigin() + ); } } } diff --git a/Theme/Backend/Lang/api.de.lang.php b/Theme/Backend/Lang/api.de.lang.php deleted file mode 100755 index 27a4a57..0000000 --- a/Theme/Backend/Lang/api.de.lang.php +++ /dev/null @@ -1,16 +0,0 @@ - [ -]]; diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php deleted file mode 100755 index 27a4a57..0000000 --- a/Theme/Backend/Lang/api.en.lang.php +++ /dev/null @@ -1,16 +0,0 @@ - [ -]]; diff --git a/Theme/Backend/editor-single.tpl.php b/Theme/Backend/editor-single.tpl.php index 28bef40..6777c2a 100755 --- a/Theme/Backend/editor-single.tpl.php +++ b/Theme/Backend/editor-single.tpl.php @@ -40,7 +40,7 @@ echo $this->getData('nav')->render(); ?>
- icon) ? '' : ''; ?>printHtml($tag->getL11n()); ?> + icon) ? '' : ''; ?>printHtml($tag->getL11n()); ?>