feed archive and feed browser improvements

master
Andrew Dolgov 15 years ago
parent a5819bb35d
commit ef88b1cca3

@ -2006,11 +2006,7 @@ function getSelectedFeedsFromBrowser() {
function updateFeedBrowser() {
try {
var options = Form.serialize("feed_browser");
var query = "?op=rpc&subop=feedBrowser&" + options;
//notify_progress("Loading, please wait...", true);
var query = Form.serialize("feed_browser");
Element.show('feed_browser_spinner');
@ -2024,10 +2020,17 @@ function updateFeedBrowser() {
var c = $("browseFeedList");
var r = transport.responseXML.getElementsByTagName("content")[0];
var nr = transport.responseXML.getElementsByTagName("num-results")[0];
var mode = transport.responseXML.getElementsByTagName("mode")[0];
if (c && r) {
c.innerHTML = r.firstChild.nodeValue;
}
if (parseInt(mode.getAttribute("value")) == 2) {
Element.show('feed_archive_remove');
} else {
Element.hide('feed_archive_remove');
}
} });
@ -2041,7 +2044,7 @@ function browseFeeds(limit) {
try {
var query = "?op=pref-feeds&subop=browse";
/* var query = "?op=ialog&subop=browse";
notify_progress("Loading, please wait...", true);
@ -2049,7 +2052,9 @@ function browseFeeds(limit) {
parameters: query,
onComplete: function(transport) {
infobox_callback2(transport);
} });
} }); */
displayDlg('feedBrowser');
return false;
} catch (e) {
@ -2169,3 +2174,77 @@ function displayNewContentPrompt(id) {
exception_error("displayNewContentPrompt", e);
}
}
function feedBrowserSubscribe() {
try {
var selected = getSelectedFeedsFromBrowser();
var mode = document.forms['feed_browser'].mode;
mode = mode[mode.selectedIndex].value;
if (selected.length > 0) {
closeInfoBox();
notify_progress("Loading, please wait...", true);
var query = "?op=rpc&subop=massSubscribe&ids="+
param_escape(selected.toString()) + "&mode=" + param_escape(mode);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
var nf = transport.responseXML.getElementsByTagName('num-feeds')[0];
var nf_value = nf.getAttribute("value");
notify_info(__("Subscribed to %d feed(s).").replace("%d", nf_value));
if (inPreferences()) {
updateFeedList();
} else {
setTimeout('updateFeedList(false, false)', 50);
}
} });
} else {
alert(__("No feeds are selected."));
}
} catch (e) {
exception_error("feedBrowserSubscribe", e);
}
}
function feedArchiveRemove() {
try {
var selected = getSelectedFeedsFromBrowser();
if (selected.length > 0) {
var pr = __("Remove selected feeds from archive?");
if (confirm(pr)) {
Element.show('feed_browser_spinner');
var query = "?op=rpc&subop=remarchived&ids=" +
param_escape(selected.toString());;
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
updateFeedBrowser();
} });
}
} else {
alert(__("No feeds are selected."));
}
} catch (e) {
exception_error("feedArchiveRemove", e);
}
}

