]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
tweak display of tweet button
[tt-rss.git] / backend.php
index c19c3b9e3d393c29318a892c33cf78b72fc61cd5..c64ceaa977fef9b427f12311663e53d5dd331e34 100644 (file)
@@ -50,7 +50,8 @@
 
        if ((!$op || $op == "rpc" || $op == "rss" || 
                        ($op == "view" && $mode != "zoom") || 
-                       $op == "digestSend" || $op == "viewfeed" || $op == "publish" ||
+                       $op == "digestSend" || $op == "dlg" || 
+                       $op == "viewfeed" || $op == "publish" ||
                        $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
                                header("Content-Type: application/xml; charset=utf-8");
 
        $update_methods = array(
                0   => __("Default"),
                1   => __("Magpie"),
-               2   => __("SimplePie"));
+               2   => __("SimplePie"), 
+               3   => __("Twitter OAuth"));
 
        if (DEFAULT_UPDATE_METHOD == "1") {
                $update_methods[0] .= ' (SimplePie)';
                break; // rpc
 
                case "feeds":
-                       if (ENABLE_GZIP_OUTPUT) {
-                               ob_start("ob_gzhandler");
-                       }
-
-                       $tags = $_REQUEST["tags"];
-
                        $subop = $_REQUEST["subop"];
+                       $root = (bool)$_REQUEST["root"];
 
                        switch($subop) {
                                case "catchupAll":
 
                                case "collapse":
                                        $cat_id = db_escape_string($_REQUEST["cid"]);
-                                       toggle_collapse_cat($link, $cat_id);
+                                       $mode = (int) db_escape_string($_REQUEST['mode']);
+                                       toggle_collapse_cat($link, $cat_id, $mode);
                                        return;
                                break;
+                       }
 
-                               case "catsortreset":
-                                       db_query($link, "UPDATE ttrss_feed_categories 
-                                                       SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
-                                       return;
-                               break;
-
-                               case "catsort":
-                                       $corder = db_escape_string($_REQUEST["corder"]);
-
-                                       $cats = split(",", $corder);
+                       if (!$root) {
+                               print json_encode(outputFeedList($link));
+                       } else {
 
-                                       for ($i = 0; $i < count($cats); $i++) {
-                                               $cat_id = $cats[$i];
+                               $feeds = outputFeedList($link, false);
 
-                                               if ($cat_id > 0) {
-                                                       db_query($link, "UPDATE ttrss_feed_categories 
-                                                               SET order_id = '$i' WHERE id = '$cat_id' AND
-                                                               owner_uid = " . $_SESSION["uid"]);
-                                               }
-                                       }
+                               $root = array();
+                               $root['id'] = 'root';
+                               $root['name'] = __('Feeds');
+                               $root['items'] = $feeds['items'];
 
-                                       return;
-                               break;
+                               $fl = array();
+                               $fl['identifier'] = 'id';
+                               $fl['label'] = 'name';
+                               $fl['items'] = array($root);
 
+                               print json_encode($fl);
                        }
 
-                       outputFeedList($link, $tags);
                break; // feeds
 
+               case "la":
+                       $id = db_escape_string($_REQUEST['id']);
+
+                       $result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries
+                               WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'");
+
+                       if (db_num_rows($result) == 1) {
+                               $article_url = db_fetch_result($result, 0, 'link');
+                               $article_url = str_replace("\n", "", $article_url);
+
+                               header("Location: $article_url");
+                               return;
+
+                       } else {
+                               print_error(__("Article not found."));
+                       }
+               break;
+
                case "view":
 
                        $id = db_escape_string($_REQUEST["id"]);
                        $mode = db_escape_string($_REQUEST["mode"]);
                        $omode = db_escape_string($_REQUEST["omode"]);
 
-                       print "<reply>";
+                       if ($mode != "zoom") print "<reply>";
 
                        // in prefetch mode we only output requested cids, main article 
                        // just gets marked as read (it already exists in client cache)
                                print "]]></counters>";
                        } */
 
-                       print "</reply>";
+                       if ($mode != "zoom") print "</reply>";
                break; // view
 
                case "viewfeed":
                        }
 
                        if (!$next_unread_feed) {
-                               print "<headlines id=\"$feed\" is_cat=\"$cat_view\"><![CDATA[";
+                               print "<headlines id=\"$feed\" is_cat=\"$cat_view\">";
                        } else {
-                               print "<headlines id=\"$next_unread_feed\" is_cat=\"$cat_view\"><![CDATA[";
+                               print "<headlines id=\"$next_unread_feed\" is_cat=\"$cat_view\">";
                        }
                
                        $override_order = false;
                                        break;
                        }
 
+                       if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
+
                        $ret = outputHeadlinesList($link, $feed, $subop, 
                                $view_mode, $limit, $cat_view, $next_unread_feed, $offset, 
                                $vgroup_last_feed, $override_order);
                        $disable_cache = $ret[3];
                        $vgroup_last_feed = $ret[4];
 
-                       print "]]></headlines>";
+                       print "</headlines>";
+
+                       if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
 
                        //print "<headlines-count value=\"$headlines_count\"/>";
                        //print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);
 
-                       /* if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop || !$offset) {
+                       //if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop) {
+                       if ($subop) {
                                print "<counters><![CDATA[";
                                print json_encode(getAllCounters($link, $omode, $feed));
                                print "]]></counters>";
-                       } */
+                       } 
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);