2013-06-07 11:44:37 +02:00
|
|
|
<?php
|
2013-06-11 11:09:28 +02:00
|
|
|
// @codingStandardsIgnoreStart
|
|
|
|
|
2013-06-11 10:27:44 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-07 11:44:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Zend_Paginator_ScrollingStyle_Interface
|
|
|
|
*/
|
|
|
|
class Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder implements Zend_Paginator_ScrollingStyle_Interface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns an array of "local" pages given a page number and range.
|
2013-06-11 10:27:44 +02:00
|
|
|
*
|
2013-06-07 11:44:37 +02:00
|
|
|
* @param Zend_Paginator $paginator
|
|
|
|
* @param integer $pageRange (Optional) Page range
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getPages(Zend_Paginator $paginator, $pageRange = null)
|
|
|
|
{
|
|
|
|
if ($pageRange === null) {
|
|
|
|
$pageRange = $paginator->getPageRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
$pageNumber = $paginator->getCurrentPageNumber();
|
2013-06-11 10:27:44 +02:00
|
|
|
$pageCount = count($paginator);
|
2013-06-07 11:44:37 +02:00
|
|
|
$range = array();
|
|
|
|
|
|
|
|
if ($pageCount < 15) {
|
|
|
|
for ($i = 1; $i < 15; $i++) {
|
2013-06-11 10:27:44 +02:00
|
|
|
if ($i > $pageCount) {
|
|
|
|
break;
|
|
|
|
}
|
2013-06-07 11:44:37 +02:00
|
|
|
$range[$i] = $i;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (array(1, 2) as $i) {
|
|
|
|
$range[$i] = $i;
|
|
|
|
}
|
|
|
|
if ($pageNumber > 8) {
|
|
|
|
$range[] = '...';
|
|
|
|
$start = 5;
|
|
|
|
if ($pageCount - $pageNumber < 8) {
|
|
|
|
$start = 9 - ($pageCount - $pageNumber);
|
|
|
|
}
|
|
|
|
for ($i = $pageNumber - $start; $i < $pageNumber + (10 - $start); $i++) {
|
2013-06-11 10:27:44 +02:00
|
|
|
if ($i > $pageCount) {
|
|
|
|
break;
|
|
|
|
}
|
2013-06-07 11:44:37 +02:00
|
|
|
$range[$i] = $i;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ($i = 3; $i <= 10; $i++) {
|
|
|
|
$range[$i] = $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($pageNumber < ($pageCount - 7)) {
|
|
|
|
$range[] = '...';
|
|
|
|
foreach (array($pageCount - 1, $pageCount) as $i) {
|
|
|
|
$range[$i] = $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-11 10:27:44 +02:00
|
|
|
if (empty($range)) {
|
|
|
|
$range[] = 1;
|
|
|
|
}
|
2013-06-07 11:44:37 +02:00
|
|
|
return $range;
|
|
|
|
}
|
|
|
|
}
|
2013-06-11 11:09:28 +02:00
|
|
|
|
|
|
|
// @codingStandardsIgnoreEnd
|