From 4062022e0fd5eda07e4230cc3f39b91e77465ff2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 16 Nov 2005 18:09:27 +0100 Subject: [PATCH] sql-ize tt-rss.php prefs --- backend.php | 1 - db-prefs.php | 19 +++++++++++++------ tt-rss.php | 30 +++++++++++++++++++----------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/backend.php b/backend.php index 954c4dac..958ca26f 100644 --- a/backend.php +++ b/backend.php @@ -16,7 +16,6 @@ $script_started = getmicrotime(); $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - $dbprefs_link = $link; if (!$link) { if (DB_TYPE == "mysql") { diff --git a/db-prefs.php b/db-prefs.php index c0f6159e..38382193 100644 --- a/db-prefs.php +++ b/db-prefs.php @@ -3,20 +3,27 @@ require_once "config.php"; require_once "db.php"; - global $dbprefs_link; - - function get_pref($pref_name) { + function get_pref($link, $pref_name) { $pref_name = db_escape_string($pref_name); - $result = db_query($dbprefs_link, "SELECT - value,ttrss_prefs_types.id as type_name + $result = db_query($link, "SELECT + value,ttrss_prefs_types.type_name as type_name FROM ttrss_prefs,ttrss_prefs_types WHERE pref_name = '$pref_name' AND ttrss_prefs_types.id = type_id"); if (db_num_rows($result) > 0) { $value = db_fetch_result($result, 0, "value"); - return $value; + $type_name = db_fetch_result($result, 0, "type_name"); + + if ($type_name == "bool") { + return $value == "true"; + } else if ($type_name == "integer") { + return sprintf("%d", $value); + } else { + return $value; + } + } else { die("Fatal error, unknown preferences key: $pref_name"); } diff --git a/tt-rss.php b/tt-rss.php index 2d29d445..a6a1842c 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -1,13 +1,17 @@ - - + Tiny Tiny RSS - + @@ -28,7 +32,7 @@ - +
@@ -39,7 +43,7 @@ - +
@@ -69,7 +73,7 @@ src="backend.php?op=error&msg=Loading,%20please wait..." id="feeds-frame" name="feeds-frame" class="feedsFrame"> - +
All feeds: @@ -120,8 +124,12 @@ 15, 30 => 30, 60 => 60); - if (DEFAULT_ARTILE_LIMIT >= 0) { - $limits[DEFAULT_ARTICLE_LIMIT] = DEFAULT_ARTICLE_LIMIT; + $def_art_limit = get_pref($link, 'DEFAULT_ARTICLE_LIMIT'); + + print $def_art_limit; + + if ($def_art_limit >= 0) { + $limits[$def_art_limit] = $def_art_limit; } asort($limits); @@ -130,14 +138,14 @@ foreach ($limits as $key) { print ""; if ($limits[$key] == 0) { print "All"; } else { print $limits[$key]; } print ""; } ?> - +  Feed:
- +