From 9c4837460c168b248e7f4a45d5b020e878bc3f91 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 4 Oct 2006 06:40:00 +0100 Subject: [PATCH] infobox-based feed category editor --- functions.js | 1 + modules/pref-feeds.php | 238 ++++++++++++++++++++++++++++++++++++-- prefs.js | 31 +++-- themes/compat/theme.css | 4 + themes/graycube/theme.css | 17 ++- tt-rss.css | 10 +- 6 files changed, 275 insertions(+), 26 deletions(-) diff --git a/functions.js b/functions.js index 652e2316..db135151 100644 --- a/functions.js +++ b/functions.js @@ -1215,6 +1215,7 @@ function infobox_callback() { box.style.display = "block"; } } + notify(""); } } diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index c4605727..46b03e89 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -391,14 +391,14 @@ } } - if ($subop == "saveCat") { +/* if ($subop == "saveCat") { $cat_title = db_escape_string(trim($_GET["title"])); $cat_id = db_escape_string($_GET["id"]); $result = db_query($link, "UPDATE ttrss_feed_categories SET title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); - } +} */ if ($subop == "remove") { @@ -446,7 +446,7 @@ } } - if ($subop == "addCat") { +/* if ($subop == "addCat") { if (!WEB_DEMO_MODE) { @@ -471,7 +471,7 @@ } - } + } if ($subop == "removeCats") { @@ -502,7 +502,7 @@ db_query($link, "COMMIT"); } } - } + } */ if ($subop == "categorize") { @@ -538,6 +538,215 @@ } + if ($subop == "editCats") { + + print "
Category editor
"; + + print "
"; + + $action = $_REQUEST["action"]; + + if ($action == "save") { + + $cat_title = db_escape_string(trim($_GET["title"])); + $cat_id = db_escape_string($_GET["id"]); + + $result = db_query($link, "UPDATE ttrss_feed_categories SET + title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); + + } + + if ($action == "add") { + + if (!WEB_DEMO_MODE) { + + $feed_cat = db_escape_string(trim($_GET["cat"])); + + $result = db_query($link, + "SELECT id FROM ttrss_feed_categories + WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); + + if (db_num_rows($result) == 0) { + + $result = db_query($link, + "INSERT INTO ttrss_feed_categories (owner_uid,title) + VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); + + } else { + + print "
+ Category $feed_cat already exists in the database. +
"; + } + + } + } + + if ($action == "remove") { + + if (!WEB_DEMO_MODE) { + + $ids = split(",", db_escape_string($_GET["ids"])); + + foreach ($ids as $id) { + + db_query($link, "BEGIN"); + + $result = db_query($link, + "SELECT count(id) as num_feeds FROM ttrss_feeds + WHERE cat_id = '$id'"); + + $num_feeds = db_fetch_result($result, 0, "num_feeds"); + + if ($num_feeds == 0) { + db_query($link, "DELETE FROM ttrss_feed_categories + WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); + } else { + + print "
+ Unable to delete non empty feed categories.
"; + + } + + db_query($link, "COMMIT"); + } + } + } + + print "
+   +
"; + + $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories + WHERE owner_uid = ".$_SESSION["uid"]." + ORDER BY title"); + + print "

"; + + if (db_num_rows($result) != 0) { + + print ""; + + print ""; + + print "
+ Select: + All, + None +
"; + + print "

"; + + print "
"; + + print ""; + +/* print " + + "; */ + + $lnum = 0; + + while ($line = db_fetch_assoc($result)) { + + $class = ($lnum % 2) ? "even" : "odd"; + + $cat_id = $line["id"]; + + $edit_cat_id = $_GET["id"]; + + if ($action == "edit" && $cat_id != $edit_cat_id) { + $class .= "Grayed"; + $this_row_id = ""; + } else { + $this_row_id = "id=\"FCATR-$cat_id\""; + } + + print ""; + + $edit_title = htmlspecialchars(db_unescape_string($line["title"])); + + if (!$edit_cat_id || $action != "edit") { + + print ""; + + print ""; + + } else if ($cat_id != $edit_cat_id) { + + print ""; + + print ""; + + } else { + + print ""; + + print ""; + + } + + print ""; + + ++$lnum; + } + + print "
 Title
" . + $edit_title . "$edit_title"; + + print ""; + print ""; + print ""; + print ""; + + print "
"; + + print "
"; + + print "
"; + + print "
+
"; + + print "
"; + + if ($action == "edit") { + print " + "; + } else { + + print " + + "; + + } + + print "
"; + + } else { + print "

