Merge branch 'master' into feature/user-and-group-management-8826
Conflicts: library/Icinga/Data/SimpleQuery.php
This commit is contained in:
commit
28a28a89d3
|
@ -5,9 +5,12 @@ namespace Icinga\Data;
|
||||||
|
|
||||||
use Iterator;
|
use Iterator;
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
|
use Zend_Paginator;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||||
|
|
||||||
class SimpleQuery implements QueryInterface, Queryable, Iterator
|
class SimpleQuery implements QueryInterface, Queryable, Iterator
|
||||||
{
|
{
|
||||||
|
@ -410,6 +413,43 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
|
||||||
return $this->limitOffset;
|
return $this->limitOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paginate data
|
||||||
|
*
|
||||||
|
* Auto-detects pagination parameters from request when unset
|
||||||
|
*
|
||||||
|
* @param int $itemsPerPage Number of items per page
|
||||||
|
* @param int $pageNumber Current page number
|
||||||
|
*
|
||||||
|
* @return Zend_Paginator
|
||||||
|
*
|
||||||
|
* @deprecated Use Icinga\Web\Controller::setupPaginationControl() and/or Icinga\Web\Widget\Paginator instead
|
||||||
|
*/
|
||||||
|
public function paginate($itemsPerPage = null, $pageNumber = null)
|
||||||
|
{
|
||||||
|
trigger_error(
|
||||||
|
'SimpleQuery::paginate() is deprecated. Use Icinga\Web\Controller::setupPaginationControl()'
|
||||||
|
. ' and/or Icinga\Web\Widget\Paginator instead',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($itemsPerPage === null || $pageNumber === null) {
|
||||||
|
// Detect parameters from request
|
||||||
|
$request = Icinga::app()->getFrontController()->getRequest();
|
||||||
|
if ($itemsPerPage === null) {
|
||||||
|
$itemsPerPage = $request->getParam('limit', 25);
|
||||||
|
}
|
||||||
|
if ($pageNumber === null) {
|
||||||
|
$pageNumber = $request->getParam('page', 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->limit($itemsPerPage, $pageNumber * $itemsPerPage);
|
||||||
|
$paginator = new Zend_Paginator(new QueryAdapter($this));
|
||||||
|
$paginator->setItemCountPerPage($itemsPerPage);
|
||||||
|
$paginator->setCurrentPageNumber($pageNumber);
|
||||||
|
return $paginator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an array containing all rows of the result set
|
* Retrieve an array containing all rows of the result set
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue