]> git.wh0rd.org Git - tt-rss.git/commitdiff
api: add getFeedTree
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 28 Mar 2013 07:04:15 +0000 (11:04 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 28 Mar 2013 07:04:27 +0000 (11:04 +0400)
api/index.php
classes/api.php
classes/pref/feeds.php

index a1143a1dc349e5e8afd708b26c7e6c1461f9d636..50703175b9a28f8cc68a9013a2bd873ff0578f41 100644 (file)
@@ -49,6 +49,8 @@
        if ($_REQUEST["sid"]) {
                session_id($_REQUEST["sid"]);
                @session_start();
+       } else if (defined('_API_DEBUG_HTTP_ENABLED')) {
+               @session_start();
        }
 
        if (!init_connection($link)) return;
index 2b9c3a148c8620be561c5bd304571977799742c9..1efa3865f5d3ae96b4b787818cd9d2e7f8f4b8b5 100644 (file)
@@ -704,6 +704,20 @@ class API extends Handler {
                }
        }
 
+       function getFeedTree() {
+               $pf = new Pref_Feeds($this->link, $_REQUEST);
+
+               $_REQUEST['mode'] = 2;
+
+               if ($pf){
+                       $data = $pf->makefeedtree();
+                       print $this->wrap(self::STATUS_OK, array("categories" => $data));
+               } else {
+                       print $this->wrap(self::STATUS_ERR, array("error" =>
+                               'UNABLE_TO_INSTANTIATE_OBJECT'));
+               }
+
+       }
 }
 
 ?>
index d2e69c502e7238aeaafa9bf3b6cd53e4a973a2fb..cd208335bb5be546eb64aea8caaab7ebfa4b6d73 100644 (file)
@@ -87,6 +87,10 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function getfeedtree() {
+               print json_encode($this->makefeedtree());
+       }
+
+       function makefeedtree() {
 
                if ($_REQUEST['mode'] != 2)
                        $search = $_SESSION["prefs_feed_search"];
@@ -284,8 +288,7 @@ class Pref_Feeds extends Handler_Protected {
                        $fl['items'] =& $root['items'];
                }
 
-               print json_encode($fl);
-               return;
+               return $fl;
        }
 
        function catsortreset() {