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}}}
|
2013-06-28 16:47:30 +02:00
|
|
|
/**
|
2013-10-23 15:10:33 +02:00
|
|
|
* This file is part of Icinga Web 2.
|
2013-09-04 18:27:16 +02:00
|
|
|
*
|
2013-10-23 15:10:33 +02:00
|
|
|
* Icinga Web 2 - Head for multiple monitoring backends.
|
2013-06-28 16:47:30 +02:00
|
|
|
* Copyright (C) 2013 Icinga Development Team
|
2013-09-04 18:27:16 +02:00
|
|
|
*
|
2013-06-28 16:47:30 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2013-09-04 18:27:16 +02:00
|
|
|
*
|
2013-06-28 16:47:30 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2013-09-04 18:27:16 +02:00
|
|
|
*
|
2013-06-28 16:47:30 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2013-09-04 18:27:16 +02:00
|
|
|
*
|
2013-10-23 15:10:33 +02:00
|
|
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
|
|
|
* @author Icinga Development Team <info@icinga.org>
|
|
|
|
*
|
2013-06-28 16:47:30 +02:00
|
|
|
*/
|
2013-06-11 10:27:44 +02:00
|
|
|
// {{{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
|
|
|
|
2013-08-07 10:27:50 +02:00
|
|
|
// @codingStandardsIgnoreEnd
|