From b63a956a3882188dcc229a67d726271d2ddd740c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 1 Oct 2015 17:34:45 +0200 Subject: [PATCH 1/4] Dashboard: Respect original dashlet order --- library/Icinga/Web/Widget/Dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 4ff192122..0cd42e7d9 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -77,7 +77,7 @@ class Dashboard extends AbstractWidget foreach ($navigation as $dashboardPane) { /** @var DashboardPane $dashboardPane */ $pane = new Pane($dashboardPane->getLabel()); - foreach ($dashboardPane->getDashlets() as $title => $url) { + foreach ($dashboardPane->getDashlets(false) as $title => $url) { $pane->addDashlet($title, $url); } From 8c8af9cd508aaf54a66df40b6f1c63249ea558e0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 1 Oct 2015 17:35:11 +0200 Subject: [PATCH 2/4] DashboardPane: Fix that ordering dashlets is persistent --- library/Icinga/Web/Navigation/DashboardPane.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Navigation/DashboardPane.php b/library/Icinga/Web/Navigation/DashboardPane.php index 3bf6d0992..64d844ab7 100644 --- a/library/Icinga/Web/Navigation/DashboardPane.php +++ b/library/Icinga/Web/Navigation/DashboardPane.php @@ -44,7 +44,9 @@ class DashboardPane extends NavigationItem } if ($ordered) { - ksort($this->dashlets); + $dashlets = $this->dashlets; + ksort($dashlets); + return $dashlets; } return $this->dashlets; From 14ae04b63154c33fcbcc01ff446a587260359f31 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 1 Oct 2015 17:43:48 +0200 Subject: [PATCH 3/4] RecursiveNavigationRenderer: Allow to enforce the standard item renderer --- .../Renderer/RecursiveNavigationRenderer.php | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Navigation/Renderer/RecursiveNavigationRenderer.php b/library/Icinga/Web/Navigation/Renderer/RecursiveNavigationRenderer.php index 83b2207bb..0417abef5 100644 --- a/library/Icinga/Web/Navigation/Renderer/RecursiveNavigationRenderer.php +++ b/library/Icinga/Web/Navigation/Renderer/RecursiveNavigationRenderer.php @@ -8,6 +8,7 @@ use RecursiveIteratorIterator; use Icinga\Exception\IcingaException; use Icinga\Web\Navigation\Navigation; use Icinga\Web\Navigation\NavigationItem; +use Icinga\Web\Navigation\Renderer\NavigationItemRenderer; /** * Renderer for multi level navigation @@ -25,6 +26,13 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N */ protected $content; + /** + * Whether to use the standard item renderer + * + * @var bool + */ + protected $useStandardRenderer; + /** * Create a new RecursiveNavigationRenderer * @@ -39,6 +47,29 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N ); } + /** + * Set whether to use the standard navigation item renderer + * + * @param bool $state + * + * @return $this + */ + public function setUseStandardItemRenderer($state = true) + { + $this->useStandardRenderer = (bool) $state; + return $this; + } + + /** + * Return whether to use the standard navigation item renderer + * + * @return bool + */ + public function getUseStandardItemRenderer() + { + return $this->useStandardRenderer; + } + /** * {@inheritdoc} */ @@ -131,7 +162,14 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N /** @var NavigationItem $item */ if ($item->shouldRender()) { $this->content[] = $this->getInnerIterator()->beginItemMarkup($item); - $this->content[] = $item->render(); + + if ($this->getUseStandardItemRenderer()) { + $renderer = new NavigationItemRenderer(); + $this->content[] = $renderer->render($item); + } else { + $this->content[] = $item->render(); + } + if (! $item->hasChildren()) { $this->content[] = $this->getInnerIterator()->endItemMarkup(); } From e788682c19310eb227f701737a8577924e6e20ff Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 1 Oct 2015 17:44:37 +0200 Subject: [PATCH 4/4] Enforce the standard nav item renderer for the main menu by default --- application/layouts/scripts/parts/navigation.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/layouts/scripts/parts/navigation.phtml b/application/layouts/scripts/parts/navigation.phtml index 78d399810..6c1c4c1b7 100644 --- a/application/layouts/scripts/parts/navigation.phtml +++ b/application/layouts/scripts/parts/navigation.phtml @@ -25,7 +25,7 @@ if (! $this->auth()->isAuthenticated()) { 'layout/menu.phtml', 'default', array( - 'menuRenderer' => Icinga::app()->getMenu()->getRenderer() + 'menuRenderer' => Icinga::app()->getMenu()->getRenderer()->setUseStandardItemRenderer() ) ) ?>