Skip to content

Commit

Permalink
Merge pull request #932 from pupi1985/patch-150
Browse files Browse the repository at this point in the history
Allow pagination of element lists that exceed QA_MAX_LIMIT_START
  • Loading branch information
svivian authored Jul 6, 2023
2 parents 49683b7 + 5931a4c commit 1923789
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions qa-include/app/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -1224,16 +1224,28 @@ function qa_insert_login_links($htmlmessage, $topage = null, $params = null)
* @param $count
* @param $prevnext
* @param array $params
* @param bool $hasmore
* @param bool|int|null $startLimit
* @param null $anchor
* @return array|null
*/
function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $params = array(), $hasmore = false, $anchor = null)
function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $params = array(), $startLimit = QA_MAX_LIMIT_START, $anchor = null)
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

// Backwards compatibility. Changed from boolean to int in v1.8.7
if (is_bool($startLimit)) {
$startLimit = QA_MAX_LIMIT_START;
}

if (is_int($startLimit)) {
$hasmore = $count > $startLimit;
$count = min((int)$count, 1 + $startLimit);
} else { // if $startLimit is null
$hasmore = false;
}

$thispage = 1 + floor($start / $pagesize);
$lastpage = ceil(min((int)$count, 1 + QA_MAX_LIMIT_START) / $pagesize);
$lastpage = ceil((int)$count / $pagesize);

if ($thispage > 1 || $lastpage > $thispage) {
$links = array('label' => qa_lang_html('main/page_label'), 'items' => array());
Expand Down
2 changes: 1 addition & 1 deletion qa-include/pages/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}

$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount,
qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count);
qa_opt('pages_prev_next'), array('q' => $inquery), $start + $gotcount - ($gotcount < $count ? 0 : 1));

if (qa_opt('feed_for_search')) {
$qa_content['feed'] = array(
Expand Down

0 comments on commit 1923789

Please sign in to comment.