]> git.wh0rd.org Git - tt-rss.git/commitdiff
mobile: implement pagination for headlines
authorAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 12:08:38 +0000 (15:08 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 12:08:38 +0000 (15:08 +0300)
mobile/feed.php
mobile/functions.php

index 610dd6adf88cb8066258fd80499d3fdb6587b64f..02461b3f6407824357f59f7c84bcb28ee6a04154 100644 (file)
@@ -22,7 +22,8 @@
 
        $feed_id = db_escape_string($_REQUEST["id"]);
        $cat_id = db_escape_string($_REQUEST["cat"]);
+       $offset = (int) db_escape_string($_REQUEST["skip"]);
 
-       render_headlines_list($link, $feed_id, $cat_id);
+       render_headlines_list($link, $feed_id, $cat_id, $offset);
 ?>
 
index 20accdc5e7905a7cf59f0613478c5d3de21bfff2..4880e1f57904e1069761b0123ca8fc1f80ec4559 100644 (file)
                print "</ul>";
        }
 
-       function render_headlines_list($link, $feed_id, $cat_id) {
+       function render_headlines_list($link, $feed_id, $cat_id, $offset) {
 
                $feed_id = $feed_id;
-               $limit = 30;
+               $limit = 15;
                $filter = '';
                $is_cat = false;
                $view_mode = 'adaptive';
                $search = '';
                $search_mode = '';
                $match_on = '';
-                       
+
                $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, 
-                       $view_mode, $is_cat, $search, $search_mode, $match_on);
+                       $view_mode, $is_cat, $search, $search_mode, $match_on, false, $offset);
 
                $result = $qfh_ret[0];
                $feed_title = $qfh_ret[1];
 
-               if ($cat_id) {
-                       $cat_title = getCategoryTitle($link, $cat_id);
+               if (!$offset) {
+                       if ($cat_id) {
+                               $cat_title = getCategoryTitle($link, $cat_id);
 
-                       print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
-                               myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>";
-               } else {
-                       print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
-                               myBackLabel='".__("Home")."' myBackHref='home.php'>";
+                               print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
+                                       myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>";
+                       } else {
+                               print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
+                                       myBackLabel='".__("Home")."' myBackHref='home.php'>";
+                       }
                }
 
+               $num_headlines = 0;
+
                while ($line = db_fetch_assoc($result)) {
                        $id = $line["id"];
                        $real_feed_id = $line["feed_id"];
                        print $line["title"];
                        print "</a></li>";
 
+                       ++$num_headlines;
+
                }
 
-               print "</ul>";
+//             print "<a target='_replace' href='feed.php?id=$feed_id&cat=$cat_id&skip=0'>Next $limit articles...</a>";
+
+               $next_offset = $offset + $num_headlines;
+               $num_unread = getFeedUnread($link, $feed_id, $is_cat);
+
+               /* FIXME needs normal implementation */
+
+               if ($num_unread == 0 || $num_unread > $next_offset) {
+                       print "<li><a href=\"feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset\" 
+                               target=\"_replace\">Get more articles...</a></li>";
+               }
+
+               if (!$offset) print "</ul>";
 
        }