]> git.wh0rd.org Git - tt-rss.git/commitdiff
adds sort order to API
authorj0nson <s.darlington@gmail.com>
Tue, 2 Apr 2013 01:21:36 +0000 (22:21 -0300)
committerj0nson <s.darlington@gmail.com>
Tue, 2 Apr 2013 01:21:36 +0000 (22:21 -0300)
Allows sort by feed date or by reverse order
api Params:
order_by (string = feed_dates, date_reverse)

classes/api.php

index ea57a61ab256b31612f981994a7068e3af40d987..f0f943698b0c15ce893c952569cd9d6d03a42c09 100644 (file)
@@ -198,14 +198,22 @@ class API extends Handler {
                        $since_id = (int)db_escape_string($this->link, $_REQUEST["since_id"]);
                        $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
                        $sanitize_content = true;
-
+                       $override_order = false;
+                       switch ($_REQUEST["order_by"]) {
+                               case "date_reverse":
+                                       $override_order = "date_entered, updated";
+                                       break;
+                               case "feed_dates":
+                                       $override_order = "updated DESC";
+                                       break;
+                       }
                        /* do not rely on params below */
 
                        $search = db_escape_string($this->link, $_REQUEST["search"]);
                        $search_mode = db_escape_string($this->link, $_REQUEST["search_mode"]);
 
                        $headlines = $this->api_get_headlines($this->link, $feed_id, $limit, $offset,
-                               $filter, $is_cat, $show_excerpt, $show_content, $view_mode, false,
+                               $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
                                $include_attachments, $since_id, $search, $search_mode,
                                $include_nested, $sanitize_content);