bludit/kernel/boot/rules/99.paginator.php
2015-07-24 00:28:25 -03:00

40 lines
1.0 KiB
PHP

<?php defined('BLUDIT') or die('Bludit CMS.');
// Current page number.
$currentPage = $Url->pageNumber();
Paginator::set('currentPage', $currentPage);
// Number of pages.
if($Url->whereAmI()=='admin') {
$postPerPage = POSTS_PER_PAGE_ADMIN;
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
}
else {
$postPerPage = $Site->postsPerPage();
$numberOfPosts = $dbPosts->numberPost(false); // published
}
// Post per page.
Paginator::set('postPerPage', $postPerPage);
// Number of posts
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);