2015-09-07 09:06:40 +02:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */
|
2015-09-07 09:06:40 +02:00
|
|
|
|
|
|
|
namespace Icinga\Web\Navigation;
|
|
|
|
|
|
|
|
use Icinga\Web\Url;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A dashboard pane
|
|
|
|
*/
|
|
|
|
class DashboardPane extends NavigationItem
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* This pane's dashlets
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $dashlets;
|
|
|
|
|
2016-04-26 13:50:02 +02:00
|
|
|
protected $disabled;
|
|
|
|
|
2015-09-07 09:06:40 +02:00
|
|
|
/**
|
|
|
|
* Set this pane's dashlets
|
|
|
|
*
|
|
|
|
* @param array $dashlets
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setDashlets(array $dashlets)
|
|
|
|
{
|
|
|
|
$this->dashlets = $dashlets;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return this pane's dashlets
|
|
|
|
*
|
2015-09-17 08:25:17 +02:00
|
|
|
* @param bool $ordered Whether to order the dashlets first
|
2015-09-16 15:31:41 +02:00
|
|
|
*
|
2015-09-07 09:06:40 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
2015-09-17 08:25:17 +02:00
|
|
|
public function getDashlets($ordered = true)
|
2015-09-07 09:06:40 +02:00
|
|
|
{
|
2015-09-16 15:31:41 +02:00
|
|
|
if ($this->dashlets === null) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2015-09-17 08:25:17 +02:00
|
|
|
if ($ordered) {
|
2015-10-01 17:35:11 +02:00
|
|
|
$dashlets = $this->dashlets;
|
|
|
|
ksort($dashlets);
|
|
|
|
return $dashlets;
|
2015-09-16 15:31:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->dashlets;
|
2015-09-07 09:06:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->setUrl(Url::fromPath('dashboard', array('pane' => $this->getName())));
|
|
|
|
}
|
2015-09-07 13:21:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function merge(NavigationItem $item)
|
|
|
|
{
|
|
|
|
parent::merge($item);
|
|
|
|
|
|
|
|
$this->setDashlets(array_merge(
|
2015-09-16 15:31:41 +02:00
|
|
|
$this->getDashlets(false),
|
|
|
|
$item->getDashlets(false)
|
2015-09-07 13:21:31 +02:00
|
|
|
));
|
|
|
|
}
|
2016-04-26 13:50:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set disabled state for pane
|
|
|
|
*
|
|
|
|
* @param bool $disabled
|
|
|
|
*/
|
2017-01-27 14:48:59 +01:00
|
|
|
public function setDisabled($disabled = true)
|
2016-04-26 13:50:02 +02:00
|
|
|
{
|
|
|
|
$this->disabled = (bool) $disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get disabled state for pane
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getDisabled()
|
|
|
|
{
|
|
|
|
return $this->disabled;
|
|
|
|
}
|
2015-09-07 09:06:40 +02:00
|
|
|
}
|