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