]> git.wh0rd.org Git - tt-rss.git/commitdiff
support loading themes from themes.local
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 5 Jun 2015 15:08:19 +0000 (18:08 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 5 Jun 2015 15:08:19 +0000 (18:08 +0300)
.gitignore
classes/pref/prefs.php
include/functions2.php
index.php
prefs.php
themes.local/.empty [new file with mode: 0644]

index 09fccffa597be4f8dd6048aafc56f4a5b947484c..97ba8f64f4985484879ce12c1e904030d7eefa00 100644 (file)
@@ -4,12 +4,12 @@
 #*
 .idea/*
 plugins.local/*
+themes.local/*
 config.php
 feed-icons/*
 cache/*/*
 lock/*
 tags
-plugins/fever
 cache/htmlpurifier/*/*ser
 lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
 web.config\r
index 096260bfb5a595092a407b46d83d4e69809d152a..bc7d9212f233faf9e02a838a4fd1d8b520f8f41d 100644 (file)
@@ -570,8 +570,10 @@ class Pref_Prefs extends Handler_Protected {
 
                        } else if ($pref_name == "USER_CSS_THEME") {
 
-                               $themes = array_filter(array_map("basename", glob("themes/*.css")),
-                                       "theme_valid");
+                               $themes = array_merge(glob("themes/*.css"), glob("themes.local/*.css"));
+                               $themes = array_map("basename", $themes);
+                               $themes = array_filter($themes, "theme_valid");
+                               asort($themes);
 
                                print_select($pref_name, $value, $themes,
                                        'dojoType="dijit.form.Select"');
index 4f8a0523ba37cfddeffb37d98ce45f65cf297ce7..314c128739425f88e41fa81f1b124f61b85747e9 100644 (file)
                return LABEL_BASE_INDEX - 1 + abs($feed);
        }
 
-       function theme_valid($file) {
-               if ($file == "default.css" || $file == "night.css") return true; // needed for array_filter
-               $file = "themes/" . basename($file);
+       function get_theme_path($theme) {
+               $check = "themes/$theme";
+               if (file_exists($check)) return $check;
+
+               $check = "themes.local/$theme";
+               if (file_exists($check)) return $check;
+       }
+
+       function theme_valid($theme) {
+               if ($theme == "default.css" || $theme == "night.css") return true; // needed for array_filter
+               $file = "themes/" . basename($theme);
+
+               if (!file_exists($file)) $file = "themes.local/" . basename($theme);
 
                if (file_exists($file) && is_readable($file)) {
                        $fh = fopen($file, "r");
index 360a6dc193632aafb7df0a86921ee77e9fa580be..f7ff97c688ed8b354ede05ef0c292eecf85955ee 100644 (file)
--- a/index.php
+++ b/index.php
@@ -66,7 +66,7 @@
        <?php if ($_SESSION["uid"]) {
                $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
                if ($theme && theme_valid("$theme")) {
-                       echo stylesheet_tag("themes/$theme");
+                       echo stylesheet_tag(get_theme_path($theme));
                } else {
                        echo stylesheet_tag("themes/default.css");
                }
index 191f452c4e11cad86e0639cbe238ef45447244e6..b20678abebdc577501403a01af7ef5553861e991 100644 (file)
--- a/prefs.php
+++ b/prefs.php
@@ -42,7 +42,7 @@
        <?php if ($_SESSION["uid"]) {
                $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
                if ($theme && theme_valid("$theme")) {
-                       echo stylesheet_tag("themes/$theme");
+                       echo stylesheet_tag(get_theme_path($theme));
                } else {
                        echo stylesheet_tag("themes/default.css");
                }
diff --git a/themes.local/.empty b/themes.local/.empty
new file mode 100644 (file)
index 0000000..e69de29