From: Andrew Dolgov Date: Thu, 14 Jan 2010 10:39:05 +0000 (+0300) Subject: query themes from filesystem; obsolete ttrss_themes X-Git-Tag: 1.4.0~46 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=dce46cade3ef1d24a12cf6d27abad5d93de95373;p=tt-rss.git query themes from filesystem; obsolete ttrss_themes --- diff --git a/functions.php b/functions.php index 71f3cbb1..ab779d3e 100644 --- a/functions.php +++ b/functions.php @@ -1797,8 +1797,6 @@ db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " . $_SESSION["uid"]); - $user_theme = get_user_theme_path($link); - $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; $_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash"); @@ -1814,8 +1812,6 @@ $_SESSION["uid"] = 1; $_SESSION["name"] = "admin"; - $user_theme = get_user_theme_path($link); - $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; initialize_user_prefs($link, $_SESSION["uid"]); @@ -1991,27 +1987,54 @@ } } - function get_user_theme_path($link) { + function get_user_theme($link) { if (get_schema_version($link) >= 63) { - $theme_id = (int) get_pref($link, "_THEME_ID"); + return get_pref($link, "_THEME_ID"); } else { - $theme_id = 1; + return false; } - if (!$_SESSION["theme_path"][$theme_id]) { - $result = db_query($link, "SELECT theme_path - FROM ttrss_themes WHERE id = '$theme_id'"); - if (db_num_rows($result) != 0) { - $theme = db_fetch_result($result, 0, "theme_path"); - $_SESSION["theme_path"][$theme_id] = $theme; - return $theme; + } + + function get_user_theme_path($link) { + + if (get_schema_version($link) >= 63) { + $theme_name = get_pref($link, "_THEME_ID"); + + if ($theme_name) { + $theme_path = "themes/$theme_name/"; } else { - return null; + $theme_name = ''; } } else { - return $_SESSION["theme_path"][$theme_id]; + $theme_path = ''; + } + + return $theme_path; + } + + function get_all_themes() { + $themes = glob("themes/*"); + + $rv = array(); + + foreach ($themes as $t) { + if (is_file("$t/theme.ini")) { + $ini = parse_ini_file("$t/theme.ini", true); + if ($ini['theme']['version']) { + $entry = array(); + $entry["path"] = $t; + $entry["base"] = basename($t); + $entry["name"] = $ini['theme']['name']; + $entry["version"] = $ini['theme']['version']; + $entry["author"] = $ini['theme']['author']; + array_push($rv, $entry); + } + } } + + return $rv; } function smart_date_time($timestamp) { @@ -3084,7 +3107,7 @@ } } - print ""; + print ""; print ""; print ""; print ""; @@ -6252,7 +6275,7 @@ $num_tags = 0; -/* if (get_user_theme_path($link) == "3pane") { +/* if (get_user_theme($link) == "3pane") { $tag_limit = 3; } else { $tag_limit = 6; diff --git a/modules/pref-prefs.php b/modules/pref-prefs.php index 367dfe40..9b58cdbb 100644 --- a/modules/pref-prefs.php +++ b/modules/pref-prefs.php @@ -85,7 +85,7 @@ // print_r($_POST); - $orig_theme_id = get_pref($link, "_THEME_ID"); + $orig_theme = get_pref($link, "_THEME_ID"); foreach (array_keys($_POST) as $pref_name) { @@ -96,17 +96,7 @@ } - if ($orig_theme_id != get_pref($link, "_THEME_ID")) { - - $result = db_query($link, "SELECT theme_path FROM ttrss_themes - WHERE id = '".get_pref($link, "_THEME_ID")."'"); - - if (db_num_rows($result) == 1) { - $theme_path = db_fetch_result($result, 0, "theme_path"); - } else { - $theme_path = ""; - } - + if ($orig_theme != get_pref($link, "_THEME_ID")) { print "PREFS_THEME_CHANGED"; } else { print __("The configuration was saved."); @@ -329,24 +319,28 @@ if ($line["section_id"] == 2) { print "".__("Select theme").""; + + $user_theme = get_pref($link, "_THEME_ID"); + $themes = get_all_themes(); + print ""; } diff --git a/prefs.php b/prefs.php index 656bdaf1..9d2d0a84 100644 --- a/prefs.php +++ b/prefs.php @@ -28,10 +28,8 @@ - + - - @@ -96,7 +94,7 @@ | - Tiny Tiny RSS + Tiny Tiny RSS
diff --git a/sanity_check.php b/sanity_check.php index c50d391a..e39902ef 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 18); - define('SCHEMA_VERSION', 63); + define('SCHEMA_VERSION', 64); if (!file_exists("config.php")) { print "Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 862ae3a4..82284b8b 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -239,7 +239,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (63); +insert into ttrss_version values (64); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, @@ -396,7 +396,7 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', '', 1); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_THEME_ID', 3, '0', '', 1); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_THEME_ID', 2, '0', '', 1); create table ttrss_user_prefs ( owner_uid integer not null, diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index fb2ac182..3a27577f 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -211,7 +211,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (63); +insert into ttrss_version values (64); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -360,7 +360,7 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', '', 1); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_THEME_ID', 3, '0', '', 1); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_THEME_ID', 2, '0', '', 1); create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, diff --git a/tt-rss.php b/tt-rss.php index 0cd784ee..6226c05b 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -29,11 +29,9 @@ - + - - @@ -161,7 +159,7 @@
- Tiny Tiny RSS + Tiny Tiny RSS