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 @@