From 716e532d16db5d88fb5928636d48b21ac71ab17e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 7 Sep 2015 10:34:21 +0200 Subject: [PATCH] notes.phtml: Use the new Navigation to load and render notes urls refs #5600 --- .../views/scripts/show/components/notes.phtml | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/notes.phtml b/modules/monitoring/application/views/scripts/show/components/notes.phtml index 4a5041e50..94f645897 100644 --- a/modules/monitoring/application/views/scripts/show/components/notes.phtml +++ b/modules/monitoring/application/views/scripts/show/components/notes.phtml @@ -1,26 +1,38 @@ getNotes()); -$links = $object->getNotesUrls(); -if (! empty($links) || ! empty($notes)): ?> +use Icinga\Web\Navigation\Navigation; + +$navigation = new Navigation(); + +$notes = trim($object->getNotes()); +if ($notes) { + $navigation->addItem($notes); +} + +$links = $object->getNotesUrls(); +if (! empty($links)) { + // add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201 + $newTabInfo = sprintf( + ' %s ', + $this->translate('opens in new window') + ); + + foreach ($links as $link) { + $navigation->addItem( + $this->escape($link) . $newTabInfo, + array( + 'url' => $link, + 'target' => '_blank' + ) + ); + } +} + +if ($navigation->isEmpty()) { + return; +} +?> - translate('Notes') ?> - - '; - } - // add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201 - $newTabInfo = sprintf( - ' %s ', - $this->translate('opens in new window') - ); - $linkText = '%s ' . $newTabInfo . ''; - foreach ($links as $i => $link) { - $links[$i] = sprintf($linkText, $this->escape($link), $this->escape($link)); - } - echo implode('
', $links); - ?> - - - + translate('Notes'); ?> + getRenderer()->setElementTag('td'); ?> + \ No newline at end of file