bludit/kernel/boot/rules/99.paginator.php

40 lines
1.0 KiB
PHP
Raw Normal View History

2015-07-20 05:14:12 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
// Current page number.
$currentPage = $Url->pageNumber();
Paginator::set('currentPage', $currentPage);
// Number of pages.
2015-07-24 05:28:25 +02:00
if($Url->whereAmI()=='admin') {
$postPerPage = POSTS_PER_PAGE_ADMIN;
2015-07-20 05:14:12 +02:00
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
}
else {
2015-07-24 05:28:25 +02:00
$postPerPage = $Site->postsPerPage();
2015-07-20 05:14:12 +02:00
$numberOfPosts = $dbPosts->numberPost(false); // published
}
2015-07-24 05:28:25 +02:00
// Post per page.
Paginator::set('postPerPage', $postPerPage);
// Number of posts
2015-07-20 05:14:12 +02:00
Paginator::set('numberOfPosts', $numberOfPosts);
$numberOfPages = (int) ceil($numberOfPosts / $postPerPage) -1;
Paginator::set('numberOfPages', $numberOfPages);
$showOlder = $numberOfPages > $currentPage;
Paginator::set('showOlder', $showOlder);
$showNewer = $currentPage > 0;
Paginator::set('showNewer', $showNewer);
$show = $showNewer && $showOlder;
Paginator::set('show', true);
$nextPage = max(0, $currentPage+1);
Paginator::set('nextPage', $nextPage);
$prevPage = min($numberOfPages, $currentPage-1);
Paginator::set('prevPage', $prevPage);