From e94cf2bb67f6dd71153bbec4d4cf613ec9229816 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 21 Jun 2019 02:12:21 +0300 Subject: [PATCH] Admin Panel: Tools #170 #165 - next round of implementation --- .../admin/app/Controllers/ToolsController.php | 83 ++++++++++++++++++- site/plugins/admin/routes/web.php | 2 + .../views/templates/system/tools/cache.html | 5 ++ .../views/templates/system/tools/index.html | 5 ++ .../templates/system/tools/information.html | 39 +++++++++ 5 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 site/plugins/admin/views/templates/system/tools/cache.html create mode 100644 site/plugins/admin/views/templates/system/tools/index.html create mode 100644 site/plugins/admin/views/templates/system/tools/information.html diff --git a/site/plugins/admin/app/Controllers/ToolsController.php b/site/plugins/admin/app/Controllers/ToolsController.php index 3a28afaa..6e3cfb16 100644 --- a/site/plugins/admin/app/Controllers/ToolsController.php +++ b/site/plugins/admin/app/Controllers/ToolsController.php @@ -2,6 +2,7 @@ namespace Flextype; +use function Flextype\Component\I18n\__; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; @@ -19,8 +20,86 @@ class ToolsController extends Controller * * @return Response */ - public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response + public function index(Request $request, Response $response) : Response { - return 'tools'; + return $response->withRedirect($this->router->pathFor('admin.tools.information')); + } + + /** + * Information page + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response + */ + public function information(Request $request, Response $response) : Response + { + + if (function_exists('apache_get_modules')) { + if (!in_array('mod_rewrite', apache_get_modules())) { + $apache_mod_rewrite_installed = false; + } else { + $apache_mod_rewrite_installed = true; + } + } else { + $apache_mod_rewrite_installed = true; + } + + return $this->view->render( + $response, + 'plugins/admin/views/templates/system/tools/information.html', + [ + 'menu_item' => 'tools', + 'php_uname' => php_uname(), + 'webserver' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : @getenv('SERVER_SOFTWARE'), + 'php_sapi_name' => php_sapi_name(), + 'apache_mod_rewrite_installed' => $apache_mod_rewrite_installed, + 'links' => [ + 'information' => [ + 'link' => $this->router->pathFor('admin.tools.index'), + 'title' => __('admin_information'), + 'attributes' => ['class' => 'navbar-item active'] + ], + 'cache' => [ + 'link' => $this->router->pathFor('admin.tools.cache'), + 'title' => __('admin_cache'), + 'attributes' => ['class' => 'navbar-item'] + ], + ] + ] + ); + } + + /** + * Cache page + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response + */ + public function cache(Request $request, Response $response) : Response + { + + return $this->view->render( + $response, + 'plugins/admin/views/templates/system/tools/cache.html', + [ + 'menu_item' => 'tools', + 'links' => [ + 'information' => [ + 'link' => $this->router->pathFor('admin.tools.index'), + 'title' => __('admin_information'), + 'attributes' => ['class' => 'navbar-item'] + ], + 'cache' => [ + 'link' => $this->router->pathFor('admin.tools.cache'), + 'title' => __('admin_cache'), + 'attributes' => ['class' => 'navbar-item active'] + ], + ] + ] + ); } } diff --git a/site/plugins/admin/routes/web.php b/site/plugins/admin/routes/web.php index 3439ed86..1b7ac07a 100644 --- a/site/plugins/admin/routes/web.php +++ b/site/plugins/admin/routes/web.php @@ -83,5 +83,7 @@ $app->group('/' . $admin_route, function () use ($flextype, $app) { // ToolsController $app->get('/tools', 'ToolsController:index')->setName('admin.tools.index'); + $app->get('/tools/information', 'ToolsController:information')->setName('admin.tools.information'); + $app->get('/tools/cache', 'ToolsController:cache')->setName('admin.tools.cache'); })->add(new AuthMiddleware($flextype)); diff --git a/site/plugins/admin/views/templates/system/tools/cache.html b/site/plugins/admin/views/templates/system/tools/cache.html new file mode 100644 index 00000000..86466986 --- /dev/null +++ b/site/plugins/admin/views/templates/system/tools/cache.html @@ -0,0 +1,5 @@ +{% extends "plugins/admin/views/partials/base.html" %} + +{% block content %} +ad +{% endblock %} diff --git a/site/plugins/admin/views/templates/system/tools/index.html b/site/plugins/admin/views/templates/system/tools/index.html new file mode 100644 index 00000000..1c4f3966 --- /dev/null +++ b/site/plugins/admin/views/templates/system/tools/index.html @@ -0,0 +1,5 @@ +{% extends "plugins/admin/views/partials/base.html" %} + +{% block content %} + +{% endblock %} diff --git a/site/plugins/admin/views/templates/system/tools/information.html b/site/plugins/admin/views/templates/system/tools/information.html new file mode 100644 index 00000000..eddda69d --- /dev/null +++ b/site/plugins/admin/views/templates/system/tools/information.html @@ -0,0 +1,39 @@ +{% extends "plugins/admin/views/partials/base.html" %} + +{% block content %} +
+
+ {{ tr('admin_flextype_version') }}: {{ FLEXTYPE_VERSION }} +
+
+ +
+ +

{{ tr('admin_server') }}

+ + + + + + + + + + + + + + + + + + + + {% if apache_mod_rewrite_installed %} + + {% else %} + + {% endif %} + +
{{ tr('admin_php_version') }}
{{ tr('admin_php_built_on') }}{{ php_uname }}
{{ tr('admin_web_server') }}{{ webserver }}
{{ tr('admin_web_server_php_interface') }}{{ php_sapi_name }}
Apache Mod Rewrite{{ tr('admin_installed') }}
Apache Mod Rewrite{{ tr('admin_not_installed') }}
+{% endblock %}