diff options
author | Andrew Dolgov <[email protected]> | 2010-01-14 13:39:05 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-01-14 13:39:05 +0300 |
commit | dce46cade3ef1d24a12cf6d27abad5d93de95373 (patch) | |
tree | 6134e71244b7eeb72b1232ac40a736e76df7aede /functions.php | |
parent | 7abf159d61a933106b9b7a704cf3e549a3b4ab01 (diff) |
query themes from filesystem; obsolete ttrss_themes
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/functions.php b/functions.php index 71f3cbb16..ab779d3e0 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 "<param key=\"theme\" value=\"".get_user_theme_path($link)."\"/>"; + print "<param key=\"theme\" value=\"".get_user_theme($link)."\"/>"; print "<param key=\"daemon_enabled\" value=\"" . ENABLE_UPDATE_DAEMON . "\"/>"; print "<param key=\"feeds_frame_refresh\" value=\"" . FEEDS_FRAME_REFRESH . "\"/>"; print "<param key=\"daemon_refresh_only\" value=\"true\"/>"; @@ -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; |