Dedicated view script for object actions

This commit is contained in:
Thomas Gelf 2014-03-08 19:49:57 +01:00
parent b4aff8f39b
commit c41160405d
2 changed files with 39 additions and 37 deletions
modules/monitoring/application/views/scripts/show/components

View File

@ -0,0 +1,39 @@
<?php
if (! $object->action_url && ! $object->notes_url) {
return;
}
$links = array();
$linkText = '<a href="%s" target="_blank">%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');
}
}
}
?>
<tr>
<th>Foreign URLs</th>
<td><?= implode("\n ", $links) . "\n" ?></td>
</tr>

View File

@ -14,43 +14,6 @@
}
?>
<div>
<div class="panel-heading border-status-<?= $objectStateName ?>">
<div class="panel-hostname">
<div class="small-row">
<?php if ($object->action_url || $object->notes_url): ?>
<br />
<?php if ($object->notes_url): ?>
<?php if (strpos($object->notes_url, "' ") === false): ?>
<a target="_new" href='<?= $this->escape($this->resolveMacros($object->notes_url, $object)); ?>'>Notes</a>
<?php else: ?>
<?php foreach(explode("' ", $object->notes_url) as $url): ?>
<?php $url = strpos($url, "'") === 0 ? substr($url, 1) : $url; ?>
<?php $url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url; ?>
<a target="_new" href='<?= $this->escape($this->resolveMacros($url, $object)); ?>'>Notes</a>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($object->action_url): ?>
<?php if (strpos($object->action_url, "' ") === false): ?>
<a target="_new" href='<?= $this->escape($this->resolveMacros($this->object->action_url, $object)); ?>'>Action</a>
<?php else: ?>
<?php foreach(explode("' ", $object->action_url) as $url): ?>
<?php $url = strpos($url, "'") === 0 ? substr($url, 1) : $url; ?>
<?php $url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url; ?>
<a target="_new" href='<?= $this->escape($this->resolveMacros($url, $object)); ?>'>Action</a>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<div class="panel-row">