From 16ece09b0a290e69e53858f80a90f8d30666b56c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 3 Sep 2015 13:36:34 +0200 Subject: [PATCH] NavigationItemRenderer: Add option $target refs #5600 --- .../Renderer/NavigationItemRenderer.php | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php b/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php index 4c872c07f..4b56b5f04 100644 --- a/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php +++ b/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php @@ -20,6 +20,13 @@ class NavigationItemRenderer */ protected $view; + /** + * The link target + * + * @var string + */ + protected $target; + /** * Create a new NavigationItemRenderer * @@ -49,6 +56,19 @@ class NavigationItemRenderer } } + /** + * Set the view + * + * @param View $view + * + * @return $this + */ + public function setView(View $view) + { + $this->view = $view; + return $this; + } + /** * Return the view * @@ -64,18 +84,28 @@ class NavigationItemRenderer } /** - * Set the view + * Set the link target * - * @param View $view + * @param string $target * * @return $this */ - public function setView(View $view) + public function setTarget($target) { - $this->view = $view; + $this->target = $target; return $this; } + /** + * Return the link target + * + * @return string + */ + public function getTarget() + { + return $this->target; + } + /** * Render the given navigation item as HTML anchor * @@ -92,9 +122,10 @@ class NavigationItemRenderer if (($url = $item->getUrl()) !== null) { $content = sprintf( - '%s', + '%s', $this->view()->propertiesToString($item->getAttributes()), $this->view()->url($url, $item->getUrlParameters()), + $this->target ? ' target="' . $this->view()->escape($this->target) . '"' : '', $label ); } else {