notes.phtml: Use the new Navigation to load and render notes urls

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-07 10:34:21 +02:00
parent 4983d46dd7
commit 716e532d16
1 changed files with 35 additions and 23 deletions

View File

@ -1,26 +1,38 @@
<?php
$notes = trim($object->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(
'<span class="info-box display-on-hover"> %s </span>',
$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;
}
?>
<tr>
<th><?= $this->translate('Notes') ?></th>
<td>
<?php
if (! empty($notes)) {
echo $notes . '<br>';
}
// add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201
$newTabInfo = sprintf(
'<span class="info-box display-on-hover"> %s </span>',
$this->translate('opens in new window')
);
$linkText = '<a href="%s" target="_blank">%s ' . $newTabInfo . '</a>';
foreach ($links as $i => $link) {
$links[$i] = sprintf($linkText, $this->escape($link), $this->escape($link));
}
echo implode('<br>', $links);
?>
</td>
</tr>
<?php endif ?>
<th><?= $this->translate('Notes'); ?></th>
<?= $navigation->getRenderer()->setElementTag('td'); ?>
</tr>