icingaweb2/modules/monitoring/application/views/scripts/show/components/actions.phtml

47 lines
1.6 KiB
PHTML
Raw Normal View History

<?php
$links = array();
$linkText = '<a href="%s" target="_blank">%s</a>';
$localLinkText = '<a href="%s">%s</a>';
if ($object->notes_url) {
if (strpos($object->notes_url, "' ") === false) {
$links[] = sprintf($linkText, $this->resolveMacros($object->notes_url, $object), 'Notes');
} else {
// TODO: We should find out document what's going on here. Looks strange :p
foreach(explode("' ", $object->notes_url) as $url) {
$url = strpos($url, "'") === 0 ? substr($url, 1) : $url;
$url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url;
$links[] = sprintf($linkText, $this->resolveMacros($url, $object), 'Notes');
}
}
}
if ($object->action_url) {
if (strpos($object->action_url, "' ") === false) {
$links[] = sprintf($linkText, $this->resolveMacros($object->action_url, $object), 'Action');
} else {
// TODO: We should find out document what's going on here. Looks strange :p
foreach(explode("' ", $object->action_url) as $url) {
$url = strpos($url, "'") === 0 ? substr($url, 1) : $url;
$url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url;
$links[] = sprintf($linkText, $this->resolveMacros($url, $object), 'Action');
}
}
}
if (isset($this->hostActions)) {
foreach ($this->hostActions as $id => $action) {
$links[] = sprintf($localLinkText, $action, $id);
}
}
if (empty($links)) {
return;
}
?>
<tr>
<th><?= $this->translate('Actions') ?></th>
<td><?= implode("\n ", $links) . "\n" ?></td>
</tr>