]> git.wh0rd.org Git - tt-rss.git/commitdiff
queryFeedHeadlines: move to array-based arguments, optionally check if first element...
authorAndrew Dolgov <noreply@fakecake.org>
Sat, 11 Jul 2015 22:29:36 +0000 (01:29 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sat, 11 Jul 2015 22:29:36 +0000 (01:29 +0300)
classes/api.php
classes/feeds.php
classes/handler/public.php
classes/pref/filters.php
include/functions2.php
js/feedlist.js
js/viewfeed.js
plugins/vf_shared/init.php

index 8267572f442fb646a758350356c3c0fcecce7b0e..1a52c9257edb6d0fccc7764fecd6dac7d3dc0595 100644 (file)
@@ -658,11 +658,30 @@ class API extends Handler {
                                }
                        }
 
-                       $qfh_ret = queryFeedHeadlines($feed_id, $limit,
+                       /*$qfh_ret = queryFeedHeadlines($feed_id, $limit,
                                $view_mode, $is_cat, $search, false,
-                               $order, $offset, 0, false, $since_id, $include_nested);
-
-                       $result = $qfh_ret[0];
+                               $order, $offset, 0, false, $since_id, $include_nested);*/
+
+                       //function queryFeedHeadlines($feed, $limit,
+                       // $view_mode, $cat_view, $search, $search_mode,
+                       // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
+                       // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
+
+                       $params = array(
+                               "feed" => $feed_id,
+                               "limit" => $limit,
+                               "view_mode" => $view_mode,
+                               "cat_view" => $is_cat,
+                               "search" => $search,
+                               "override_order" => $order,
+                               "offset" => $offset,
+                               "since_id" => $since_id,
+                               "include_children" => $include_nested,
+                       );
+
+                       $qfh_ret = queryFeedHeadlines($params);
+
+               $result = $qfh_ret[0];
                        $feed_title = $qfh_ret[1];
 
                        $headlines = array();
index ed66be291a116424bd6e0cff750b9dce9066ef53..15b3f068cbb85574891a8bce03b69dff4793bd78 100644 (file)
@@ -148,7 +148,7 @@ class Feeds extends Handler_Protected {
 
        private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
                                        $next_unread_feed, $offset, $vgr_last_feed = false,
-                                       $override_order = false, $include_children = false) {
+                                       $override_order = false, $include_children = false, $check_top_id = false) {
 
                $disable_cache = false;
 
@@ -232,9 +232,28 @@ class Feeds extends Handler_Protected {
                        }
 
                } else {
-                       $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
+                       /*$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
                                $search, false, $override_order, $offset, 0,
-                               false, 0, $include_children);
+                               false, 0, $include_children, $topid);*/
+
+                       //function queryFeedHeadlines($feed, $limit,
+                       // $view_mode, $cat_view, $search, $search_mode,
+                       // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
+                       // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
+
+                       $params = array(
+                               "feed" => $feed,
+                               "limit" => $limit,
+                               "view_mode" => $view_mode,
+                               "cat_view" => $cat_view,
+                               "search" => $search,
+                               "override_order" => $override_order,
+                               "offset" => $offset,
+                               "include_children" => $include_children,
+                               "check_top_id" => $check_top_id
+                       );
+
+                       $qfh_ret = queryFeedHeadlines($params);
                }
 
                $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
@@ -810,6 +829,7 @@ class Feeds extends Handler_Protected {
                @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
                @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
                $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
+               $check_top_id = $this->dbh->escape_string($_REQUEST["topid"]);
 
                if (is_numeric($feed)) $feed = (int) $feed;
 
@@ -889,7 +909,7 @@ class Feeds extends Handler_Protected {
 
                $ret = $this->format_headlines_list($feed, $method,
                        $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
-                       $vgroup_last_feed, $override_order, true);
+                       $vgroup_last_feed, $override_order, true, $check_top_id);
 
                //$topmost_article_ids = $ret[0];
                $headlines_count = $ret[1];
index 74e837846e18ca0a3cefe94e34207f5b5392a83e..1bf0887011d0248ce8fcaa4da0334b0cdde1bf22 100644 (file)
@@ -37,10 +37,31 @@ class Handler_Public extends Handler {
                        break;
                }
 
-               $qfh_ret = queryFeedHeadlines($feed,
+               /*$qfh_ret = queryFeedHeadlines($feed,
                        1, $view_mode, $is_cat, $search, false,
                        $date_sort_field, $offset, $owner_uid,
-                       false, 0, true, true, false, false, $start_ts);
+                       false, 0, true, true, false, false, $start_ts);*/
+
+               //function queryFeedHeadlines($feed,
+               // $limit, $view_mode, $cat_view, $search, $search_mode,
+               // $override_order = false, $offset = 0, $owner_uid = 0,
+               // $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
+
+               $params = array(
+                       "owner_uid" => $owner_uid,
+                       "feed" => $feed,
+                       "limit" => 1,
+                       "view_mode" => $view_mode,
+                       "cat_view" => $is_cat,
+                       "search" => $search,
+                       "override_order" => $date_sort_field,
+                       "include_children" => true,
+                       "ignore_vfeed_group" => true,
+                       "offset" => $offset,
+                       "start_ts" => $start_ts
+               );
+
+               $qfh_ret = queryFeedHeadlines($params);
 
                $result = $qfh_ret[0];
 
@@ -58,11 +79,26 @@ class Handler_Public extends Handler {
                        header("Last-Modified: $last_modified", true);
                }
 
-               $qfh_ret = queryFeedHeadlines($feed,
+               /*$qfh_ret = queryFeedHeadlines($feed,
                        $limit, $view_mode, $is_cat, $search, false,
                        $date_sort_field, $offset, $owner_uid,
-                       false, 0, true, true, false, false, $start_ts);
-
+                       false, 0, true, true, false, false, $start_ts);*/
+
+               $params = array(
+                       "owner_uid" => $owner_uid,
+                       "feed" => $feed,
+                       "limit" => $limit,
+                       "view_mode" => $view_mode,
+                       "cat_view" => $is_cat,
+                       "search" => $search,
+                       "override_order" => $date_sort_field,
+                       "include_children" => true,
+                       "ignore_vfeed_group" => true,
+                       "offset" => $offset,
+                       "start_ts" => $start_ts
+               );
+
+               $qfh_ret = queryFeedHeadlines($params);
 
                $result = $qfh_ret[0];
                $feed_title = htmlspecialchars($qfh_ret[1]);
@@ -496,7 +532,7 @@ class Handler_Public extends Handler {
                                        </div>
                                        <button type="submit"><?php echo __('Share') ?></button>
                                        <button onclick="return window.close()"><?php echo __('Cancel') ?></button>
-                                       </div>
+                                       </td>
 
                                </form>
                                </td></tr></table>
index 170c1a5277bedd7fb378c23e27102e3cf019970a..5e3c35b7d509702202b8d1209d30d374cde548ad 100644 (file)
@@ -83,9 +83,22 @@ class Pref_Filters extends Handler_Protected {
                        }
                }
 
-               $qfh_ret = queryFeedHeadlines(-4, 30, "", false, false, false,
-                       "date_entered DESC", 0, $_SESSION["uid"], $filter);
-
+               //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode,
+               // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false,
+
+               /*$qfh_ret = queryFeedHeadlines(-4, 30, "", false, false, false,
+                       "date_entered DESC", 0, $_SESSION["uid"], $filter);*/
+
+               $params = array(
+                       "feed" => -4,
+                       "limit" => 30,
+                       "view_mode" => "",
+                       "cat_view" => false,
+                       "override_order" => "date_entered DESC",
+                       "filter" => $filter
+               );
+
+               $qfh_ret = queryFeedHeadlines($params);
                $result = $qfh_ret[0];
 
                $found = 0;
index 133352f75975c44c210d5437f440b3a584efe14a..e4e66acd155cc8679f0847febcdc8fa2c386cecd 100644 (file)
        }
 
        // $search_mode is obsolete/unused
-       function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) {
-
-               if (!$owner_uid) $owner_uid = $_SESSION["uid"];
+       //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
+       function queryFeedHeadlines($params) {
+
+               $feed = $params["feed"];
+               $limit = isset($params["limit"]) ? $params["limit"] : 30;
+               $view_mode = $params["view_mode"];
+               $cat_view = isset($params["cat_view"]) ? $params["cat_view"] : false;
+               $search = isset($params["search"]) ? $params["search"] : false;
+               $override_order = isset($params["override_order"]) ? $params["override_order"] : false;
+               $offset = isset($params["offset"]) ? $params["offset"] : 0;
+               $owner_uid = isset($params["owner_uid"]) ? $params["owner_uid"] : $_SESSION["uid"];
+               $filter = isset($params["filter"]) ? $params["filter"] : 0;
+               $since_id = isset($params["since_id"]) ? $params["since_id"] : 0;
+               $include_children = isset($params["include_children"]) ? $params["include_children"] : false;
+               $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ? $params["ignore_vfeed_group"] : false;
+               $override_strategy = isset($params["override_strategy"]) ? $params["override_strategy"] : false;
+               $override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false;
+               $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false;
+               $check_top_id = isset($params["check_top_id"]) ? $params["check_top_id"] : false;
 
                $ext_tables_part = "";
                $search_words = array();
                                        $start_ts_query_part = "";
                                }
 
+
+                               // if previous topmost article id changed that means our current pagination is no longer valid
+                               if ($check_top_id) {
+                                       $query = "SELECT DISTINCT
+                                                       date_entered,
+                                                       guid,
+                                                       ttrss_entries.id,
+                                                       ttrss_entries.title,
+                                                       updated,
+                                                       score
+                                               FROM
+                                                       $from_qpart
+                                               WHERE
+                                               $feed_check_qpart
+                                               ttrss_user_entries.ref_id = ttrss_entries.id AND
+                                               ttrss_user_entries.owner_uid = '$owner_uid' AND
+                                               $search_query_part
+                                               $start_ts_query_part
+                                               $filter_query_part
+                                               $view_query_part
+                                               $since_id_part
+                                               $query_strategy_part ORDER BY $order_by LIMIT 1";
+
+                                       if ($_REQUEST["debug"]) {
+                                               print $query;
+                                       }
+
+                                       $result = db_query($query);
+                                       if ($result) {
+                                               $current_top_id = db_fetch_result($result, 0, "id");
+
+                                               if ($current_top_id != $check_top_id) {
+                                                       // top changed, bail out
+
+                                                       return array(false, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words);
+                                               }
+                                       }
+                               }
+
                                $query = "SELECT DISTINCT
                                                date_entered,
                                                guid,
index 7c2e08052d41888afa630db048d5d36fc46f5a9d..ffcecc7c4650e1a070bd115adf62bdef7abb0352 100644 (file)
@@ -99,6 +99,10 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req, can_w
                        query = query + "&m=" + param_escape(method);
                }
 
+               if (current_top_article_id && offset > 0) {
+                       query = query + "&topid=" + param_escape(current_top_article_id);
+               }
+
                if (!background) {
                        if (_search_query) {
                                force_nocache = true;
index e346b2967ee46249287c8ff73450b83b7e935357..8bc42aadc802955e88f85be834619a457636489f 100644 (file)
@@ -13,6 +13,7 @@ var catchup_timeout_id = false;
 var cids_requested = [];
 var loaded_article_ids = [];
 var _last_headlines_update = 0;
+var current_top_article_id = false;
 
 var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
 
@@ -83,6 +84,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                        if (infscroll_req == false) {
                                loaded_article_ids = [];
+                               current_top_article_id = false;
 
                                dijit.byId("headlines-frame").attr('content',
                                        reply['headlines']['content']);
@@ -102,6 +104,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                        }
                                });
 
+                               if (loaded_article_ids.size() > 0) {
+                                       current_top_article_id = parseInt(loaded_article_ids[0].replace("RROW-", ""));
+                               }
+
                                var hsp = $("headlines-spacer");
                                if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
                                dijit.byId('headlines-frame').domNode.appendChild(hsp);
index c7eac96593ea3a42a9116808e8c79bbb338672d5..3138c8a7dcb04891c101341c7421d7aa399da792 100644 (file)
@@ -35,7 +35,7 @@ class VF_Shared extends Plugin {
        //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false) {
 
        function get_headlines($feed_id, $options) {
-               $qfh_ret = queryFeedHeadlines(-4,
+               /*$qfh_ret = queryFeedHeadlines(-4,
                        $options['limit'],
                        $this->get_unread(-1) > 0 ? "adaptive" : "all_articles",
                        false,
@@ -49,8 +49,23 @@ class VF_Shared extends Plugin {
                        $options['include_children'],
                        false,
                        "uuid != ''",
-                       "ttrss_feeds.title AS feed_title,");
+                       "ttrss_feeds.title AS feed_title,"); */
 
+               $params = array(
+                       "feed" => -4,
+                       "limit" => $options["limit"],
+                       "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles",
+                       "search" => $options['search'],
+                       "override_order" => $options['override_order'],
+                       "offset" => $options["offset"],
+                       "filter" => $options["filter"],
+                       "since_id" => $options["since_id"],
+                       "include_children" => $options["include_children"],
+                       "override_strategy" => "uuid != ''",
+                       "override_vfeed" => "ttrss_feeds.title AS feed_title,"
+               );
+
+               $qfh_ret = queryFeedHeadlines($params);
                $qfh_ret[1] = __("Shared articles");
 
                return $qfh_ret;