From 77e9671919d21b2b1d08c9da38520ba7a40592a1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 17 Nov 2005 06:26:54 +0100 Subject: preferences editor --- backend.php | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- functions.php | 13 ++++++ prefs.js | 2 +- tt-rss.css | 8 +++- 4 files changed, 144 insertions(+), 3 deletions(-) diff --git a/backend.php b/backend.php index e70fc9d7e..f37c51bd8 100644 --- a/backend.php +++ b/backend.php @@ -1,7 +1,7 @@ 0) { + + $type_name = db_fetch_result($result, 0, "type_name"); + + if ($type_name == "bool") { + if ($value == 1) { + $value = "true"; + } else { + $value = "false"; + } + } else if ($type_name == "integer") { + $value = sprintf("%d", $value); + } + +// print "$pref_name : $type_name : $value
"; + + db_query($link, "UPDATE ttrss_prefs SET value = '$value' + WHERE pref_name = '$pref_name'"); + + } + + header("Location: prefs.php"); + + } + + } else if ($subop == "Reset to defaults") { + + header("Location: prefs.php"); + + } else { + + $result = db_query($link, "SELECT + pref_name,short_desc,help_text,value,type_name, + section_name,def_value + FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections + WHERE type_id = ttrss_prefs_types.id AND + section_id = ttrss_prefs_sections.id + ORDER BY section_name,short_desc"); + + print "
"; + + print ""; + + $lnum = 0; + + $active_section = ""; + + while ($line = db_fetch_assoc($result)) { + + if ($active_section != $line["section_name"]) { + $active_section = $line["section_name"]; + print ""; + print " + "; + } + + $class = ($lnum % 2) ? "even" : "odd"; + + print ""; + + print ""; + + $type_name = $line["type_name"]; + $pref_name = $line["pref_name"]; + $value = $line["value"]; + $def_value = $line["def_value"]; + + print ""; + + print ""; + + $lnum++; + } + + print "

$active_section

OptionValue
" . $line["short_desc"] . ""; + + if ($type_name == "bool") { +// print_select($pref_name, $value, array("true", "false")); + + if ($value == "true") { + $value = "Yes"; + } else { + $value = "No"; + } + + print_radio($pref_name, $value, array("Yes", "No")); + + } else { + print ""; + } + + print "
"; + + print ""; + + print "

"; + + print " 

"; + + print "
"; + + } + + } + db_close($link); ?> diff --git a/functions.php b/functions.php index d9d9c37fd..75fc8003c 100644 --- a/functions.php +++ b/functions.php @@ -454,4 +454,17 @@ return ((float)$usec + (float)$sec); } + function print_radio($id, $default, $values, $attributes = "") { + foreach ($values as $v) { + + if ($v == $default) + $sel = "checked value=\"1\""; + else + $sel = "value=\"0\""; + + print " $v "; + + } + } + ?> diff --git a/prefs.js b/prefs.js index 170423423..a7764758e 100644 --- a/prefs.js +++ b/prefs.js @@ -779,7 +779,7 @@ function init() { return; } - selectTab("feedConfig"); + selectTab("genConfig"); document.onkeydown = hotkey_handler; notify(""); diff --git a/tt-rss.css b/tt-rss.css index 933575aba..5c3251abb 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -246,6 +246,11 @@ a:hover { padding-left : 2px; } +input.editbox { + width : 200px; + padding-left : 2px; +} + #notify { font-size : 10pt; text-align : right; @@ -390,7 +395,8 @@ table.prefAddFeed input { } table.prefFeedList tr.title td, table.prefFilterList tr.title td, - table.headlinesList tr.title td, table.prefLabelList tr.title td { + table.headlinesList tr.title td, table.prefLabelList tr.title td, + table.prefPrefsList tr.title td { font-weight : bold; border-width : 0px 0px 1px 0px; border-color : #f0f0f0; -- cgit v1.2.3