query themes from filesystem; obsolete ttrss_themes

This commit is contained in:
Andrew Dolgov 2010-01-14 13:39:05 +03:00
parent 7abf159d61
commit dce46cade3
7 changed files with 69 additions and 56 deletions

View File

@ -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($link) {
if (get_schema_version($link) >= 63) {
return get_pref($link, "_THEME_ID");
} else {
return false;
}
}
function get_user_theme_path($link) {
if (get_schema_version($link) >= 63) {
$theme_id = (int) get_pref($link, "_THEME_ID");
} else {
$theme_id = 1;
}
$theme_name = get_pref($link, "_THEME_ID");
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;
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;

View File

@ -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 "<tr><td width=\"40%\">".__("Select theme")."</td>";
$user_theme = get_pref($link, "_THEME_ID");
$themes = get_all_themes();
print "<td><select name=\"_THEME_ID\">";
print "<option value='0'>".__('Default')."</option>";
print "<option value=''>".__('Default')."</option>";
print "<option disabled>--------</option>";
$user_theme_id = get_pref($link, "_THEME_ID");
$tmp_result = db_query($link, "SELECT
id,theme_name FROM ttrss_themes ORDER BY theme_name");
while ($tmp_line = db_fetch_assoc($tmp_result)) {
if ($tmp_line["id"] == $user_theme_id) {
$selected = "selected";
foreach ($themes as $t) {
$base = $t['base'];
$name = $t['name'];
if ($base == $user_theme) {
$selected = "selected=\"1\"";
} else {
$selected = "";
}
print "<option value=\"".$tmp_line["id"]."\" $selected>" .
$tmp_line["theme_name"] . "</option>";
print "<option $selected value='$base'>$name</option>";
}
print "</select></td></tr>";
}

View File

@ -28,10 +28,8 @@
<?php $user_theme = get_user_theme_path($link);
if ($user_theme) { ?>
<link rel="stylesheet" type="text/css" href="themes/<?php echo $user_theme ?>/theme.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo $user_theme ?>/theme.css"/>
<?php } ?>
<?php if ($user_theme) { $theme_image_path = "themes/$user_theme/"; } ?>
<?php $user_css_url = get_pref($link, 'USER_STYLESHEET_URL'); ?>
<?php if ($user_css_url) { ?>
@ -96,7 +94,7 @@
| <a href="logout.php"><?php echo __('Logout') ?></a>
<?php } ?>
</div>
<img src="<?php echo $theme_image_path ?>images/ttrss_logo.png" alt="Tiny Tiny RSS"/>
<img src="<?php echo $user_theme ?>images/ttrss_logo.png" alt="Tiny Tiny RSS"/>
</div>
<div id="prefTabs">

View File

@ -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 "<b>Fatal Error</b>: You forgot to copy

View File

@ -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,

View File

@ -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,

View File

@ -29,11 +29,9 @@
<?php $user_theme = get_user_theme_path($link);
if ($user_theme) { ?>
<link rel="stylesheet" type="text/css" href="themes/<?php echo $user_theme ?>/theme.css?<?php echo $dt_add ?>">
<link rel="stylesheet" type="text/css" href="<?php echo $user_theme ?>/theme.css?<?php echo $dt_add ?>">
<?php } ?>
<?php if ($user_theme) { $theme_image_path = "themes/$user_theme/"; } ?>
<?php $user_css_url = get_pref($link, 'USER_STYLESHEET_URL'); ?>
<?php if ($user_css_url) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo $user_css_url ?>"/>
@ -161,7 +159,7 @@
</div>
<img src="<?php echo $theme_image_path ?>images/ttrss_logo.png" alt="Tiny Tiny RSS"/>
<img src="<?php echo $user_theme ?>images/ttrss_logo.png" alt="Tiny Tiny RSS"/>
</div>
<div id="feeds-holder">