From db3f4c01ea60da33cb340514a6d05090525a65e8 Mon Sep 17 00:00:00 2001 From: Roni <54395471+Roni-Neto@users.noreply.github.com> Date: Mon, 17 May 2021 00:54:45 -0300 Subject: [PATCH] Added in preferences light or dark theme (#539) Added in the preferences option to change the light or dark theme, Now to change the theme will be in the preferences / settings area, along with other settings, and may even have other themes in the future. --- tinyfilemanager.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 60dfad1..dbada7c 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,6 +1,6 @@ '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345 ); -//set application theme -//options - 'light' and 'dark' -$theme = 'light'; - // Readonly users // e.g. array('users', 'guest', ...) $readonly_users = array( @@ -141,8 +137,6 @@ if (is_readable($config_file)) { // max upload file size define('MAX_UPLOAD_SIZE', $max_upload_size_bytes); -define('FM_THEME', $theme); - // private key and session name to store to the session if ( !defined( 'FM_SESSION_ID')) { define('FM_SESSION_ID', 'filemanager'); @@ -166,6 +160,11 @@ $hide_Cols = isset($cfg->data['hide_Cols']) ? $cfg->data['hide_Cols'] : true; // Show directory size: true or speedup output: false $calc_folder = isset($cfg->data['calc_folder']) ? $cfg->data['calc_folder'] : true; +// Theme +$theme = isset($cfg->data['theme']) ? $cfg->data['theme'] : 'light'; + +define('FM_THEME', $theme); + //available languages $lang_list = array( 'en' => 'English' @@ -473,7 +472,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { // Save Config if (isset($_POST['type']) && $_POST['type'] == "settings") { - global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list, $hide_Cols, $calc_folder; + global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list, $hide_Cols, $calc_folder, $theme; $newLng = $_POST['js-language']; fm_get_translations([]); if (!array_key_exists($newLng, $lang_list)) { @@ -484,6 +483,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false; $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == "true" ? true : false; $caf = isset($_POST['js-calc-folder']) && $_POST['js-calc-folder'] == "true" ? true : false; + $te3 = $_POST['js-theme-3']; if ($cfg->data['lang'] != $newLng) { $cfg->data['lang'] = $newLng; @@ -509,6 +509,10 @@ if (isset($_POST['ajax']) && !FM_READONLY) { $cfg->data['calc_folder'] = $caf; $calc_folder = $caf; } + if ($cfg->data['theme'] != $te3) { + $cfg->data['theme'] = $te3; + $theme = $te3; + } $cfg->save(); echo true; } @@ -1435,6 +1439,16 @@ if (isset($_GET['settings']) && !FM_READONLY) { + +
+ +
+ +
+