diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml
index 18f8a8482..78365f733 100644
--- a/modules/monitoring/application/views/scripts/show/components/actions.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml
@@ -1,16 +1,11 @@
%s ', $this->translate('opens in new window'));
-$links = MonitoredObject::parseAttributeUrls($object->action_url);
+$links = $object->getActionUrls();
foreach ($links as $i => $link) {
- $links[$i] = sprintf(
- '%s ' . $newTabInfo . '',
- $this->resolveMacros($object->action_url, $object),
- 'Action'
- );
+ $links[$i] = sprintf('%s ' . $newTabInfo . '', $link, 'Action');
}
if (isset($this->actions)) {
diff --git a/modules/monitoring/application/views/scripts/show/components/notes.phtml b/modules/monitoring/application/views/scripts/show/components/notes.phtml
index 678d70c90..4a5041e50 100644
--- a/modules/monitoring/application/views/scripts/show/components/notes.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/notes.phtml
@@ -1,15 +1,13 @@
getNotes());
$links = $object->getNotesUrls();
-?>
-
+if (! empty($links) || ! empty($notes)): ?>
= $this->translate('Notes') ?> |
resolveMacros($notes, $object);
echo $notes . ' ';
}
// add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201
@@ -19,8 +17,7 @@ $links = $object->getNotesUrls();
);
$linkText = '%s ' . $newTabInfo . '';
foreach ($links as $i => $link) {
- $resolved = $this->resolveMacros($link, $object);
- $links[$i] = sprintf($linkText, $this->escape($resolved), $this->escape($resolved));
+ $links[$i] = sprintf($linkText, $this->escape($link), $this->escape($link));
}
echo implode(' ', $links);
?>
diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php
index da3d66613..dd9b4c0c1 100644
--- a/modules/monitoring/library/Monitoring/Object/Host.php
+++ b/modules/monitoring/library/Monitoring/Object/Host.php
@@ -192,7 +192,9 @@ class Host extends MonitoredObject
public function getNotesUrls()
{
- return MonitoredObject::parseAttributeUrls($this->host_notes_url);
+ return $this->resolveAllStrings(
+ MonitoredObject::parseAttributeUrls($this->host_notes_url)
+ );
}
public function getNotes()
diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
index 37d29c82e..b68bc0539 100644
--- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
+++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
@@ -569,14 +569,14 @@ abstract class MonitoredObject implements Filterable
*
* @return string The notes as a string
*/
- public function getNotes() {}
+ public abstract function getNotes();
/**
* Get all note urls configured for this monitored object
*
* @return array All note urls as a string
*/
- public function getNotesUrls() {}
+ public abstract function getNotesUrls();
/**
* Get all action urls configured for this monitored object
@@ -585,7 +585,23 @@ abstract class MonitoredObject implements Filterable
*/
public function getActionUrls()
{
- return MonitoredObject::parseAttributeUrls($this->action_url);
+ return $this->resolveAllStrings(
+ MonitoredObject::parseAttributeUrls($this->action_url)
+ );
+ }
+
+ /**
+ * Resolve macros in all given strings in the current object context
+ *
+ * @param array $strs An array of urls as string
+ * @return type
+ */
+ protected function resolveAllStrings(array $strs)
+ {
+ foreach ($strs as $i => $str) {
+ $strs[$i] = Macro::resolveMacros($str, $this);
+ }
+ return $strs;
}
/**
diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php
index 6b5cd5bf9..cb5615df1 100644
--- a/modules/monitoring/library/Monitoring/Object/Service.php
+++ b/modules/monitoring/library/Monitoring/Object/Service.php
@@ -202,7 +202,9 @@ class Service extends MonitoredObject
public function getNotesUrls()
{
- return MonitoredObject::parseAttributeUrls($this->service_notes_url);
+ return $this->resolveAllStrings(
+ MonitoredObject::parseAttributeUrls($this->service_notes_url)
+ );
}
public function getNotes()
|