support loading themes from themes.local
This commit is contained in:
parent
7c0a2ab202
commit
b9634eb8b8
6 changed files with 20 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,12 +4,12 @@
|
||||||
#*
|
#*
|
||||||
.idea/*
|
.idea/*
|
||||||
plugins.local/*
|
plugins.local/*
|
||||||
|
themes.local/*
|
||||||
config.php
|
config.php
|
||||||
feed-icons/*
|
feed-icons/*
|
||||||
cache/*/*
|
cache/*/*
|
||||||
lock/*
|
lock/*
|
||||||
tags
|
tags
|
||||||
plugins/fever
|
|
||||||
cache/htmlpurifier/*/*ser
|
cache/htmlpurifier/*/*ser
|
||||||
lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
|
lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
|
||||||
web.config
|
web.config
|
||||||
|
|
|
@ -570,8 +570,10 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
|
|
||||||
} else if ($pref_name == "USER_CSS_THEME") {
|
} else if ($pref_name == "USER_CSS_THEME") {
|
||||||
|
|
||||||
$themes = array_filter(array_map("basename", glob("themes/*.css")),
|
$themes = array_merge(glob("themes/*.css"), glob("themes.local/*.css"));
|
||||||
"theme_valid");
|
$themes = array_map("basename", $themes);
|
||||||
|
$themes = array_filter($themes, "theme_valid");
|
||||||
|
asort($themes);
|
||||||
|
|
||||||
print_select($pref_name, $value, $themes,
|
print_select($pref_name, $value, $themes,
|
||||||
'dojoType="dijit.form.Select"');
|
'dojoType="dijit.form.Select"');
|
||||||
|
|
|
@ -2444,9 +2444,19 @@
|
||||||
return LABEL_BASE_INDEX - 1 + abs($feed);
|
return LABEL_BASE_INDEX - 1 + abs($feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
function theme_valid($file) {
|
function get_theme_path($theme) {
|
||||||
if ($file == "default.css" || $file == "night.css") return true; // needed for array_filter
|
$check = "themes/$theme";
|
||||||
$file = "themes/" . basename($file);
|
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)) {
|
if (file_exists($file) && is_readable($file)) {
|
||||||
$fh = fopen($file, "r");
|
$fh = fopen($file, "r");
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<?php if ($_SESSION["uid"]) {
|
<?php if ($_SESSION["uid"]) {
|
||||||
$theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
|
$theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
|
||||||
if ($theme && theme_valid("$theme")) {
|
if ($theme && theme_valid("$theme")) {
|
||||||
echo stylesheet_tag("themes/$theme");
|
echo stylesheet_tag(get_theme_path($theme));
|
||||||
} else {
|
} else {
|
||||||
echo stylesheet_tag("themes/default.css");
|
echo stylesheet_tag("themes/default.css");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<?php if ($_SESSION["uid"]) {
|
<?php if ($_SESSION["uid"]) {
|
||||||
$theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
|
$theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
|
||||||
if ($theme && theme_valid("$theme")) {
|
if ($theme && theme_valid("$theme")) {
|
||||||
echo stylesheet_tag("themes/$theme");
|
echo stylesheet_tag(get_theme_path($theme));
|
||||||
} else {
|
} else {
|
||||||
echo stylesheet_tag("themes/default.css");
|
echo stylesheet_tag("themes/default.css");
|
||||||
}
|
}
|
||||||
|
|
0
themes.local/.empty
Normal file
0
themes.local/.empty
Normal file
Loading…
Reference in a new issue