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
|
|
|
|
}
|
2016-01-17 01:11:58 +01:00
|
|
|
elseif($Url->whereAmI()=='tag') {
|
|
|
|
$postPerPage = $Site->postsPerPage();
|
|
|
|
$tagKey = $Url->slug();
|
|
|
|
$numberOfPosts = $dbTags->countPostsByTag($tagKey);
|
|
|
|
}
|
2015-07-20 05:14:12 +02:00
|
|
|
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);
|
|
|
|
|
2015-10-31 23:54:42 +01:00
|
|
|
$numberOfPages = (int) max(ceil($numberOfPosts / $postPerPage) -1, 0);
|
2015-07-20 05:14:12 +02:00
|
|
|
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);
|