remove theme supports-version etc checking

This commit is contained in:
Andrew Dolgov 2018-12-09 11:37:26 +03:00
parent b2c079893b
commit 703351c79e
4 changed files with 7 additions and 26 deletions

View File

@ -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_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css"));
$themes = array_map("basename", $themes); $themes = array_map("basename", $themes);
$themes = array_filter($themes, "theme_valid"); $themes = array_filter($themes, "theme_exists");
asort($themes); 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'>"; print "<select name='$pref_name' id='$pref_name' dojoType='dijit.form.Select'>";

View File

@ -1078,7 +1078,7 @@
$params["label_base_index"] = (int) LABEL_BASE_INDEX; $params["label_base_index"] = (int) LABEL_BASE_INDEX;
$theme = get_pref( "USER_CSS_THEME", false, false); $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()); $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names());
@ -2442,27 +2442,8 @@
if (file_exists($check)) return $check; if (file_exists($check)) return $check;
} }
function theme_valid($theme) { function theme_exists($theme) {
$bundled_themes = [ "night.css", "compact.css" ]; return file_exists("themes/$theme") || file_exists("themes.local/$theme");
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;
} }
/** /**

View File

@ -63,7 +63,7 @@
<?php if ($_SESSION["uid"]) { <?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false); $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)); echo stylesheet_tag(get_theme_path($theme));
} else { } else {
echo stylesheet_tag("css/default.css"); echo stylesheet_tag("css/default.css");

View File

@ -39,7 +39,7 @@
<?php if ($_SESSION["uid"]) { <?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false); $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)); echo stylesheet_tag(get_theme_path($theme));
} else { } else {
echo stylesheet_tag("css/default.css"); echo stylesheet_tag("css/default.css");