From 547e6542ba7d396cc1c349577e2078fda098bee6 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Nov 2023 10:09:31 +0000 Subject: move color_mode related code to theme_init.php --- view/theme/redbasic/php/theme.php | 20 -------------------- view/theme/redbasic/php/theme_init.php | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'view/theme') diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php index 82f6c80d3..c33c4f78e 100644 --- a/view/theme/redbasic/php/theme.php +++ b/view/theme/redbasic/php/theme.php @@ -16,24 +16,4 @@ function redbasic_init() { - $mode = ''; - $navbar_mode = ''; - - if (local_channel()) { - $mode = ((get_pconfig(local_channel(), 'redbasic', 'dark_mode')) ? 'dark' : 'light'); - $navbar_mode = ((get_pconfig(local_channel(), 'redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); - } - - if (App::$profile_uid) { - $mode = ((get_pconfig(App::$profile_uid, 'redbasic', 'dark_mode')) ? 'dark' : 'light'); - $navbar_mode = ((get_pconfig(App::$profile_uid, 'redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); - } - - if (!$mode) { - $mode = ((get_config('redbasic', 'dark_mode')) ? 'dark' : 'light'); - $navbar_mode = ((get_config('redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); - } - - App::$page['color_mode'] = 'data-bs-theme="' . $mode . '"'; - App::$page['navbar_color_mode'] = (($navbar_mode === 'dark') ? 'data-bs-theme="' . $navbar_mode . '"' : ''); } diff --git a/view/theme/redbasic/php/theme_init.php b/view/theme/redbasic/php/theme_init.php index af2794b8d..cb81165b1 100644 --- a/view/theme/redbasic/php/theme_init.php +++ b/view/theme/redbasic/php/theme_init.php @@ -11,3 +11,24 @@ head_add_js('/vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js'); head_add_js('/library/bootbox/bootbox.min.js'); head_add_js('/library/bootstrap-tagsinput/bootstrap-tagsinput.js'); head_add_js('/library/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js'); + +$redbasic_mode = ''; +$redbasic_navbar_mode = ''; + +if (local_channel()) { + $redbasic_mode = ((get_pconfig(local_channel(), 'redbasic', 'dark_mode')) ? 'dark' : 'light'); + $redbasic_navbar_mode = ((get_pconfig(local_channel(), 'redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); +} + +if (App::$profile_uid) { + $redbasic_mode = ((get_pconfig(App::$profile_uid, 'redbasic', 'dark_mode')) ? 'dark' : 'light'); + $redbasic_navbar_mode = ((get_pconfig(App::$profile_uid, 'redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); +} + +if (!$redbasic_mode) { + $redbasic_mode = ((get_config('redbasic', 'dark_mode')) ? 'dark' : 'light'); + $redbasic_navbar_mode = ((get_config('redbasic', 'navbar_dark_mode')) ? 'dark' : 'light'); +} + +App::$page['color_mode'] = 'data-bs-theme="' . $redbasic_mode . '"'; +App::$page['navbar_color_mode'] = (($redbasic_navbar_mode === 'dark') ? 'data-bs-theme="' . $redbasic_navbar_mode . '"' : ''); -- cgit v1.2.3