Rewrite mixedPagination view script

refs #5543
This commit is contained in:
Eric Lippmann 2015-09-25 17:00:53 +02:00
parent 155e54978d
commit bd47909f93
1 changed files with 76 additions and 88 deletions

View File

@ -1,93 +1,81 @@
<?php <?php
use Icinga\Web\Url; 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; 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 <div class="pagination-control" role="navigation">
<h2 id="<?= $this->protectId('pagination') ?>" class="sr-only" tabindex="-1"><?= $this->translate('Pagination') ?></h2>
if (isset($this->previous)) { <ul class="nav nav-tabs">
printf( <?php if (isset($this->previous)): ?>
$li, <?php $label = sprintf(
'', $this->translate('Show rows %u to %u of %u'),
Url::fromRequest()->overwriteParams( ($this->current - 2) * $this->itemCountPerPage + 1,
array('page' => $this->previous) ($this->current - 1) * $this->itemCountPerPage,
)->getAbsoluteUrl(), $this->totalItemCount
$title_prev, ) ?>
'« ' . t('Prev') <li>
); <a href="<?= Url::fromRequest()->overwriteParams(array('page' => $this->previous)) ?>"
} else { title="<?= $label ?>"
echo ' ><li class="disabled"><span>« ' . t('Prev') . '</span></li'; aria-label="<?= $label ?>">
} <?= $this->icon('angle-double-left') ?>
</a>
foreach ($this->pagesInRange as $page) { </li>
$start = ($page - 1) * $limit + 1; <?php else: ?>
$end = $page * $limit; <li class="disabled" aria-hidden="true">
if ($end > $total) { <span>
$end = $total; <span class="sr-only"><?= $this->translate('Previous page') ?></span>
} <?= $this->icon('angle-double-left') ?>
$title = sprintf($fromto, $start, $end, $total); </span>
$class = $page === $this->current ? ' class="active"' : ''; </li>
<?php endif ?>
if ($page === '...') { <?php foreach ($this->pagesInRange as $page): ?>
echo ' ><li class="disabled"><span>...</span></li'; <?php if ($page === '...'): ?>
} else { <li class="disabled">
printf( <span>...</span>
$li, </li>
$class, <?php else: ?>
Url::fromRequest()->overwriteParams( <?php
array('page' => $page) $end = $page * $this->itemCountPerPage;
), if ($end > $this->totalItemCount) {
$title, $end = $this->totalItemCount;
$page }
); $label = sprintf(
} $this->translate('Show rows %u to %u of %u'),
} ($page - 1) * $this->itemCountPerPage + 1,
$end,
if (isset($this->next)) { $this->totalItemCount
printf( );
$li, ?>
'', <li<?= $page === $this->current ? ' class="active"' : '' ?>>
Url::fromRequest()->overwriteParams( <a href="<?= Url::fromRequest()->overwriteParams(array('page' => $page)) ?>"
array('page' => $this->next) title="<?= $label ?>"
)->getAbsoluteUrl(), aria-label="<?= $label ?>">
$title_next, <?= $page ?>
t('Next') . ' »' </a>
); </li>
} else { <?php endif ?>
echo ' ><li class="disabled"><span>' . t('Next') . ' »</span></li'; <?php endforeach ?>
} <?php if (isset($this->next)): ?>
<?php $label = sprintf(
?> $this->translate('Show rows %u to %u of %u'),
></ul> $this->current * $this->itemCountPerPage + 1,
($this->current + 1) * $this->itemCountPerPage,
$this->totalItemCount
) ?>
<li>
<a href="<?= Url::fromRequest()->overwriteParams(array('page' => $this->next)) ?>"
title="<?= $label ?>"
aria-label="<?= $label ?>">
<?= $this->icon('angle-double-right') ?>
</a>
</li>
<?php else: ?>
<li class="disabled" aria-hidden="true">
<span>
<span class="sr-only"><?= $this->translate('Next page') ?></span>
<?= $this->icon('angle-double-right') ?>
</span>
</li>
<?php endif ?>
</ul>
</div>