commit
e33791b50f
|
@ -11,6 +11,7 @@
|
|||
|
||||
<table class="avp newsection">
|
||||
<tbody>
|
||||
<?= $this->render('show/components/notes.phtml') ?>
|
||||
<?= $this->render('show/components/acknowledgement.phtml') ?>
|
||||
<?= $this->render('show/components/comments.phtml') ?>
|
||||
<?= $this->render('show/components/notifications.phtml') ?>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<table class="avp newsection">
|
||||
<tbody>
|
||||
<?= $this->render('show/components/notes.phtml') ?>
|
||||
<?= $this->render('show/components/acknowledgement.phtml') ?>
|
||||
<?= $this->render('show/components/comments.phtml') ?>
|
||||
<?= $this->render('show/components/notifications.phtml') ?>
|
||||
|
|
|
@ -8,18 +8,6 @@ $newTabInfo = sprintf('<span class="info-box display-on-hover"> %s </span>', $th
|
|||
$linkText = '<a href="%s" target="_blank">%s ' . $newTabInfo . '</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');
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
$notes = trim($object->getNotes());
|
||||
$links = $object->getNotesUrls();
|
||||
?>
|
||||
|
||||
<?php if (! empty($links) || ! empty($notes)): ?>
|
||||
<tr>
|
||||
<th><?= $this->translate('Notes') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
if (! empty($notes)) {
|
||||
$notes = $this->resolveMacros($notes, $object);
|
||||
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) {
|
||||
$resolved = $this->resolveMacros($link, $object);
|
||||
$links[$i] = sprintf($linkText, $this->escape($resolved), $this->escape($resolved));
|
||||
}
|
||||
echo implode('<br>', $links);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
|
@ -43,6 +43,7 @@ class StatusQuery extends IdoQuery
|
|||
'host_icon_image' => 'h.icon_image',
|
||||
'host_icon_image_alt' => 'h.icon_image_alt',
|
||||
'host_action_url' => 'h.action_url',
|
||||
'host_notes' => 'h.notes',
|
||||
'host_notes_url' => 'h.notes_url'
|
||||
),
|
||||
'hoststatus' => array(
|
||||
|
@ -179,6 +180,7 @@ class StatusQuery extends IdoQuery
|
|||
'service_icon_image' => 's.icon_image',
|
||||
'service_icon_image_alt' => 's.icon_image_alt',
|
||||
'service_action_url' => 's.action_url',
|
||||
'service_notes' => 's.notes',
|
||||
'service_notes_url' => 's.notes_url',
|
||||
'object_type' => '(\'service\')'
|
||||
),
|
||||
|
|
|
@ -119,6 +119,7 @@ class Host extends MonitoredObject
|
|||
'host_max_check_attempts',
|
||||
'host_name',
|
||||
'host_next_check',
|
||||
'host_notes',
|
||||
'host_notes_url',
|
||||
'host_notifications_enabled',
|
||||
'host_notifications_enabled_changed',
|
||||
|
@ -188,4 +189,14 @@ class Host extends MonitoredObject
|
|||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function getNotesUrls()
|
||||
{
|
||||
return MonitoredObject::parseAttributeUrls($this->host_notes_url);
|
||||
}
|
||||
|
||||
public function getNotes()
|
||||
{
|
||||
return $this->host_notes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,4 +563,44 @@ abstract class MonitoredObject implements Filterable
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The notes for this monitored object
|
||||
*
|
||||
* @return string The notes as a string
|
||||
*/
|
||||
public function getNotes() {}
|
||||
|
||||
/**
|
||||
* Get all note urls configured for this monitored object
|
||||
*
|
||||
* @return array All note urls as a string
|
||||
*/
|
||||
public function getNotesUrls() {}
|
||||
|
||||
/**
|
||||
* Parse the content of the action_url or notes_url attributes
|
||||
*
|
||||
* @link http://docs.icinga.org/latest/de/objectdefinitions.html
|
||||
*
|
||||
* @param string $urlString A string containing one or more urls
|
||||
* @return array Array of urls as strings
|
||||
*/
|
||||
public static function parseAttributeUrls($urlString)
|
||||
{
|
||||
if (empty($urlString)) {
|
||||
return array();
|
||||
}
|
||||
if (strpos($urlString, "' ") === false) {
|
||||
$links[] = $urlString;
|
||||
} else {
|
||||
// parse notes-url format
|
||||
foreach (explode("' ", $urlString) as $url) {
|
||||
$url = strpos($url, "'") === 0 ? substr($url, 1) : $url;
|
||||
$url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url;
|
||||
$links[] = $url;
|
||||
}
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ class Service extends MonitoredObject
|
|||
'service_last_state_change',
|
||||
'service_long_output',
|
||||
'service_next_check',
|
||||
'service_notes',
|
||||
'service_notes_url',
|
||||
'service_notifications_enabled',
|
||||
'service_notifications_enabled_changed',
|
||||
|
@ -198,4 +199,14 @@ class Service extends MonitoredObject
|
|||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function getNotesUrls()
|
||||
{
|
||||
return MonitoredObject::parseAttributeUrls($this->service_notes_url);
|
||||
}
|
||||
|
||||
public function getNotes()
|
||||
{
|
||||
return $this->service_notes;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue