icingaweb2/application/views/scripts/mixedPagination.phtml

94 lines
2.2 KiB
PHTML

<?php
use Icinga\Web\Url;
// Please note that there is a reason for the strange way of writing ><.
// It was the best compromise that came to my mind to get rid of whitespaces
// between inline-block elements. Found no better hack - and table-cell seems
// to be less supported.
if ($this->pageCount <= 1) return;
?><p id="<?= $this->protectId('paginationlabel'); ?>" class="audible"><?= t('Pagination') ?></p>
<ul class="pagination" aria-labelledby="<?= $this->protectId('paginationlabel'); ?>" role="navigation"
<?php
$fromto = t('Show rows %u to %u out of %u');
$total = $this->totalItemCount;
$limit = $this->itemCountPerPage;
$title_prev = sprintf(
$fromto,
($this->current - 2) * $limit + 1,
($this->current - 1) * $limit,
$total
);
$title_next = sprintf(
$fromto,
($this->current) * $limit + 1,
($this->current + 1) * $limit,
$total
);
$li = ' ><li%1$s><span class="audible">'
. t('Page')
. ' </span><a href="%2$s" aria-label="%3$s" title="%3$s">%4$s</a></li
';
?>
<?php
if (isset($this->previous)) {
printf(
$li,
'',
Url::fromRequest()->overwriteParams(
array('page' => $this->previous)
)->getAbsoluteUrl(),
$title_prev,
'« ' . t('Prev')
);
} else {
echo ' ><li class="disabled"><span>« ' . t('Prev') . '</span></li';
}
foreach ($this->pagesInRange as $page) {
$start = ($page - 1) * $limit + 1;
$end = $page * $limit;
if ($end > $total) {
$end = $total;
}
$title = sprintf($fromto, $start, $end, $total);
$class = $page === $this->current ? ' class="active"' : '';
if ($page === '...') {
echo ' ><li class="disabled"><span>...</span></li';
} else {
printf(
$li,
$class,
Url::fromRequest()->overwriteParams(
array('page' => $page)
),
$title,
$page
);
}
}
if (isset($this->next)) {
printf(
$li,
'',
Url::fromRequest()->overwriteParams(
array('page' => $this->next)
)->getAbsoluteUrl(),
$title_next,
t('Next') . ' »'
);
} else {
echo ' ><li class="disabled"><span>' . t('Next') . ' »</span></li';
}
?>
></ul>