From 39d7151da4bedc1b86adefd8ef485352dc733bf1 Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 22 Mar 2023 20:39:00 +0100 Subject: [PATCH] Move theme UI under System tab --- includes/locale.php | 30 ++++++++++++++++++++++++ includes/system.php | 47 ++++++++++++++++---------------------- includes/themes.php | 22 ------------------ index.php | 11 +-------- templates/system.php | 2 ++ templates/system/theme.php | 20 ++++++++++++++++ templates/themes.php | 31 ------------------------- 7 files changed, 73 insertions(+), 90 deletions(-) delete mode 100755 includes/themes.php create mode 100644 templates/system/theme.php delete mode 100755 templates/themes.php diff --git a/includes/locale.php b/includes/locale.php index 065b5364..16bbf45f 100755 --- a/includes/locale.php +++ b/includes/locale.php @@ -94,3 +94,33 @@ bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT); bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8'); textdomain(LOCALE_DOMAIN); + +function getLocales() +{ + $arrLocales = array( + 'en_GB.UTF-8' => 'English', + 'cs_CZ.UTF-8' => 'Čeština', + 'zh_TW.UTF-8' => '正體中文 (Chinese traditional)', + 'zh_CN.UTF-8' => '简体中文 (Chinese simplified)', + 'da_DK.UTF-8' => 'Dansk', + 'de_DE.UTF-8' => 'Deutsch', + 'es_MX.UTF-8' => 'Español', + 'fi_FI.UTF-8' => 'Finnish', + 'fr_FR.UTF-8' => 'Français', + 'el_GR.UTF-8' => 'Ελληνικά', + 'id_ID.UTF-8' => 'Indonesian', + 'it_IT.UTF-8' => 'Italiano', + 'ja_JP.UTF-8' => '日本語 (Japanese)', + 'ko_KR.UTF-8' => '한국어 (Korean)', + 'nl_NL.UTF-8' => 'Nederlands', + 'pl_PL.UTF-8' => 'Polskie', + 'pt_BR.UTF-8' => 'Português', + 'ru_RU.UTF-8' => 'Русский', + 'ro_RO.UTF-8' => 'Română', + 'sv_SE.UTF-8' => 'Svenska', + 'tr_TR.UTF-8' => 'Türkçe', + 'vi_VN.UTF-8' => 'Tiếng Việt (Vietnamese)' + ); + return $arrLocales; +} + diff --git a/includes/system.php b/includes/system.php index 56f5e111..774745b9 100755 --- a/includes/system.php +++ b/includes/system.php @@ -1,6 +1,7 @@ 'English', - 'cs_CZ.UTF-8' => 'Čeština', - 'zh_TW.UTF-8' => '正體中文 (Chinese traditional)', - 'zh_CN.UTF-8' => '简体中文 (Chinese simplified)', - 'da_DK.UTF-8' => 'Dansk', - 'de_DE.UTF-8' => 'Deutsch', - 'es_MX.UTF-8' => 'Español', - 'fi_FI.UTF-8' => 'Finnish', - 'fr_FR.UTF-8' => 'Français', - 'el_GR.UTF-8' => 'Ελληνικά', - 'id_ID.UTF-8' => 'Indonesian', - 'it_IT.UTF-8' => 'Italiano', - 'ja_JP.UTF-8' => '日本語 (Japanese)', - 'ko_KR.UTF-8' => '한국어 (Korean)', - 'nl_NL.UTF-8' => 'Nederlands', - 'pl_PL.UTF-8' => 'Polskie', - 'pt_BR.UTF-8' => 'Português', - 'ru_RU.UTF-8' => 'Русский', - 'ro_RO.UTF-8' => 'Română', - 'sv_SE.UTF-8' => 'Svenska', - 'tr_TR.UTF-8' => 'Türkçe', - 'vi_VN.UTF-8' => 'Tiếng Việt (Vietnamese)' - ); + $arrLocales = getLocales(); #fetch system status variables. $system = new \RaspAP\System\Sysinfo; @@ -209,6 +186,20 @@ function DisplaySystem() $hostapd_led = "service-status-down"; } + // theme options + $themes = [ + "default" => "RaspAP (default)", + "hackernews" => "HackerNews" + ]; + $themeFiles = [ + "default" => "custom.php", + "hackernews" => "hackernews.css" + ]; + $selectedTheme = array_search($_COOKIE['theme'], $themeFiles); + + $extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false); + $extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false); + echo renderTemplate("system", compact( "arrLocales", "status", @@ -229,6 +220,8 @@ function DisplaySystem() "cputemp_led", "hostapd", "hostapd_status", - "hostapd_led" + "hostapd_led", + "themes", + "selectedTheme" )); } diff --git a/includes/themes.php b/includes/themes.php deleted file mode 100755 index ab4cf43c..00000000 --- a/includes/themes.php +++ /dev/null @@ -1,22 +0,0 @@ - "RaspAP (default)", - "hackernews" => "HackerNews" - ]; - $themeFiles = [ - "default" => "custom.php", - "hackernews" => "hackernews.css" - ]; - $selectedTheme = array_search($_COOKIE['theme'], $themeFiles); - - echo renderTemplate("themes", compact("themes", "selectedTheme")); - - $extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false); - $extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false); -} diff --git a/index.php b/index.php index 5fc4b9c6..8e68318f 100755 --- a/index.php +++ b/index.php @@ -41,7 +41,6 @@ require_once 'includes/system.php'; require_once 'includes/sysstats.php'; require_once 'includes/configure_client.php'; require_once 'includes/networking.php'; -require_once 'includes/themes.php'; require_once 'includes/data_usage.php'; require_once 'includes/about.php'; require_once 'includes/openvpn.php'; @@ -180,11 +179,6 @@ $bridgedEnabled = getBridgedState(); - - - @@ -287,14 +281,11 @@ $bridgedEnabled = getBridgedState(); case "/save_hostapd_conf": SaveTORAndVPNConfig(); break; - case "/theme_conf": - DisplayThemeConfig($extraFooterScripts); - break; case "/data_use": DisplayDataUsage($extraFooterScripts); break; case "/system_info": - DisplaySystem(); + DisplaySystem($extraFooterScripts); break; case "/about": DisplayAbout(); diff --git a/templates/system.php b/templates/system.php index 513f1c50..b939930d 100755 --- a/templates/system.php +++ b/templates/system.php @@ -15,12 +15,14 @@
+
diff --git a/templates/system/theme.php b/templates/system/theme.php new file mode 100644 index 00000000..10bb42ec --- /dev/null +++ b/templates/system/theme.php @@ -0,0 +1,20 @@ + +
+

+
+
+ + +
+
+ + +
+
+
+ +
+ + diff --git a/templates/themes.php b/templates/themes.php deleted file mode 100755 index 0e5d7fc2..00000000 --- a/templates/themes.php +++ /dev/null @@ -1,31 +0,0 @@ -
-
-
-
-
-
- -
-
-
-
-

-
-
- - -
-
- - -
-
-
- -
- -
-
-