mobile: implement pagination for headlines

This commit is contained in:
Andrew Dolgov 2009-12-18 15:08:38 +03:00
parent c6dbeedc44
commit 78d7a96559
2 changed files with 32 additions and 13 deletions

View 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);
?>

View File

@ -284,10 +284,10 @@
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';
@ -299,21 +299,25 @@
$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"];
@ -335,9 +339,23 @@
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>";
}