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
|
|
|
|
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage) -1, 0);
|
|
|
|
Paginator::set('amountOfPages', $amountOfPages);
|
2015-07-20 05:14:12 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
$showOlder = $amountOfPages > $currentPage;
|
2015-07-20 05:14:12 +02:00
|
|
|
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);
|
|
|
|
|
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);
|