From 4a16bda3d06b2d7e17602e52f3cfc1fd5a2a2a2e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Nov 2010 16:19:32 +0300 Subject: [PATCH] rpc/updateFeedBrowser: use JSON --- functions.js | 18 +++++++----------- modules/backend-rpc.php | 23 +++++------------------ modules/popup-dialog.php | 2 +- modules/pref-feeds.php | 13 +++++++------ 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/functions.js b/functions.js index 5dcfe6f3..615d59fc 100644 --- a/functions.js +++ b/functions.js @@ -1417,12 +1417,6 @@ function feedBrowser() { 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(); } @@ -1446,17 +1440,19 @@ function feedBrowser() { Element.hide('feed_browser_spinner'); 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]; + + var reply = JSON.parse(transport.responseText); + + var r = reply['content']; + var mode = reply['mode']; if (c && r) { - c.innerHTML = r.firstChild.nodeValue; + c.innerHTML = r; } dojo.parser.parse("browseFeedList"); - if (parseInt(mode.getAttribute("value")) == 2) { + if (mode == 2) { Element.show(dijit.byId('feed_archive_remove').domNode); } else { Element.hide(dijit.byId('feed_archive_remove').domNode); diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 3120fb7b..7c26d2ec 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -551,25 +551,18 @@ } if ($subop == "updateFeedBrowser") { + header("Content-Type: text/plain"); $search = db_escape_string($_REQUEST["search"]); $limit = db_escape_string($_REQUEST["limit"]); - $mode = db_escape_string($_REQUEST["mode"]); - - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; + $mode = (int) db_escape_string($_REQUEST["mode"]); + print json_encode(array("content" => + make_feed_browser($link, $search, $limit, $mode), + "mode" => $mode)); return; } - if ($subop == "massSubscribe") { $ids = split(",", db_escape_string($_REQUEST["ids"])); @@ -611,12 +604,6 @@ } } - $num_feeds = count($subscribed); - - print ""; - print ""; - print ""; - return; } diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 16b727fd..6da30521 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -345,7 +345,7 @@ $owner_uid = $_SESSION["uid"]; print ""; print "
diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index ed320d19..33d3a43f 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1362,9 +1362,10 @@ } - function print_feed_browser($link, $search, $limit, $mode = 1) { + function make_feed_browser($link, $search, $limit, $mode = 1) { - $owner_uid = $_SESSION["uid"]; + $owner_uid = $_SESSION["uid"]; + $rv = ''; if ($search) { $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR @@ -1436,7 +1437,7 @@ style='border-width : 0px; vertical-align : middle' src='images/feed-icon-12x12.png'>"; - print "
  • $check_box". "$feed_icon $feed_url " . htmlspecialchars($details["title"]) . " ($subscribers) @@ -1479,7 +1480,7 @@ style='border-width : 0px; vertical-align : middle' src='images/feed-icon-12x12.png'>"; - print "
  • ". $check_box . "$feed_icon $feed_url " . $title . $archived . $site_url . "
  • "; @@ -1491,10 +1492,10 @@ } if ($feedctr == 0) { - print "
  • ".__('No feeds found.')."

  • "; + $rv .= "
  • ".__('No feeds found.')."

  • "; } - return $feedctr; + return $rv; } -- 2.39.5