Browse Source

remove theme supports-version etc checking

Andrew Dolgov 1 year ago
parent
commit
703351c79e
4 changed files with 7 additions and 26 deletions
  1. 2 2
      classes/pref/prefs.php
  2. 3 22
      include/functions.php
  3. 1 1
      index.php
  4. 1 1
      prefs.php

+ 2 - 2
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'>";
 

+ 3 - 22
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");
 	}
 
 	/**

+ 1 - 1
index.php

@@ -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");

+ 1 - 1
prefs.php

@@ -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");