2015-07-20 05:14:12 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Current page number
|
2015-07-20 05:14:12 +02:00
|
|
|
$currentPage = $Url->pageNumber();
|
|
|
|
Paginator::set('currentPage', $currentPage);
|
|
|
|
|
2015-07-24 05:28:25 +02:00
|
|
|
if($Url->whereAmI()=='admin') {
|
2017-05-16 00:46:20 +02:00
|
|
|
$itemsPerPage = ITEMS_PER_PAGE_ADMIN;
|
|
|
|
$amountOfItems = $dbPages->count(false);
|
2015-07-20 05:14:12 +02:00
|
|
|
}
|
2016-01-17 01:11:58 +01:00
|
|
|
elseif($Url->whereAmI()=='tag') {
|
2017-05-16 00:46:20 +02:00
|
|
|
$itemsPerPage = $Site->itemsPerPage();
|
2016-01-17 01:11:58 +01:00
|
|
|
$tagKey = $Url->slug();
|
2017-05-16 00:46:20 +02:00
|
|
|
$amountOfItems = $dbTags->countPagesByTag($tagKey);
|
|
|
|
}
|
|
|
|
elseif($Url->whereAmI()=='category') {
|
|
|
|
$itemsPerPage = $Site->itemsPerPage();
|
|
|
|
$categoryKey = $Url->slug();
|
|
|
|
$amountOfItems = $dbCategories->countPagesByCategory($categoryKey);
|
2016-01-17 01:11:58 +01:00
|
|
|
}
|
2015-07-20 05:14:12 +02:00
|
|
|
else {
|
2017-05-16 00:46:20 +02:00
|
|
|
$itemsPerPage = $Site->itemsPerPage();
|
|
|
|
$amountOfItems = $dbPages->count(true);
|
2015-07-20 05:14:12 +02:00
|
|
|
}
|
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Items per page
|
|
|
|
Paginator::set('itemsPerPage', $itemsPerPage);
|
2015-07-24 05:28:25 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Amount of items
|
|
|
|
Paginator::set('amountOfItems', $amountOfItems);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Amount of pages
|
2017-05-24 00:48:29 +02:00
|
|
|
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage), 1);
|
2017-05-16 00:46:20 +02:00
|
|
|
Paginator::set('amountOfPages', $amountOfPages);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// TRUE if exists a next page to show
|
|
|
|
$showNext = $amountOfPages > $currentPage;
|
|
|
|
Paginator::set('showNext', $showNext);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// TRUE if exists a previous page to show
|
|
|
|
$showPrev = $currentPage > Paginator::firstPage();
|
|
|
|
Paginator::set('showPrev', $showPrev);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// TRUE if exists a next and previous page to show
|
|
|
|
$showNextPrev = $showNext && $showPrev;
|
|
|
|
Paginator::set('showNextPrev', $showNextPrev);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// Integer with the next page
|
2015-07-20 05:14:12 +02:00
|
|
|
$nextPage = max(0, $currentPage+1);
|
|
|
|
Paginator::set('nextPage', $nextPage);
|
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// Integer with the previous page
|
2017-05-16 00:46:20 +02:00
|
|
|
$prevPage = min($amountOfPages, $currentPage-1);
|
2015-07-20 05:14:12 +02:00
|
|
|
Paginator::set('prevPage', $prevPage);
|