icingaweb2/application/views/scripts/mixedPagination.phtml

63 lines
1.6 KiB
PHTML
Raw Normal View History

<?php
2013-07-12 13:40:21 +02:00
if ($this->pageCount <= 1) return;
$fromto = $this->translate('%d to %d of %d');
$total = $this->totalItemCount;
2013-07-12 13:40:21 +02:00
$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
);
?>
<ul class="pagination pagination-sm">
<!-- Previous page link -->
2013-07-12 13:40:21 +02:00
<?php if (isset($this->previous)): ?>
<li><a href="<?= $this->url()->setParam('page', $this->previous) ?>" title="<?= $title_prev ?>">« <?= $this->translate('Back') ?></a></li>
2013-07-12 13:40:21 +02:00
<?php else: ?>
<li class="disabled"><span>« <?= $this->translate('Back') ?></span></li>
2013-07-12 13:40:21 +02:00
<?php endif ?>
<!-- Numbered page links -->
<?php
2013-07-12 13:40:21 +02:00
foreach ($this->pagesInRange as $page):
2013-07-12 13:40:21 +02:00
$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 === '...'): ?>
<li class="disabled"><span>...</span></li>
<?php else: ?>
<li <?= $class ?>>
<a href="<?= $this->url()->setParam('page', $page) ?>" title="<?= $title ?>">
<?= $page ?>
</a>
</li>
2013-07-12 13:40:21 +02:00
<?php
endif;
endforeach;
?>
<!-- Next page link -->
<? if (isset($this->next)): ?>
<li><a href="<?= $this->url()->setParam('page', $this->next) ?>" title="<?= $title_next ?>"><?= t('Next') ?> »</a></li>
<? else: ?>
<li class="disabled"><span><?= t('Next') ?> »</span></li>
<? endif ?>
</ul>