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");
$_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"]);
}
}
- 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) {
}
}
- 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\"/>";
$num_tags = 0;
-/* if (get_user_theme_path($link) == "3pane") {
+/* if (get_user_theme($link) == "3pane") {
$tag_limit = 3;
} else {
$tag_limit = 6;
// 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) {
}
- 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.");
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>";
}
<?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) { ?>
| <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">
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
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,
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,
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,
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,
<?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 ?>"/>
</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">