1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-24 13:52:56 +02:00

Admin Panel: Themes #171 #165

- next round of implementation.
This commit is contained in:
Awilum
2019-06-23 13:03:24 +03:00
parent 93b541c4fa
commit f8a672a0c1
2 changed files with 77 additions and 7 deletions

View File

@@ -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')],

View File

@@ -0,0 +1,61 @@
<?php
namespace Flextype;
use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Text\Text;
use function Flextype\Component\I18n\__;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* @property View $view
* @property Router $router
* @property Cache $cache
* @property Themes $themes
* @property Slugify $slugify
*/
class ThemesController extends Controller
{
/**
* Index page
*
* @param Request $request PSR7 request
* @param Response $response PSR7 response
*
* @return Response
*/
public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response
{
$themes = [];
foreach (Filesystem::listContents(PATH['themes']) as $theme) {
if ($theme['type'] == 'dir' && Filesystem::has($theme['path'] . '/' . 'theme.json')) {
$themes[$theme['dirname']] = $theme['dirname'];
}
}
return $this->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']
],
]
]
);
}
}