No feed categories defined.

"; + } + + print "
"; + + return; + + } + if ($quiet) return; // print "

Edit Feeds

"; @@ -810,8 +1019,18 @@ } - print " -  All feeds: "; + + if (get_pref($link, 'ENABLE_FEED_CATS')) { + + print " "; + + print " | "; + + } + + print "All feeds: "; } @@ -821,7 +1040,8 @@ } - if (get_pref($link, 'ENABLE_FEED_CATS')) { + +/* if (get_pref($link, 'ENABLE_FEED_CATS')) { print "

Edit Categories

"; @@ -936,7 +1156,7 @@ } else { print "

No feed categories defined.

"; } - } + } */ print "

Import OPML

diff --git a/prefs.js b/prefs.js index da8a4c3e..d9c10d69 100644 --- a/prefs.js +++ b/prefs.js @@ -245,9 +245,9 @@ function addFeedCat() { } else { notify("Adding feed category..."); - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" + param_escape(cat.value), true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); link.value = ""; @@ -365,9 +365,9 @@ function editFeedCat(cat) { active_feed_cat = cat; - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" + param_escape(cat), true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); } @@ -549,9 +549,9 @@ function removeSelectedFeedCats() { if (ok) { notify("Removing selected categories..."); - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+ + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+ param_escape(sel_rows.toString()), true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); } @@ -589,8 +589,8 @@ function feedCatEditCancel() { // notify("Operation cancelled."); - xmlhttp.open("GET", "backend.php?op=pref-feeds", true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); return false; @@ -637,7 +637,7 @@ function feedCatEditSave() { var query = Form.serialize("feed_cat_edit_form"); xmlhttp.open("GET", "backend.php?" + query, true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); active_feed_cat = false; @@ -1435,7 +1435,7 @@ function selectPrefRows(kind, select) { } else if (kind == "fcat") { opbarid = "catOpToolbar"; nrow = "FCATR-"; - nchk = "FCHK-"; + nchk = "FCCHK-"; lname = "prefFeedCatList"; } else if (kind == "filter") { opbarid = "filterOpToolbar"; @@ -1542,3 +1542,14 @@ function userSwitch() { var user = chooser[chooser.selectedIndex].value; window.location = "prefs.php?swu=" + user; } + +function editFeedCats() { + if (!xmlhttp_ready(xmlhttp)) { + printLockingError(); + return + } + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); + xmlhttp.onreadystatechange=infobox_callback; + xmlhttp.send(null); +} diff --git a/themes/compat/theme.css b/themes/compat/theme.css index 7fcf0fad..94bade82 100644 --- a/themes/compat/theme.css +++ b/themes/compat/theme.css @@ -315,6 +315,10 @@ tr.title td a:hover { color : #5050aa; } +div.prefFeedCatHolder { + border : 1px solid #c0c0c0; +} + table.prefFeedList td.feedEditCat { font-size : large; border-color : #c0c0c0; diff --git a/themes/graycube/theme.css b/themes/graycube/theme.css index 71bacfa9..a22f7010 100644 --- a/themes/graycube/theme.css +++ b/themes/graycube/theme.css @@ -125,15 +125,16 @@ div.postReply > div.postHeader { } .evenGrayed, .evenGrayed td { - background-color : white; - color : #909090; - border-width : 1px 0px 1px 0px; - border-style : solid; - border-color : #ebebeb; + background-color : #f9f9f9; + color : gray; + border-width : 1px 0px 1px 0px; + border-style : solid; + border-color : #ebebeb; } .oddGrayed { - color : #909090; + color : gray; + background-color : #f9f9f9; } .even, .even td { @@ -218,6 +219,10 @@ li.tagUnreadSelected a { color : gray; } +div.prefFeedCatHolder { + border : 1px solid #999999; +} + table.prefFeedList td.feedEditCat { font-weight : bold; border-width : 0px 0px 1px 0px; diff --git a/tt-rss.css b/tt-rss.css index b74aa487..a24a7968 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -412,6 +412,13 @@ table.prefFeedList td.feedSelect { text-align : center; } +div.prefFeedCatHolder { + height : 250px; + overflow : auto; + border : 1px solid #88b0f0; + margin : 5px 0px 5px 0px; +} + a.helpLink { color : #808080; } @@ -465,8 +472,9 @@ div.helpResponse { } div.infoBoxContents { - padding : 5px; + padding : 10px; margin-bottom : 5px; + font-size : small; } div.infoBoxContents td { -- 2.39.2