From f8a672a0c1636d51620d64a04268df051b036c9e Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 23 Jun 2019 13:03:24 +0300 Subject: [PATCH] Admin Panel: Themes #171 #165 - next round of implementation. --- .../app/Controllers/TemplatesController.php | 23 ++++--- .../app/Controllers/ThemesController.php | 61 +++++++++++++++++++ 2 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 site/plugins/admin/app/Controllers/ThemesController.php diff --git a/site/plugins/admin/app/Controllers/TemplatesController.php b/site/plugins/admin/app/Controllers/TemplatesController.php index 800ee67a..8e6f5850 100644 --- a/site/plugins/admin/app/Controllers/TemplatesController.php +++ b/site/plugins/admin/app/Controllers/TemplatesController.php @@ -27,14 +27,23 @@ class TemplatesController extends Controller */ public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response { + + $theme = $request->getQueryParams()['theme']; + return $this->view->render( $response, - 'plugins/admin/views/templates/extends/templates/index.html', + 'plugins/admin/views/templates/extends/themes/templates/index.html', [ - 'menu_item' => 'templates', - 'templates_list' => $this->themes->getTemplates(), - 'partials_list' => $this->themes->getPartials(), + 'menu_item' => 'themes', + 'theme' => $theme, + 'templates_list' => $this->themes->getTemplates($theme), + 'partials_list' => $this->themes->getPartials($theme), 'links' => [ + 'themes' => [ + 'link' => $this->router->pathFor('admin.themes.index'), + 'title' => __('admin_themes'), + 'attributes' => ['class' => 'navbar-item'] + ], 'templates' => [ 'link' => $this->router->pathFor('admin.templates.index'), 'title' => __('admin_templates'), @@ -64,7 +73,7 @@ class TemplatesController extends Controller { return $this->view->render( $response, - 'plugins/admin/views/templates/extends/templates/add.html', + 'plugins/admin/views/templates/extends/themes/templates/add.html', [ 'menu_item' => 'templates', 'links' => [ @@ -129,7 +138,7 @@ class TemplatesController extends Controller return $this->view->render( $response, - 'plugins/admin/views/templates/extends/templates/edit.html', + 'plugins/admin/views/templates/extends/themes/templates/edit.html', [ 'menu_item' => 'templates', 'id' => $request->getQueryParams()['id'], @@ -192,7 +201,7 @@ class TemplatesController extends Controller { return $this->view->render( $response, - 'plugins/admin/views/templates/extends/templates/rename.html', + 'plugins/admin/views/templates/extends/themes/templates/rename.html', [ 'menu_item' => 'templates', 'types' => ['partial' => __('admin_partial'), 'template' => __('admin_template')], diff --git a/site/plugins/admin/app/Controllers/ThemesController.php b/site/plugins/admin/app/Controllers/ThemesController.php new file mode 100644 index 00000000..4856e25e --- /dev/null +++ b/site/plugins/admin/app/Controllers/ThemesController.php @@ -0,0 +1,61 @@ +view->render( + $response, + 'plugins/admin/views/templates/extends/themes/index.html', + [ + 'menu_item' => 'themes', + 'themes_list' => $themes, + 'links' => [ + 'themes' => [ + 'link' => $this->router->pathFor('admin.themes.index'), + 'title' => __('admin_themes'), + 'attributes' => ['class' => 'navbar-item active'] + ], + ], + 'buttons' => [ + 'templates_create' => [ + 'link' => $this->router->pathFor('admin.templates.add'), + 'title' => __('admin_create_new_template'), + 'attributes' => ['class' => 'float-right btn'] + ], + ] + ] + ); + } +}