diff --git a/cp/app/Controllers/HomeController.php b/cp/app/Controllers/HomeController.php index 8f49032..a26c938 100644 --- a/cp/app/Controllers/HomeController.php +++ b/cp/app/Controllers/HomeController.php @@ -222,4 +222,15 @@ class HomeController extends Controller } return $response->withHeader('Location', '/dashboard')->withStatus(302); } + + public function selectTheme(Request $request, Response $response) + { + global $container; + + $data = $request->getParsedBody(); + $_SESSION['_theme'] = ($v = substr(trim(preg_replace('/[^\x20-\x7E]/', '', $data['theme-primary'] ?? '')), 0, 30)) !== '' ? $v : 'blue'; + + $container->get('flash')->addMessage('success', 'Theme color has been set successfully'); + return $response->withHeader('Location', '/profile')->withStatus(302); + } } \ No newline at end of file diff --git a/cp/bootstrap/app.php b/cp/bootstrap/app.php index dd029ce..17ae2d6 100644 --- a/cp/bootstrap/app.php +++ b/cp/bootstrap/app.php @@ -155,6 +155,11 @@ $container->set('view', function ($container) { } else { $view->getEnvironment()->addGlobal('screen_mode', 'light'); } + if (isset($_SESSION['_theme'])) { + $view->getEnvironment()->addGlobal('theme', $_SESSION['_theme']); + } else { + $view->getEnvironment()->addGlobal('theme', 'blue'); + } if (envi('MINIMUM_DATA') === 'true') { $view->getEnvironment()->addGlobal('minimum_data', 'true'); } else { diff --git a/cp/resources/views/admin/profile/profile.twig b/cp/resources/views/admin/profile/profile.twig index da1f7f3..eeb685b 100644 --- a/cp/resources/views/admin/profile/profile.twig +++ b/cp/resources/views/admin/profile/profile.twig @@ -49,56 +49,145 @@
-

{{ __('Details') }}

-
- {{ csrf.field | raw }} -
-
-
{{ __('User Name') }}
-
{{ username }}
-
-
-
{{ __('Email') }}
-
{{ email }}
-
-
-
{{ __('Status') }}
-
- - {{ status }} - -
-
-
-
{{ __('Role') }}
-
- - {{ role }} - -
+

{{ __('Details') }}

+
+
+
{{ __('User Name') }}
+
{{ username }}
+
+
+
{{ __('Email') }}
+
{{ email }}
+
+
+
{{ __('Status') }}
+
+ + {{ status }} +
-

{{ __('Change Password') }}

-
-
-
{{ __('Old Password') }}
- - {% if errors.old_password %} - {{ errors.old_password | first }} - {% endif %} -
-
-
{{ __('New Password') }}
- - {% if errors.new_password %} - {{ errors.new_password | first }} - {% endif %} +
+
{{ __('Role') }}
+
+ + {{ role }} +
- - +
+
+
+
+ {{ csrf.field | raw }} +

{{ __('Change Password') }}

+
+
+
{{ __('Old Password') }}
+ + {% if errors.old_password %} + {{ errors.old_password | first }} + {% endif %} +
+
+
{{ __('New Password') }}
+ + {% if errors.new_password %} + {{ errors.new_password | first }} + {% endif %} +
+
+ +
+
+
+
+ {{ csrf.field | raw }} +

{{ __('Select Theme') }}

+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
{% if secret is defined %} diff --git a/cp/resources/views/layouts/app.twig b/cp/resources/views/layouts/app.twig index c51f26f..278e1b0 100644 --- a/cp/resources/views/layouts/app.twig +++ b/cp/resources/views/layouts/app.twig @@ -1,5 +1,5 @@ - + diff --git a/cp/routes/web.php b/cp/routes/web.php index 285ace6..60b7848 100644 --- a/cp/routes/web.php +++ b/cp/routes/web.php @@ -173,6 +173,7 @@ $app->group('', function ($route) { $route->post('/token-well', ProfileController::class .':tokenWell')->setName('tokenWell'); $route->get('/mode', HomeController::class .':mode')->setName('mode'); + $route->post('/theme', HomeController::class . ':selectTheme')->setName('select.theme'); $route->get('/lang', HomeController::class .':lang')->setName('lang'); $route->get('/logout', AuthController::class . ':logout')->setName('logout'); $route->post('/change-password', PasswordController::class . ':changePassword')->setName('change.password');