diff --git a/Controller/ApiController.php b/Controller/ApiController.php index e47d25f..6030957 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -188,12 +188,16 @@ final class ApiController extends Controller ReferenceMapper::create()->execute($ref); if ($collection === null) { - $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( - '/Modules/Media/Files', - $accountPath, - $request->header->account, - __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/News/' . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') . '/' . $news->getId() - ); + $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); + + if ($collection instanceof NullMedia) { + $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( + '/Modules/Media/Files', + $accountPath, + $request->header->account, + __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/News/' . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') . '/' . $news->getId() + ); + } } CollectionMapper::writer()->createRelationTable('sources', [$ref->getId()], $collection->getId()); @@ -214,12 +218,16 @@ final class ApiController extends Controller ReferenceMapper::create()->execute($ref); if ($collection === null) { - $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( - '/Modules/Media/Files', - $path, - $request->header->account, - __DIR__ . '/../../../Modules/Media/Files' . $path - ); + $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); + + if ($collection instanceof NullMedia) { + $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( + '/Modules/Media/Files', + $path, + $request->header->account, + __DIR__ . '/../../../Modules/Media/Files' . $path + ); + } } CollectionMapper::writer()->createRelationTable('sources', [$ref->getId()], $collection->getId()); diff --git a/Theme/Backend/news-dashboard.tpl.php b/Theme/Backend/news-dashboard.tpl.php index 341373d..fe9bb5d 100755 --- a/Theme/Backend/news-dashboard.tpl.php +++ b/Theme/Backend/news-dashboard.tpl.php @@ -35,7 +35,7 @@ echo $this->getData('nav')->render(); ?> getId(), $seen)) ? '' : ''; ?> printHtml($news->title); ?> - printHtml($news->createdBy->name3 . ' ' . $news->createdBy->name2 . ' ' . $news->createdBy->name1); ?> + printHtml($this->renderUserName('%3$s %2$s %1$s', [$news->createdBy->name1, $news->createdBy->name2, $news->createdBy->name3, $news->createdBy->login ?? ''])); ?> - publish->format('Y-m-d'); ?> ' : ''; ?> diff --git a/Theme/Backend/news-single.tpl.php b/Theme/Backend/news-single.tpl.php index 3422970..71aa65f 100755 --- a/Theme/Backend/news-single.tpl.php +++ b/Theme/Backend/news-single.tpl.php @@ -32,7 +32,7 @@ echo $this->getData('nav')->render(); ?>