diff --git a/Admin/Settings/Theme/Backend/settings.tpl.php b/Admin/Settings/Theme/Backend/settings.tpl.php index e53396e..ad1769d 100755 --- a/Admin/Settings/Theme/Backend/settings.tpl.php +++ b/Admin/Settings/Theme/Backend/settings.tpl.php @@ -18,9 +18,9 @@ use phpOMS\Uri\UriFactory; * @var \phpOMS\Views\View $this * @var \Modules\Media\Models\MediaType[] $types */ -$types = $this->getData('types') ?? []; +$types = $this->data['types'] ?? []; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 1f854d6..a2d85ff 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -85,7 +85,7 @@ final class ApiController extends Controller $uploads = $this->uploadFiles( names: $request->getDataList('names'), fileNames: $request->getDataList('filenames'), - files: $request->getFiles(), + files: $request->files, account: $request->header->account, basePath: __DIR__ . '/../../../Modules/Media/Files' . \urldecode($request->getDataString('path') ?? ''), virtualPath: \urldecode($request->getDataString('virtualpath') ?? ''), @@ -633,7 +633,7 @@ final class ApiController extends Controller public function apiReferenceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateReferenceCreate($request))) { - $response->set('collection_create', new FormValidation($val)); + $response->data['collection_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -770,7 +770,7 @@ final class ApiController extends Controller public function apiCollectionCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateCollectionCreate($request))) { - $response->set('collection_create', new FormValidation($val)); + $response->data['collection_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1132,7 +1132,7 @@ final class ApiController extends Controller $this->setMediaResponseHeader($media, $request, $response); $view = $this->createView($media, $request, $response); - $view->setData('path', __DIR__ . '/../../../'); + $view->data['path'] = __DIR__ . '/../../../'; $response->set('export', $view); } @@ -1183,7 +1183,7 @@ final class ApiController extends Controller public function createView(Media $media, RequestAbstract $request, ResponseAbstract $response) : View { $view = new View($this->app->l11nManager, $request, $response); - $view->setData('media', $media); + $view->data['media'] = $media; if (!\headers_sent()) { $response->endAllOutputBuffering(); // for large files @@ -1202,7 +1202,7 @@ final class ApiController extends Controller $head->setStyle('core', $css ?? ''); $head->addAsset(AssetType::CSS, 'cssOMS/styles.css?v=1.0.0'); - $view->setData('head', $head); + $view->data['head'] = $head; switch (\strtolower($media->extension)) { case 'xls': @@ -1341,7 +1341,7 @@ final class ApiController extends Controller public function apiMediaTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateMediaTypeCreate($request))) { - $response->set('media_type_create', new FormValidation($val)); + $response->data['media_type_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1370,7 +1370,7 @@ final class ApiController extends Controller if ($request->hasData('title')) { $type->setL11n( $request->getDataString('title') ?? '', - $request->getDataString('lang') ?? $request->getLanguage() + $request->getDataString('lang') ?? $request->header->l11n->language ); } @@ -1414,7 +1414,7 @@ final class ApiController extends Controller public function apiMediaTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateMediaTypeL11nCreate($request))) { - $response->set('media_type_l11n_create', new FormValidation($val)); + $response->data['media_type_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1441,7 +1441,7 @@ final class ApiController extends Controller $l11nMediaType->ref = $request->getDataInt('type') ?? 0; $l11nMediaType->content = $request->getDataString('title') ?? ''; $l11nMediaType->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); return $l11nMediaType; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 564eb57..5eaa5bf 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -85,7 +85,7 @@ final class BackendController extends Controller PermissionCategory::MEDIA, ); - $mediaMapper = MediaMapper::getByVirtualPath($path)->where('tags/title/language', $request->getLanguage()); + $mediaMapper = MediaMapper::getByVirtualPath($path)->where('tags/title/language', $request->header->l11n->language); if (!$hasPermission) { $permWhere = PermissionAbstractMapper::helper($this->app->dbPool->get('select')) @@ -104,7 +104,7 @@ final class BackendController extends Controller /** @var Media[] $media */ $media = $mediaMapper->execute(); - $collectionMapper = CollectionMapper::getParentCollection($path)->where('tags/title/language', $request->getLanguage()); + $collectionMapper = CollectionMapper::getParentCollection($path)->where('tags/title/language', $request->header->l11n->language); if (!$hasPermission) { $permWhere = PermissionAbstractMapper::helper($this->app->dbPool->get('select')) @@ -183,9 +183,9 @@ final class BackendController extends Controller $media = \array_merge($media, $unIndexedFiles); } - $view->addData('media', $media); - $view->addData('path', $path); - $view->addData('account', $this->app->accountManager->get($request->header->account)); + $view->data['media'] = $media; + $view->data['path'] = $path; + $view->data['account'] = $this->app->accountManager->get($request->header->account); return $view; } @@ -206,7 +206,7 @@ final class BackendController extends Controller { $view = new MediaView($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Media/Theme/Backend/media-single'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000401001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000401001, $request, $response); $id = $request->getDataInt('id'); if ($id === 0) { @@ -222,7 +222,7 @@ final class BackendController extends Controller $media->setPath('/Modules/Media/Files/' . \ltrim($path, '\\/')); $media->isAbsolute = false; - $view->addData('view', $this->createMediaView($media, $request, $response)); + $view->data['view'] = $this->createMediaView($media, $request, $response); } } else { /** @var \Modules\Media\Models\Media $media */ @@ -232,20 +232,20 @@ final class BackendController extends Controller ->with('tags/title') ->with('content') ->where('id', $id) - ->where('tags/title/language', $request->getLanguage()) + ->where('tags/title/language', $request->header->l11n->language) ->execute(); if ($media->class === MediaClass::COLLECTION) { /** @var \Modules\Media\Models\Media[] $files */ $files = MediaMapper::getByVirtualPath( $media->getVirtualPath() . ($media->getVirtualPath() !== '/' ? '/' : '') . $media->name - )->where('tags/title/language', $request->getLanguage())->execute(); + )->where('tags/title/language', $request->header->l11n->language)->execute(); /** @var \Modules\Media\Models\Collection $collection */ $collection = CollectionMapper::get()->where('id', $id)->execute(); $media = \array_merge($files, $collection->getSources()); - $view->addData('path', $collection->getVirtualPath() . '/' . $collection->name); + $view->data['path'] = $collection->getVirtualPath() . '/' . $collection->name; $view->setTemplate('/Modules/Media/Theme/Backend/media-list'); } else { $sub = $request->getDataString('sub') ?? ''; @@ -254,7 +254,7 @@ final class BackendController extends Controller ) { $listView = new ListView($this->app->l11nManager, $request, $response); $listView->setTemplate('/modules/Media/Theme/Backend/Components/Media/list'); - $view->addData('view', $listView); + $view->data['view'] = $listView; } else { if ($media->class === MediaClass::REFERENCE) { /** @var \Modules\Media\Models\Media $media */ @@ -264,19 +264,19 @@ final class BackendController extends Controller ->with('tags/title') ->with('content') ->where('id', $media->source?->id ?? 0) - ->where('tags/title/language', $request->getLanguage()) + ->where('tags/title/language', $request->header->l11n->language) ->execute(); - $view->addData('view', $this->createMediaView($media->source, $request, $response)); + $view->data['view'] = $this->createMediaView($media->source, $request, $response); } else { - $view->addData('view', $this->createMediaView($media, $request, $response)); + $view->data['view'] = $this->createMediaView($media, $request, $response); } } } } - $view->addData('account', $this->app->accountManager->get($request->header->account)); - $view->addData('media', $media); + $view->data['account'] = $this->app->accountManager->get($request->header->account); + $view->data['media'] = $media; return $view; } @@ -391,15 +391,15 @@ final class BackendController extends Controller public function viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response); $id = $request->getDataString('id') ?? ''; $settings = SettingMapper::getAll()->where('module', $id)->execute(); - $view->setData('settings', $settings); + $view->data['settings'] = $settings; - $types = MediaTypeMapper::getAll()->with('title')->where('title/language', $response->getLanguage())->execute(); - $view->setData('types', $types); + $types = MediaTypeMapper::getAll()->with('title')->where('title/language', $response->header->l11n->language)->execute(); + $view->data['types'] = $types; $view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings'); @@ -426,15 +426,15 @@ final class BackendController extends Controller /** @var \phpOMS\Localization\BaseStringL11n $type */ $type = MediaTypeMapper::get() ->with('title') - ->where('title/language', $response->getLanguage()) + ->where('title/language', $response->header->l11n->language) ->where('id', (int) $request->getData('id')) ->execute(); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007501001, $request, $response)); - $view->addData('type', $type); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007501001, $request, $response); + $view->data['type'] = $type; $l11n = MediaTypeL11nMapper::getAll()->where('type', $type->id)->execute(); - $view->addData('l11n', $l11n); + $view->data['l11n'] = $l11n; return $view; } @@ -477,7 +477,7 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Media/Theme/Backend/media-file-create'); $editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response); - $view->addData('editor', $editor); + $view->data['editor'] = $editor; return $view; } diff --git a/Controller/FileUploaderTrait.php b/Controller/FileUploaderTrait.php index ef32c6f..d4d5afa 100644 --- a/Controller/FileUploaderTrait.php +++ b/Controller/FileUploaderTrait.php @@ -42,7 +42,7 @@ trait FileUploaderTrait */ public static function setUpFileUploaderTrait(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { - $head = $response->get('Content')->getData('head'); + $head = $response->get('Content')->head; $head->addAsset(AssetType::JS, '/Modules/Media/Controller.js', ['type' => 'module']); } } diff --git a/Models/MediaListTrait.php b/Models/MediaListTrait.php index a42b89d..35038cb 100644 --- a/Models/MediaListTrait.php +++ b/Models/MediaListTrait.php @@ -32,7 +32,7 @@ trait MediaListTrait * @var Media[] * @since 1.0.0 */ - private array $files = []; + public array $files = []; /** * Get files diff --git a/Models/MediaType.php b/Models/MediaType.php index 684828d..4db1037 100755 --- a/Models/MediaType.php +++ b/Models/MediaType.php @@ -73,18 +73,6 @@ class MediaType implements \JsonSerializable $this->setL11n($name); } - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * @return string * diff --git a/Theme/Api/spreadsheetAsCsv.tpl.php b/Theme/Api/spreadsheetAsCsv.tpl.php index 8d5c3f0..df5e17e 100755 --- a/Theme/Api/spreadsheetAsCsv.tpl.php +++ b/Theme/Api/spreadsheetAsCsv.tpl.php @@ -18,7 +18,7 @@ use phpOMS\Autoloader; Autoloader::addPath(__DIR__ . '/../../../../Resources/'); -$media = $this->getData('media'); +$media = $this->data['media']; $reader = IOFactory::createReaderforFile(($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath()); $reader->setReadDataOnly(true); diff --git a/Theme/Api/spreadsheetAsHtml.tpl.php b/Theme/Api/spreadsheetAsHtml.tpl.php index d765091..209d599 100755 --- a/Theme/Api/spreadsheetAsHtml.tpl.php +++ b/Theme/Api/spreadsheetAsHtml.tpl.php @@ -17,6 +17,6 @@ use phpOMS\Utils\Parser\Spreadsheet\SpreadsheetParser; Autoloader::addPath(__DIR__ . '/../../../../Resources/'); -$media = $this->getData('media'); +$media = $this->data['media']; echo SpreadsheetParser::parseSpreadsheet(($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath(), 'html'); diff --git a/Theme/Api/wordAsHtml.tpl.php b/Theme/Api/wordAsHtml.tpl.php index 5a43073..17d4a6b 100755 --- a/Theme/Api/wordAsHtml.tpl.php +++ b/Theme/Api/wordAsHtml.tpl.php @@ -18,7 +18,7 @@ use phpOMS\Autoloader; Autoloader::addPath(__DIR__ . '/../../../../Resources/'); -$media = $this->getData('media'); +$media = $this->data['media']; $reader = IOFactory::createReader('Word2007'); $doc = $reader->load(($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath()); diff --git a/Theme/Backend/media-list.tpl.php b/Theme/Backend/media-list.tpl.php index b37d485..73656ec 100755 --- a/Theme/Backend/media-list.tpl.php +++ b/Theme/Backend/media-list.tpl.php @@ -24,10 +24,10 @@ include __DIR__ . '/template-functions.php'; $mediaPath = \urldecode($this->getData('path') ?? '/'); /** @var \Modules\Media\Models\Media[] $media */ -$media = $this->getData('media') ?? []; +$media = $this->data['media'] ?? []; /** @var \Modules\Admin\Models\Account $account */ -$account = $this->getData('account'); +$account = $this->data['account']; $accountDir = $account->id . ' ' . $account->login; $previous = empty($media) ? '{/base}/media/list' : '{/base}/media/list?{?}&id=' . \reset($media)->id . '&ptype=p'; diff --git a/Theme/Backend/media-single.tpl.php b/Theme/Backend/media-single.tpl.php index 34f5677..3a4e5cd 100755 --- a/Theme/Backend/media-single.tpl.php +++ b/Theme/Backend/media-single.tpl.php @@ -20,21 +20,21 @@ include __DIR__ . '/template-functions.php'; /** @var \Modules\Media\Views\MediaView $this */ /** @var \Modules\Media\Models\Media $media */ -$media = $this->getData('media'); -$view = $this->getData('view'); +$media = $this->data['media']; +$view = $this->data['view']; /** @var \Modules\Tag\Models\Tag[] $tag */ $tags = $media->getTags(); /** @var \Modules\Admin\Models\Account $account */ -$account = $this->getData('account'); +$account = $this->data['account']; $accountDir = $account->id . ' ' . $account->login; $mediaPath = \urldecode($media->getVirtualPath() ?? '/'); /** @var \phpOMS\Message\Http\HttpRequest $this->request */ -echo $this->getData('nav')->render(); +echo $this->data['nav']->render(); ?>