]> git.wh0rd.org Git - tt-rss.git/commitdiff
preferences editor
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 17 Nov 2005 05:26:54 +0000 (06:26 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 17 Nov 2005 05:26:54 +0000 (06:26 +0100)
backend.php
functions.php
prefs.js
tt-rss.css

index e70fc9d7eda64373bbab8ab2bc02963450c0fc52..f37c51bd80b5ee17598fe2442c496cf051f837ec 100644 (file)
@@ -1,7 +1,7 @@
 <?
        define(SCHEMA_VERSION, 2);
 
-       $op = $_GET["op"];
+       $op = $_REQUEST["op"];
 
        if ($op == "rpc" || $op == "updateAllFeeds") {
                header("Content-Type: application/xml");
 
        }
 
+       if ($op == "pref-prefs") {
+
+               $subop = $_POST["subop"];
+
+               if ($subop == "Save configuration") {
+
+                       foreach (array_keys($_POST) as $pref_name) {
+                       
+                               $pref_name = db_escape_string($pref_name);
+                               $value = db_escape_string($_POST[$pref_name]);
+
+                               $result = db_query($link, "SELECT type_name 
+                                       FROM ttrss_prefs,ttrss_prefs_types 
+                                       WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
+
+                               if (db_num_rows($result) > 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<br>";
+
+                                       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 "<form action=\"backend.php\" method=\"POST\">";
+
+                       print "<table width=\"100%\" class=\"prefPrefsList\">";
+       
+                       $lnum = 0;
+
+                       $active_section = "";
+       
+                       while ($line = db_fetch_assoc($result)) {
+
+                               if ($active_section != $line["section_name"]) {
+                                       $active_section = $line["section_name"];
+                                       print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>";
+                                       print "<tr class=\"title\">
+                                               <td width=\"25%\">Option</td><td>Value</td></tr>";
+                               }
+
+                               $class = ($lnum % 2) ? "even" : "odd";
+
+                               print "<tr class=\"$class\">";
+
+                               print "<td width=\"40%\">" . $line["short_desc"] . "</td>";
+
+                               $type_name = $line["type_name"];
+                               $pref_name = $line["pref_name"];
+                               $value = $line["value"];
+                               $def_value = $line["def_value"];
+
+                               print "<td>";
+
+                               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 "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">";
+                               }
+
+                               print "</td>";
+
+                               print "</tr>";
+
+                               $lnum++;
+                       }
+
+                       print "</table>";
+
+                       print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
+
+                       print "<p><input class=\"button\" type=\"submit\" 
+                               name=\"subop\" value=\"Save configuration\">";
+                               
+                       print "&nbsp;<input class=\"button\" type=\"submit\" 
+                               name=\"subop\" value=\"Reset to defaults\"></p>";
+
+                       print "</form>";
+
+               }
+
+       }
+
        db_close($link);
 ?>
 
index d9d9c37fd52c7b507b246d888720b096a3d7f121..75fc8003c1d6d04f066f270609588f0430f70c36 100644 (file)
                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 "<input type=\"radio\" $sel $attributes name=\"$id\">&nbsp;$v&nbsp;";
+
+               }
+       }
+
 ?>
index 170423423c92a32227688ba90f383fb907821e88..a7764758e53e624d34d48e79e65ffa286ba7404a 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -779,7 +779,7 @@ function init() {
                return;
        }
 
-       selectTab("feedConfig");
+       selectTab("genConfig");
 
        document.onkeydown = hotkey_handler;
        notify("");
index 933575aba2949c716e1b45ad0cc9aa15cf2b89ea..5c3251abbfe4f667507d0aa50e4246292e8b05d7 100644 (file)
@@ -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;