From b275724809b968727270683586ebebcb1192af8f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 17 Apr 2024 17:45:07 +0000 Subject: [PATCH] fix templates --- Controller/BackendController.php | 87 ++++++++++-------------- Theme/Backend/wiki-app-create.tpl.php | 18 ----- Theme/Backend/wiki-app-list.tpl.php | 33 +++++++++ Theme/Backend/wiki-app-view.tpl.php | 34 ++++++++- Theme/Backend/wiki-category-list.tpl.php | 4 +- 5 files changed, 105 insertions(+), 71 deletions(-) delete mode 100755 Theme/Backend/wiki-app-create.tpl.php diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 8baae1c..b552c00 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -85,18 +85,14 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-dashboard'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiCategory[] $categories */ - $categories = WikiCategoryMapper::getAll() + $view->data['categories'] = WikiCategoryMapper::getAll() ->with('name') ->where('parent', null) ->where('app', $app) ->where('name/language', $response->header->l11n->language) ->executeGetArray(); - $view->data['categories'] = $categories; - - /** @var \Modules\Knowledgebase\Models\WikiDoc[] $documents */ - $documents = WikiDocMapper::getAll() + $view->data['docs'] = WikiDocMapper::getAll() ->with('tags') ->with('tags/title') ->where('app', $app) @@ -106,11 +102,9 @@ final class BackendController extends Controller ->sort('createdAt', OrderType::DESC) ->executeGetArray(); - $view->data['docs'] = $documents; - - /** @var \Modules\Knowledgebase\Models\WikiApp[] $apps */ - $apps = WikiAppMapper::getAll()->executeGetArray(); - $view->data['apps'] = $apps; + $view->data['apps'] = WikiAppMapper::getAll() + ->where('unit', [$this->app->unitId, null]) + ->executeGetArray(); return $view; } @@ -134,9 +128,9 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-app-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiApp[] $list */ - $list = WikiAppMapper::getAll()->executeGetArray(); - $view->data['apps'] = $list; + $view->data['apps'] = WikiAppMapper::getAll() + ->where('unit', [$this->app->unitId, null]) + ->executeGetArray(); return $view; } @@ -160,9 +154,9 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-app-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiApp $app */ - $app = WikiAppMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $view->data['app'] = $app; + $view->data['app'] = WikiAppMapper::get() + ->where('id', (int) $request->getData('id')) + ->execute(); return $view; } @@ -185,8 +179,6 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-app-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - $view->data['app'] = new NullWikiApp(); - return $view; } @@ -209,17 +201,14 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-category-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiCategory[] $list */ - $list = WikiCategoryMapper::getAll() + $view->data['categories'] = WikiCategoryMapper::getAll() ->with('name') ->where('name/language', $response->header->l11n->language) ->executeGetArray(); - $view->data['categories'] = $list; - - /** @var \Modules\Knowledgebase\Models\WikiApp[] $apps */ - $apps = WikiAppMapper::getAll()->executeGetArray(); - $view->data['apps'] = $apps; + $view->data['apps'] = WikiAppMapper::getAll() + ->where('unit', [$this->app->unitId, null]) + ->executeGetArray(); return $view; } @@ -243,30 +232,29 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-category-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiCategory $category */ - $category = WikiCategoryMapper::get() + $view->data['category'] = WikiCategoryMapper::get() ->with('name') ->where('id', (int) $request->getData('id')) ->where('name/language', $response->header->l11n->language) ->execute(); - $view->data['category'] = $category; - $view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response); - /** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */ - $l11nValues = WikiCategoryL11nMapper::getAll() - ->where('ref', $category->id) + $view->data['l11nValues'] = WikiCategoryL11nMapper::getAll() + ->where('ref', $view->data['category']->id) ->executeGetArray(); - $view->data['l11nValues'] = $l11nValues; - $view->data['apps'] = WikiAppMapper::getAll() ->where('unit', [$this->app->unitId, null]) ->executeGetArray(); - $appIds = \array_map(function (WikiApp $app) { return $app->id; - }, $view->data['apps']); + $appIds = \array_map( + function (WikiApp $app) { + return $app->id; + }, + $view->data['apps'] + ); + $appIds = \array_unique($appIds); $view->data['parents'] = WikiCategoryMapper::getAll() @@ -302,8 +290,13 @@ final class BackendController extends Controller ->where('unit', [$this->app->unitId, null]) ->executeGetArray(); - $appIds = \array_map(function (WikiApp $app) { return $app->id; - }, $view->data['apps']); + $appIds = \array_map( + function (WikiApp $app) { + return $app->id; + }, + $view->data['apps'] + ); + $appIds = \array_unique($appIds); $view->data['parents'] = WikiCategoryMapper::getAll() @@ -337,22 +330,18 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Knowledgebase/Theme/Backend/wiki-doc-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005901001, $request, $response); - /** @var \Modules\Knowledgebase\Models\WikiCategory[] $categories */ - $categories = WikiCategoryMapper::getAll() + $view->data['categories'] = WikiCategoryMapper::getAll() ->with('name') ->where('app', $wikiId) ->where('parent', $categoryId === 0 ? null : $categoryId) ->where('name/language', $response->header->l11n->language) ->executeGetArray(); - $view->data['categories'] = $categories; - $view->data['category'] = WikiCategoryMapper::get() ->where('id', $categoryId === 0 ? null : $categoryId) ->execute(); - /** @var \Modules\Knowledgebase\Models\WikiDoc[] $documents */ - $documents = WikiDocMapper::getAll() + $view->data['docs'] = WikiDocMapper::getAll() ->with('tags') ->with('tags/title') ->where('app', $wikiId) @@ -362,11 +351,9 @@ final class BackendController extends Controller ->sort('createdAt', OrderType::DESC) ->executeGetArray(); - $view->data['docs'] = $documents; - - /** @var \Modules\Knowledgebase\Models\WikiApp[] $apps */ - $apps = WikiAppMapper::getAll()->executeGetArray(); - $view->data['apps'] = $apps; + $view->data['apps'] = WikiAppMapper::getAll() + ->where('unit', [$this->app->unitId, null]) + ->executeGetArray(); return $view; } diff --git a/Theme/Backend/wiki-app-create.tpl.php b/Theme/Backend/wiki-app-create.tpl.php deleted file mode 100755 index f9c09eb..0000000 --- a/Theme/Backend/wiki-app-create.tpl.php +++ /dev/null @@ -1,18 +0,0 @@ -data['app']; - -/** @var \phpOMS\Views\View $this */ -echo $this->data['nav']->render(); diff --git a/Theme/Backend/wiki-app-list.tpl.php b/Theme/Backend/wiki-app-list.tpl.php index f25e0f2..56821f9 100755 --- a/Theme/Backend/wiki-app-list.tpl.php +++ b/Theme/Backend/wiki-app-list.tpl.php @@ -12,7 +12,40 @@ */ declare(strict_types=1); +use phpOMS\Uri\UriFactory; + $apps = $this->data['apps']; /** @var \phpOMS\Views\View $this */ echo $this->data['nav']->render(); +?> +
+
+
+
+ getHtml('Apps'); ?> + download + getHtml('New', '0', '0'); ?> +
+
+ + + + + $value) : ++$c; + $url = \phpOMS\Uri\UriFactory::build('{/base}/wiki/app/view?{?}&id=' . $value->id); ?> + +
getHtml('ID', '0', '0'); ?> + getHtml('Title'); ?> +
id; ?> + printHtml($value->name); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+
diff --git a/Theme/Backend/wiki-app-view.tpl.php b/Theme/Backend/wiki-app-view.tpl.php index f9c09eb..2d09a56 100644 --- a/Theme/Backend/wiki-app-view.tpl.php +++ b/Theme/Backend/wiki-app-view.tpl.php @@ -12,7 +12,39 @@ */ declare(strict_types=1); -$app = $this->data['app']; +use Modules\Knowledgebase\Models\NullWikiApp; +use phpOMS\Uri\UriFactory; + +$app = $this->data['app'] ?? new NullWikiApp(); +$isNew = $app->id === 0; /** @var \phpOMS\Views\View $this */ echo $this->data['nav']->render(); +?> +
+
+
+
+
getHtml('App'); ?>
+
+
+ + +
+ +
+ + +
+
+
+ + + + + +
+
+
+
+
diff --git a/Theme/Backend/wiki-category-list.tpl.php b/Theme/Backend/wiki-category-list.tpl.php index 25a1c44..cb273ce 100755 --- a/Theme/Backend/wiki-category-list.tpl.php +++ b/Theme/Backend/wiki-category-list.tpl.php @@ -29,7 +29,7 @@ echo $this->data['nav']->render();
-
+
getHtml('Categories'); ?> download @@ -56,6 +56,6 @@ echo $this->data['nav']->render();
-
+
\ No newline at end of file