]> git.wh0rd.org - tt-rss.git/commitdiff
rpc/updateFeedBrowser: use JSON
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:19:32 +0000 (16:19 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:19:40 +0000 (16:19 +0300)
functions.js
modules/backend-rpc.php
modules/popup-dialog.php
modules/pref-feeds.php

index 5dcfe6f3a1a20acdd82252200512bed238a207b3..615d59fc3aec5cf19a17be44c1487f020fc2399b 100644 (file)
@@ -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);
index 3120fb7b3eba8bc2c333728432e9209fe163730b..7c26d2ec47aa940aef8dd94870a8fae2b3e3f496 100644 (file)
                }
 
                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 "<rpc-reply>";
-                       print "<content>";
-                       print "<![CDATA[";
-                       $ctr = print_feed_browser($link, $search, $limit, $mode);
-                       print "]]>";
-                       print "</content>";
-                       print "<num-results value=\"$ctr\"/>";
-                       print "<mode value=\"$mode\"/>";
-                       print "</rpc-reply>";
+                       $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"]));
                                }
                        }
 
-                       $num_feeds = count($subscribed);
-
-                       print "<rpc-reply>";
-                       print "<num-feeds value='$num_feeds'/>";
-                       print "</rpc-reply>";
-
                        return;
                } 
 
index 16b727fd1f5a0a0cac9941c9efa174cadcdd2bf1..6da30521bd1561d51998cfda366156981a702159 100644 (file)
                        $owner_uid = $_SESSION["uid"];
 
                        print "<ul class='browseFeedList' id='browseFeedList'>";
-                       print_feed_browser($link, $search, 25);
+                       print make_feed_browser($link, $search, 25);
                        print "</ul>";
 
                        print "<div align='center'>
index ed320d191a4cab90719aa450bcf690e7beb6cbd7..33d3a43fc8b02c3fe28815a977dce81a21db1520 100644 (file)
 
        }
 
-       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 
                                                style='border-width : 0px; vertical-align : middle' 
                                                src='images/feed-icon-12x12.png'></a>";
 
-                                       print "<li title=\"".htmlspecialchars($details["site_url"])."\" 
+                                       $rv .= "<li title=\"".htmlspecialchars($details["site_url"])."\" 
                                                id=\"FBROW-".$details["id"]."\">$check_box".
                                                "$feed_icon $feed_url " . htmlspecialchars($details["title"]) . 
                                                "&nbsp;<span class='subscribers'>($subscribers)</span>
                                                style='border-width : 0px; vertical-align : middle' 
                                                src='images/feed-icon-12x12.png'></a>";
 
-                                       print "<li title='".$line['site_url']."' class='$class' 
+                                       $rv .= "<li title='".$line['site_url']."' class='$class' 
                                                id=\"FBROW-".$line["id"]."\">".
                                                $check_box . "$feed_icon $feed_url " . $title . 
                                                $archived . $site_url . "</li>";
                        }
 
                        if ($feedctr == 0) {
-                               print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
+                               $rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
                        }
 
-               return $feedctr;
+               return $rv;
 
        }