From ef88b1cca37705b97e939ac7fc500aff0b646dbf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 13 Jan 2010 13:44:20 +0300 Subject: feed archive and feed browser improvements --- modules/backend-rpc.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++- modules/popup-dialog.php | 56 +++++++++++++++++++++++++++++++++++ modules/pref-feeds.php | 54 ++++++++++++++++++++++------------ 3 files changed, 167 insertions(+), 19 deletions(-) (limited to 'modules') diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index e10a20de3..1e0732ef8 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -3,6 +3,28 @@ $subop = $_REQUEST["subop"]; + if ($subop == "remarchive") { + $ids = split(",", db_escape_string($_REQUEST["ids"])); + + print ""; + + foreach ($ids as $id) { + $result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE + (SELECT COUNT(*) FROM ttrss_user_entries + WHERE orig_feed_id = '$id') = 0 AND + id = '$id' AND owner_uid = ".$_SESSION["uid"]); + + $rc = db_affected_rows($link, $result); + + print ""; + + } + + print ""; + + return; + } + if ($subop == "addfeed") { $feed = db_escape_string($_REQUEST['feed']); @@ -569,7 +591,7 @@ return; } - if ($subop == "feedBrowser") { + if ($subop == "updateFeedBrowser") { $search = db_escape_string($_REQUEST["search"]); $limit = db_escape_string($_REQUEST["limit"]); @@ -582,11 +604,63 @@ print "]]>"; print ""; print ""; + print ""; print ""; return; } + + if ($subop == "massSubscribe") { + + $ids = split(",", db_escape_string($_REQUEST["ids"])); + $mode = $_REQUEST["mode"]; + + $subscribed = array(); + + foreach ($ids as $id) { + + if ($mode == 1) { + $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds + WHERE id = '$id'"); + } else if ($mode == 2) { + $result = db_query($link, "SELECT * FROM ttrss_archived_feeds + WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); + $orig_id = db_escape_string(db_fetch_result($result, 0, "id")); + $site_url = db_escape_string(db_fetch_result($result, 0, "site_url")); + } + + $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url")); + $title = db_escape_string(db_fetch_result($result, 0, "title")); + + $title_orig = db_fetch_result($result, 0, "title"); + + $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE + feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); + + if (db_num_rows($result) == 0) { + if ($mode == 1) { + $result = db_query($link, + "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) + VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); + } else if ($mode == 2) { + $result = db_query($link, + "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url) + VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')"); + } + array_push($subscribed, $title_orig); + } + } + + $num_feeds = count($subscribed); + + print ""; + print ""; + print ""; + + return; + } + if ($subop == "download") { $stage = (int) $_REQUEST["stage"]; $cidt = (int)db_escape_string($_REQUEST["cidt"]); diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index b5aae1846..c3285fb0c 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -142,6 +142,62 @@ return; } + if ($id == "feedBrowser") { + + print "
".__('Feed Browser')."
"; + + print "
"; + + $browser_search = db_escape_string($_REQUEST["search"]); + + print "
"; + + print ""; + print ""; + + print " +
+ + + +
"; + + print " "; + + print __("limit:"); + + print " "; + + print "

"; + + $owner_uid = $_SESSION["uid"]; + + print "

    "; + print_feed_browser($link, $search, 25); + print "
"; + + print "
+ + +
"; + + print "
"; + return; + } + if ($id == "search") { print "
".__('Search')."
"; diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 9d33461af..531396cf5 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -15,7 +15,7 @@ $quiet = $_REQUEST["quiet"]; $mode = $_REQUEST["mode"]; - if ($subop == "massSubscribe") { +/* if ($subop == "massSubscribe") { $ids = split(",", db_escape_string($_REQUEST["ids"])); $subscribed = array(); @@ -65,9 +65,11 @@ print format_notice($msg); } - } - if ($subop == "browse") { + return; + } */ + +/* if ($subop == "browse") { print "
".__('Feed Browser')."
"; @@ -118,7 +120,7 @@ print ""; return; - } + } */ if ($subop == "editfeed") { $feed_id = db_escape_string($_REQUEST["id"]); @@ -1437,8 +1439,12 @@ AND owner_uid = '$owner_uid') $search_qpart ORDER BY subscribers DESC LIMIT $limit"); } else if ($mode == 2) { - $result = db_query($link, "SELECT * FROM - ttrss_archived_feeds WHERE + $result = db_query($link, "SELECT *, + (SELECT COUNT(*) FROM ttrss_user_entries WHERE + orig_feed_id = ttrss_archived_feeds.id) AS articles_archived + FROM + ttrss_archived_feeds + WHERE (SELECT COUNT(*) FROM ttrss_feeds WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND owner_uid = '$owner_uid') = 0 AND @@ -1452,7 +1458,7 @@ if ($mode == 1) { - $feed_url = $line["feed_url"]; + $feed_url = htmlspecialchars($line["feed_url"]); $subscribers = $line["subscribers"]; $det_result = db_query($link, "SELECT site_url,title,id @@ -1469,26 +1475,30 @@ $feed_icon = ""; } - $check_box = ""; $class = ($feedctr % 2) ? "even" : "odd"; if ($details["site_url"]) { - $site_url = " + $site_url = " www"; } else { $site_url = ""; } - print "
  • $check_box". - "$feed_icon " . $details["title"] . + print "
  • $check_box". + "$feed_icon " . htmlspecialchars($details["title"]) . " ($subscribers) - $site_url -
  • "; + $site_url"; } else if ($mode == 2) { - $feed_url = $line["feed_url"]; + $feed_url = htmlspecialchars($line["feed_url"]); + $site_url = htmlspecialchars($line["site_url"]); + $title = htmlspecialchars($line["title"]); $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico"; @@ -1503,16 +1513,24 @@ type=\"checkbox\" id=\"FBCHK-" . $line["id"] . "\">"; $class = ($feedctr % 2) ? "even" : "odd"; - + + if ($line['articles_archived'] > 0) { + $archived = sprintf(__("%d archived articles"), $line['articles_archived']); + $archived = " ($archived)"; + } else { + $archived = ''; + } + if ($line["site_url"]) { - $site_url = " + $site_url = " www"; } else { $site_url = ""; } - print "
  • $check_box". - "$feed_icon " . $line["title"] . $site_url . "
  • "; + print "
  • ". + $check_box . "$feed_icon " . $title . $archived . $site_url . "
  • "; } -- cgit v1.2.3-54-g00ecf