diff options
-rw-r--r-- | classes/pref/prefs.php | 4 | ||||
-rwxr-xr-x | include/functions.php | 25 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | prefs.php | 2 |
4 files changed, 7 insertions, 26 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 6c7a45953..4af0bef33 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -552,10 +552,10 @@ class Pref_Prefs extends Handler_Protected { $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css")); $themes = array_map("basename", $themes); - $themes = array_filter($themes, "theme_valid"); + $themes = array_filter($themes, "theme_exists"); asort($themes); - if (!theme_valid($value)) $value = "default.php"; + if (!theme_exists($value)) $value = "default.php"; print "<select name='$pref_name' id='$pref_name' dojoType='dijit.form.Select'>"; diff --git a/include/functions.php b/include/functions.php index 2b6ad50e4..8d0b703f7 100755 --- a/include/functions.php +++ b/include/functions.php @@ -1078,7 +1078,7 @@ $params["label_base_index"] = (int) LABEL_BASE_INDEX; $theme = get_pref( "USER_CSS_THEME", false, false); - $params["theme"] = theme_valid("$theme") ? $theme : ""; + $params["theme"] = theme_exists($theme) ? $theme : ""; $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); @@ -2442,27 +2442,8 @@ if (file_exists($check)) return $check; } - function theme_valid($theme) { - $bundled_themes = [ "night.css", "compact.css" ]; - - if (in_array($theme, $bundled_themes)) return true; - - $file = "themes/" . basename($theme); - - if (!file_exists($file)) $file = "themes.local/" . basename($theme); - - if (file_exists($file) && is_readable($file)) { - $fh = fopen($file, "r"); - - if ($fh) { - $header = fgets($fh); - fclose($fh); - - return strpos($header, "supports-version:" . VERSION_STATIC) !== FALSE; - } - } - - return false; + function theme_exists($theme) { + return file_exists("themes/$theme") || file_exists("themes.local/$theme"); } /** @@ -63,7 +63,7 @@ <?php if ($_SESSION["uid"]) { $theme = get_pref("USER_CSS_THEME", false, false); - if ($theme && theme_valid("$theme")) { + if ($theme && theme_exists("$theme")) { echo stylesheet_tag(get_theme_path($theme)); } else { echo stylesheet_tag("css/default.css"); @@ -39,7 +39,7 @@ <?php if ($_SESSION["uid"]) { $theme = get_pref("USER_CSS_THEME", false, false); - if ($theme && theme_valid("$theme")) { + if ($theme && theme_exists("$theme")) { echo stylesheet_tag(get_theme_path($theme)); } else { echo stylesheet_tag("css/default.css"); |