mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Icinga\Web\Controller: Add helper functions to create control widgets
refs #7876
This commit is contained in:
parent
7735e5d31d
commit
2bd31ee395
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
|
use Zend_Paginator;
|
||||||
use Icinga\Web\Controller\ModuleActionController;
|
use Icinga\Web\Controller\ModuleActionController;
|
||||||
use Icinga\Web\Widget\SortBox;
|
use Icinga\Web\Widget\SortBox;
|
||||||
|
use Icinga\Web\Widget\Limiter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the controller all modules should inherit from
|
* This is the controller all modules should inherit from
|
||||||
@ -16,15 +18,75 @@ class Controller extends ModuleActionController
|
|||||||
/**
|
/**
|
||||||
* Create a SortBox widget at the `sortBox' view property
|
* Create a SortBox widget at the `sortBox' view property
|
||||||
*
|
*
|
||||||
|
* In case the current view has been requested as compact this method does nothing.
|
||||||
|
*
|
||||||
* @param array $columns An array containing the sort columns, with the
|
* @param array $columns An array containing the sort columns, with the
|
||||||
* submit value as the key and the label as the value
|
* submit value as the key and the label as the value
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
protected function setupSortControl(array $columns)
|
protected function setupSortControl(array $columns)
|
||||||
{
|
{
|
||||||
|
if (! $this->view->compact) {
|
||||||
$req = $this->getRequest();
|
$req = $this->getRequest();
|
||||||
$this->view->sortBox = SortBox::create(
|
$this->view->sortBox = SortBox::create(
|
||||||
'sortbox-' . $req->getActionName(),
|
'sortbox-' . $req->getActionName(),
|
||||||
$columns
|
$columns
|
||||||
)->applyRequest($req);
|
)->applyRequest($req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Limiter widget at the `limiter' view property
|
||||||
|
*
|
||||||
|
* In case the current view has been requested as compact this method does nothing.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
protected function setupLimitControl()
|
||||||
|
{
|
||||||
|
if (! $this->view->compact) {
|
||||||
|
$this->view->limiter = new Limiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the view property `paginator' to the given Zend_Paginator
|
||||||
|
*
|
||||||
|
* In case the current view has been requested as compact this method does nothing.
|
||||||
|
*
|
||||||
|
* @param Zend_Paginator $paginator The Zend_Paginator for which to show a pagination control
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
protected function setupPaginationControl(Zend_Paginator $paginator)
|
||||||
|
{
|
||||||
|
if (! $this->view->compact) {
|
||||||
|
$this->view->paginator = $paginator;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the view property `filterEditor' to the given FilterEditor
|
||||||
|
*
|
||||||
|
* In case the current view has been requested as compact this method does nothing.
|
||||||
|
*
|
||||||
|
* @param Form $editor The FilterEditor
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
protected function setupFilterControl($editor)
|
||||||
|
{
|
||||||
|
if (! $this->view->compact) {
|
||||||
|
$this->view->filterEditor = $editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user