From 0ea4fb50963cd443e06ef77fb0d193335575e51b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 10 Dec 2005 20:35:09 +0100 Subject: [PATCH] prefs: rework categorized feed list, boxed feed editor instead of inline --- backend.php | 310 +++++++++++++++++++++++++++----------------------- functions.php | 7 ++ prefs.js | 11 +- tt-rss.css | 8 ++ 4 files changed, 194 insertions(+), 142 deletions(-) diff --git a/backend.php b/backend.php index 73898646..8fc0d00b 100644 --- a/backend.php +++ b/backend.php @@ -1287,6 +1287,102 @@ $subop = $_GET["subop"]; $quiet = $_GET["quiet"]; + if ($subop == "editfeed") { + $feed_id = db_escape_string($_GET["id"]); + + $result = db_query($link, + "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND + owner_uid = " . $_SESSION["uid"]); + + $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, + 0, "title"))); + + print "
"; + + $icon_file = ICONS_DIR . "/$feed_id.ico"; + + if (file_exists($icon_file) && filesize($icon_file) > 0) { + $feed_icon = ""; + } else { + $feed_icon = ""; + } + + print "

$feed_icon $title

"; + + print ""; + + $row_class = "odd"; + + print ""; + print ""; + + $feed_url = db_fetch_result($result, 0, "feed_url"); + $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, + 0, "feed_url"))); + $row_class = toggleEvenOdd($row_class); + + print ""; + print ""; + + if (get_pref($link, 'ENABLE_FEED_CATS')) { + + $cat_id = db_fetch_result($result, 0, "cat_id"); + + $row_class = toggleEvenOdd($row_class); + + print ""; + print ""; + print ""; + + } + + $update_interval = db_fetch_result($result, 0, "update_interval"); + $row_class = toggleEvenOdd($row_class); + + print ""; + print ""; + + $purge_interval = db_fetch_result($result, 0, "purge_interval"); + $row_class = toggleEvenOdd($row_class); + + print ""; + print ""; + + print "
Title:
Feed URL:
Category:"; + print "
Update Interval:
Purge Days:
"; + print "
"; + + print "
+ +
"; + return; + } + if ($subop == "editSave") { $feed_title = db_escape_string($_GET["t"]); $feed_link = db_escape_string($_GET["l"]); @@ -1535,7 +1631,7 @@ ttrss_feeds WHERE $search_qpart owner_uid = '".$_SESSION["uid"]."' - ORDER by $feeds_sort,title"); + ORDER by category,$feeds_sort,title"); if (db_num_rows($result) != 0) { @@ -1551,46 +1647,72 @@ 'FEEDR-', 'FRCHK-', false)\">None "; - print " -   - Select - - Title - - Link - "; - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - print " - Category"; + if (!get_pref($link, 'ENABLE_FEED_CATS')) { + print " +   + Select + + Title + + Link + "; + + print " + + Update Interval + + + Purge Days + + "; } - print " - - Update Interval - - - Purge Days - - "; - $lnum = 0; + + $cur_cat_id = -1; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $feed_id = $line["id"]; + $cat_id = $line["cat_id"]; + + $edit_title = htmlspecialchars(db_unescape_string($line["title"])); + $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); + $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); - $edit_feed_id = $_GET["id"]; - - if ($subop == "edit" && $feed_id != $edit_feed_id) { - $class .= "Grayed"; - $this_row_id = ""; - } else { - $this_row_id = "id=\"FEEDR-$feed_id\""; + if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; + if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled"; + if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default"; + if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled"; + + if (!$edit_cat) $edit_cat = "Uncategorized"; + + + if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { + print "$edit_cat"; + + print " +   + Select + + Title + + Link + + + Update Interval + + + Purge Days + "; + + $cur_cat_id = $cat_id; } - + + $this_row_id = "id=\"FEEDR-$feed_id\""; + print ""; $icon_file = ICONS_DIR . "/$feed_id.ico"; @@ -1603,123 +1725,29 @@ } print "$feed_icon"; - $edit_title = htmlspecialchars(db_unescape_string($line["title"])); - $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); - $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); - - if (!$edit_cat) $edit_cat = "Uncategorized"; - - if (!$edit_feed_id || $subop != "edit") { - - print ""; + print ""; - $edit_title = truncate_string($edit_title, 40); - $edit_link = truncate_string($edit_link, 60); - - print "" . - $edit_title . ""; - - print "" . - $edit_link . ""; - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - print "" . - $edit_cat . ""; - } - - if ($line["update_interval"] == "0") - $line["update_interval"] = "Default"; - - if ($line["update_interval"] == "-1") - $line["update_interval"] = "Disabled"; + $edit_title = truncate_string($edit_title, 40); + $edit_link = truncate_string($edit_link, 60); - print "" . - $line["update_interval"] . ""; - - if ($line["purge_interval"] == "0") - $line["purge_interval"] = "Default"; - - if ($line["purge_interval"] < 0) - $line["purge_interval"] = "Disabled"; - - print "" . - $line["purge_interval"] . ""; - - } else if ($feed_id != $edit_feed_id) { - - print ""; + print "" . + $edit_title . ""; + + print "" . + $edit_link . ""; - $edit_title = truncate_string($edit_title, 40); - $edit_link = truncate_string($edit_link, 60); +/* if (get_pref($link, 'ENABLE_FEED_CATS')) { + print "" . + $edit_cat . ""; + } */ - print "$edit_title"; - print "$edit_link"; - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - print "$edit_cat"; - } - - if ($line["update_interval"] == "0") - $line["update_interval"] = "Default"; - - print "" . $line["update_interval"] . ""; - - if ($line["purge_interval"] == "0") - $line["purge_interval"] = "Default"; - - if ($line["purge_interval"] < 0) - $line["purge_interval"] = "Disabled"; - - print "" . $line["purge_interval"] . ""; - - } else { - - print ""; - - print ""; - print ""; - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - - print ""; - print ""; - print ""; - - } - - print ""; - print ""; - - } + print "" . + $line["purge_interval"] . ""; -/* if (!$line["last_updated"]) $line["last_updated"] = "Never"; - - print "" . $line["last_updated"] . ""; */ - print ""; ++$lnum; diff --git a/functions.php b/functions.php index d977745f..eedb9ab7 100644 --- a/functions.php +++ b/functions.php @@ -836,4 +836,11 @@ return "false"; } } + + function toggleEvenOdd($a) { + if ($a == "even") + return "odd"; + else + return "even"; + } ?> diff --git a/prefs.js b/prefs.js index 1064cb91..c1e8ed35 100644 --- a/prefs.js +++ b/prefs.js @@ -391,9 +391,18 @@ function editFeed(feed) { active_feed = feed; - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + +/* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + param_escape(feed), true); xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); */ + + selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); + selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed, true); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + + param_escape(active_feed), true); + + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); } diff --git a/tt-rss.css b/tt-rss.css index 05a2bde0..a7a51276 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -451,6 +451,14 @@ table.prefFeedList tr.title td, table.prefFilterList tr.title td, border-width : 0px 0px 1px 0px; border-color : #f0f0f0; border-style : solid; + font-size : x-small; +} + +table.prefFeedList td.feedEditCat { + font-size : large; + font-weight : bold; + color : black; + padding : 5px 0px 5px 0px; } a.helpLink { -- 2.39.5