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

View File

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