mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
parent
dd943c3aa7
commit
0f8d5bddba
@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Exception\ConfigurationError;
|
|
||||||
use Zend_Config;
|
|
||||||
use RecursiveIterator;
|
use RecursiveIterator;
|
||||||
|
use Zend_Config;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
class Menu implements RecursiveIterator
|
class Menu implements RecursiveIterator
|
||||||
{
|
{
|
||||||
@ -278,13 +279,17 @@ class Menu implements RecursiveIterator
|
|||||||
/**
|
/**
|
||||||
* Set the url of this menu
|
* Set the url of this menu
|
||||||
*
|
*
|
||||||
* @param string $url The url to set for this menu
|
* @param Url|string $url The url to set for this menu
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setUrl($url)
|
public function setUrl($url)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
if ($url instanceof Url) {
|
||||||
|
$this->url = $url;
|
||||||
|
} else {
|
||||||
|
$this->url = Url::fromPath($url);
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,11 @@ class MenuRenderer extends RecursiveIteratorIterator
|
|||||||
*/
|
*/
|
||||||
public function __construct(Menu $menu, $url = null)
|
public function __construct(Menu $menu, $url = null)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
if ($url instanceof Url) {
|
||||||
|
$this->url = $url;
|
||||||
|
} else {
|
||||||
|
$this->url = Url::fromPath($url);
|
||||||
|
}
|
||||||
parent::__construct($menu, RecursiveIteratorIterator::CHILD_FIRST);
|
parent::__construct($menu, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +93,7 @@ class MenuRenderer extends RecursiveIteratorIterator
|
|||||||
{
|
{
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<a href="%s">%s%s</a>',
|
'<a href="%s">%s%s</a>',
|
||||||
$child->getUrl() ? Url::fromPath($child->getUrl()) : '#',
|
$child->getUrl() ?: '#',
|
||||||
$child->getIcon() ? '<img src="' . Url::fromPath($child->getIcon()) . '" class="icon" /> ' : '',
|
$child->getIcon() ? '<img src="' . Url::fromPath($child->getIcon()) . '" class="icon" /> ' : '',
|
||||||
htmlspecialchars($child->getTitle())
|
htmlspecialchars($child->getTitle())
|
||||||
);
|
);
|
||||||
@ -146,6 +150,9 @@ class MenuRenderer extends RecursiveIteratorIterator
|
|||||||
*/
|
*/
|
||||||
protected function isActive(Menu $child)
|
protected function isActive(Menu $child)
|
||||||
{
|
{
|
||||||
return html_entity_decode(rawurldecode($this->url)) === html_entity_decode(rawurldecode($child->getUrl()));
|
if (! $this->url) return false;
|
||||||
|
if (! ($childUrl = $child->getUrl())) return false;
|
||||||
|
|
||||||
|
return $this->url && $this->url->matches($childUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user