mobile: implement pagination for headlines

master
Andrew Dolgov 15 years ago
parent c6dbeedc44
commit 78d7a96559

@ -22,7 +22,8 @@
$feed_id = db_escape_string($_REQUEST["id"]); $feed_id = db_escape_string($_REQUEST["id"]);
$cat_id = db_escape_string($_REQUEST["cat"]); $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);
?> ?>

@ -284,10 +284,10 @@
print "</ul>"; 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; $feed_id = $feed_id;
$limit = 30; $limit = 15;
$filter = ''; $filter = '';
$is_cat = false; $is_cat = false;
$view_mode = 'adaptive'; $view_mode = 'adaptive';
@ -297,23 +297,27 @@
$search = ''; $search = '';
$search_mode = ''; $search_mode = '';
$match_on = ''; $match_on = '';
$qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, $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]; $result = $qfh_ret[0];
$feed_title = $qfh_ret[1]; $feed_title = $qfh_ret[1];
if ($cat_id) { if (!$offset) {
$cat_title = getCategoryTitle($link, $cat_id); if ($cat_id) {
$cat_title = getCategoryTitle($link, $cat_id);
print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>"; myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>";
} else { } else {
print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
myBackLabel='".__("Home")."' myBackHref='home.php'>"; myBackLabel='".__("Home")."' myBackHref='home.php'>";
}
} }
$num_headlines = 0;
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
$id = $line["id"]; $id = $line["id"];
$real_feed_id = $line["feed_id"]; $real_feed_id = $line["feed_id"];
@ -335,9 +339,23 @@
print $line["title"]; print $line["title"];
print "</a></li>"; 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>";
} }

Loading…
Cancel
Save