Paginator/SlidingWithBorder: use less space

Showing less items right now. It would be great if we could steer
this by parameter. IMO we should also think about dropping ZF
pagination and use a custom tiny widget.
This commit is contained in:
Thomas Gelf 2014-06-20 17:31:32 +02:00
parent 45fa8ca225
commit 3e24a2cbe4
1 changed files with 29 additions and 16 deletions

View File

@ -43,6 +43,7 @@ class Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder implements Zend_Pagi
*/
public function getPages(Zend_Paginator $paginator, $pageRange = null)
{
// This is unused
if ($pageRange === null) {
$pageRange = $paginator->getPageRange();
}
@ -51,40 +52,52 @@ class Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder implements Zend_Pagi
$pageCount = count($paginator);
$range = array();
if ($pageCount < 15) {
for ($i = 1; $i < 15; $i++) {
if ($pageCount < 10) {
// Show all pages if we have less than 10.
for ($i = 1; $i < 10; $i++) {
if ($i > $pageCount) {
break;
}
$range[$i] = $i;
}
} else {
// More than 10 pages:
foreach (array(1, 2) as $i) {
$range[$i] = $i;
}
if ($pageNumber > 8) {
$range[] = '...';
$start = 5;
if ($pageCount - $pageNumber < 8) {
$start = 9 - ($pageCount - $pageNumber);
if ($pageNumber < 6 ) {
// We are on page 1-5 from
for ($i = 1; $i <= 7; $i++) {
$range[$i] = $i;
}
for ($i = $pageNumber - $start; $i < $pageNumber + (10 - $start); $i++) {
} else {
// Current page > 5
$range[] = '...';
// Less than 5 pages left
if (($pageCount - $pageNumber) < 5) {
$start = 5 - ($pageCount - $pageNumber);
} else {
$start = 1;
}
for ($i = $pageNumber - $start; $i < ($pageNumber + (4 - $start)); $i++) {
if ($i > $pageCount) {
break;
}
$range[$i] = $i;
}
} else {
for ($i = 3; $i <= 10; $i++) {
$range[$i] = $i;
}
}
if ($pageNumber < ($pageCount - 7)) {
if ($pageNumber < ($pageCount - 2)) {
$range[] = '...';
foreach (array($pageCount - 1, $pageCount) as $i) {
$range[$i] = $i;
}
}
foreach (array($pageCount - 1, $pageCount) as $i) {
$range[$i] = $i;
}
}
if (empty($range)) {
$range[] = 1;