@ -3,6 +3,28 @@
$subop = $_REQUEST["subop"];
if ($subop == "remarchive") {
$ids = split(",", db_escape_string($_REQUEST["ids"]));
print "<rpc-reply>";
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 "<feed id='$id' rc='$rc'/>";
}
print "</rpc-reply>";
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 "</content>";
print "<num-results value=\"$ctr\"/>";
print "<mode value=\"$mode\"/>";
print "</rpc-reply>";
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 "<rpc-reply>";
print "<num-feeds value='$num_feeds'/>";
print "</rpc-reply>";
return;
}
if ($subop == "download") {
$stage = (int) $_REQUEST["stage"];
$cidt = (int)db_escape_string($_REQUEST["cidt"]);

@ -142,6 +142,62 @@
return;
}
if ($id == "feedBrowser") {
print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
print "<div class=\"infoBoxContents\">";
$browser_search = db_escape_string($_REQUEST["search"]);
print "<form onsubmit='return false;' display='inline'
name='feed_browser' id='feed_browser'>";
print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
print "<input type=\"hidden\" name=\"subop\" value=\"updateFeedBrowser\">";
print "
<div style='float : right'>
<img style='display : none'
id='feed_browser_spinner' src='images/indicator_white.gif'>
<input name=\"search\" size=\"20\" type=\"search\"
onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
<button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
</div>";
print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
<option value='1'>" . __('Popular feeds') . "</option>
<option value='2'>" . __('Feed archive') . "</option>
</select> ";
print __("limit:");
print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
foreach (array(25, 50, 100, 200) as $l) {
$issel = ($l == $limit) ? "selected" : "";
print "<option $issel>$l</option>";
}
print "</select> ";
print "<p>";
$owner_uid = $_SESSION["uid"];
print "<ul class='browseFeedList' id='browseFeedList'>";
print_feed_browser($link, $search, 25);
print "</ul>";
print "<div align='center'>
<button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
<button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove from archive')."</button>
<button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
print "</div>";
return;
}
if ($id == "search") {
print "<div id=\"infoBoxTitle\">".__('Search')."</div>";

@ -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 "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
@ -118,7 +120,7 @@
print "</div>";
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 = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
}
$check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
$check_box = "<input onclick='toggleSelectListRow(this)'
class='feedBrowseCB'
type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
$class = ($feedctr % 2) ? "even" : "odd";
if ($details["site_url"]) {
$site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\">
$site_url = "<a target=\"_blank\" href=\"".
htmlspecialchars($details["site_url"])."\">
<img style='border-width : 0px' src='images/www.png' alt='www'></a>";
} else {
$site_url = "";
}
print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
"$feed_icon " . $details["title"] .
print "<li title=\"".htmlspecialchars($details["site_url"])."\"
class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
"$feed_icon " . htmlspecialchars($details["title"]) .
"&nbsp;<span class='subscribers'>($subscribers)</span>
$site_url
</li>";
$site_url</li>";
} 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 = "&nbsp;<span class='subscribers'>($archived)</span>";
} else {
$archived = '';
}
if ($line["site_url"]) {
$site_url = "<a target=\"_blank\" href=\"".$line["site_url"]."\">
$site_url = "<a target=\"_blank\" href=\"$site_url\">
<img style='border-width : 0px' src='images/www.png' alt='www'></a>";
} else {
$site_url = "";
}
print "<li class='$class' id=\"FBROW-".$line["id"]."\">$check_box".
"$feed_icon " . $line["title"] . $site_url . "</li>";
print "<li title='".$line['site_url']."' class='$class'
id=\"FBROW-".$line["id"]."\">".
$check_box . "$feed_icon " . $title . $archived . $site_url . "</li>";
}

@ -1214,7 +1214,7 @@ function validatePrefsReset() {
}
function feedBrowserSubscribe() {
/*function feedBrowserSubscribe() {
try {
var selected = getSelectedFeedsFromBrowser();
@ -1242,7 +1242,7 @@ function feedBrowserSubscribe() {
} catch (e) {
exception_error("feedBrowserSubscribe", e);
}
}
} */
function updateBigFeedBrowserBtn() {
notify_progress("Loading, please wait...");

@ -1470,39 +1470,6 @@ function visitOfficialSite() {
window.open("http://tt-rss.org/");
}
function feedBrowserSubscribe() {
try {
var selected = getSelectedFeedsFromBrowser();
var mode = document.forms['feed_browser'].mode;
mode = mode[mode.selectedIndex].value;
if (selected.length > 0) {
closeInfoBox();
notify_progress("Loading, please wait...", true);
var query = "?op=pref-feeds&subop=massSubscribe&ids="+
param_escape(selected.toString()) + "&mode=" + param_escape(mode);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
updateFeedList();
} });
} else {
alert(__("No feeds are selected."));
}
} catch (e) {
exception_error("feedBrowserSubscribe", e);
}
}
function inPreferences() {
return false;
}

Loading…
Cancel
Save