From 51188daa4549b9f826bf217770aaa40950798261 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Feb 2014 16:21:36 +0100 Subject: [PATCH] Implenent TopBar hook and status summary as hook in monitoring refs #5597 --- application/controllers/LayoutController.php | 27 ++++++ application/layouts/scripts/body.phtml | 3 +- .../layouts/scripts/parts/topbar.phtml | 13 +-- library/Icinga/Web/Hook.php | 5 ++ .../{Topbar.php => Hook/Layout/TopBar.php} | 34 ++++---- .../views/scripts/{ => layout}/topbar.phtml | 0 .../library/Monitoring/Web/Hook/TopBar.php | 87 +++++++++++++++++++ modules/monitoring/register.php | 4 - modules/monitoring/run.php | 17 +++- 9 files changed, 160 insertions(+), 30 deletions(-) rename library/Icinga/Web/{Topbar.php => Hook/Layout/TopBar.php} (72%) rename modules/monitoring/application/views/scripts/{ => layout}/topbar.phtml (100%) create mode 100644 modules/monitoring/library/Monitoring/Web/Hook/TopBar.php diff --git a/application/controllers/LayoutController.php b/application/controllers/LayoutController.php index 81bf36083..45836582e 100644 --- a/application/controllers/LayoutController.php +++ b/application/controllers/LayoutController.php @@ -4,16 +4,43 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Web\Controller\ActionController; +use Icinga\Web\Hook; use Icinga\Web\Menu; use Icinga\Web\Url; +/** + * Create complex layout parts + */ class LayoutController extends ActionController { + /** + * Render the menu + */ public function menuAction() { $this->view->url = Url::fromRequest()->getRelativeUrl(); $this->view->items = Menu::fromConfig()->getChildren(); $this->view->sub = false; } + + /** + * Render the top bar + */ + public function topbarAction() + { + $topbarHtmlParts = array(); + + /** @var Hook\Layout\TopBar $hook */ + $hook = null; + + foreach (Hook::all(Hook::TARGET_LAYOUT_TOPBAR) as $hook) { + $topbarHtmlParts[] = $hook->getHtml($this->getRequest(), $this->view); + } + + $this->view->topbarHtmlParts = $topbarHtmlParts; + + + $this->renderScript('parts/topbar.phtml'); + } } // @codingStandardsIgnoreEnd diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index 565a3122d..a42b46dcc 100755 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -1,4 +1,5 @@ -render('parts/topbar.phtml') ?> +action('topbar', 'layout'); ?> +
diff --git a/application/layouts/scripts/parts/topbar.phtml b/application/layouts/scripts/parts/topbar.phtml index e2aa3209c..39d559f57 100755 --- a/application/layouts/scripts/parts/topbar.phtml +++ b/application/layouts/scripts/parts/topbar.phtml @@ -1,14 +1,15 @@ -