From 259d3838b5fd7178cc61f0ccb423e0f04c54d941 Mon Sep 17 00:00:00 2001 From: glaszig Date: Mon, 19 Aug 2019 01:24:13 +0100 Subject: [PATCH] improved theme dropdown, selected theme detection --- includes/themes.php | 29 ++++++++++++----------------- templates/themes.php | 6 +----- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/includes/themes.php b/includes/themes.php index ffeb203f..82de4aed 100755 --- a/includes/themes.php +++ b/includes/themes.php @@ -5,22 +5,17 @@ */ function DisplayThemeConfig() { + $themes = [ + "default" => "RaspAP (default)", + "hackernews" => "HackerNews", + "terminal" => "Terminal" + ]; + $themeFiles = [ + "default" => "custom.css", + "hackernews" => "hackernews.css", + "terminal" => "terminal.css" + ]; + $selectedTheme = array_search($_COOKIE['theme'], $themeFiles); - $cselected = ''; - $hselected = ''; - $tselected = ''; - - switch ($_COOKIE['theme']) { - case "custom.css": - $cselected = ' selected="selected"'; - break; - case "hackernews.css": - $hselected = ' selected="selected"'; - break; - case "terminal.css": - $tselected = ' selected="selected"'; - break; - } - - echo renderTemplate("themes", compact("cselected", "hselected", "tselected")); + echo renderTemplate("themes", compact("themes", "selectedTheme")); } diff --git a/templates/themes.php b/templates/themes.php index ab0b090c..1a4d41a8 100644 --- a/templates/themes.php +++ b/templates/themes.php @@ -9,11 +9,7 @@
- +