PHTML hotfix

This commit is contained in:
Alexander Klimov 2014-03-07 11:30:23 +01:00
parent 73f2bf18d0
commit 75096dd65b
3 changed files with 67 additions and 101 deletions

View File

@ -80,7 +80,7 @@ foreach ($services as $service):
<?php endif ?>
<?php if ($service->service_icon_image): ?>
<?= $this->img($this->resolveMacros($service->service_icon_image, $service), array('align' => 'left')) ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?php endif ?>
<a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?>
<?php if ($service->host_state != 0): ?>

View File

@ -1,6 +1,5 @@
<?php
/** @var Zend_View_Helper_CommandForm $cf */
$cf = $this->getHelper('CommandForm');
$data = array('host' => $object->host_name);
@ -8,59 +7,43 @@ if ($object->service_description) {
$data['service'] = $object->service_description;
}
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Comments
<?php
?>
<div class="pull-right">
<a rel="tooltip" title="Add a comment" href="<?= $this->href('monitoring/command/addComment', $data) ?>" class="btn-common btn-small button"><?=
$this->icon('comment.png')
?></a>
<a rel="tooltip" title="Send custom notification" href="<?= $this->href('monitoring/command/sendCustomNotification', $data
) ?>" class="btn-common btn-small button">
<?= $this->icon('notification.png') ?>
</a>
</div>
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<table class="table table-condensed table-detail">
<tbody>
<?php if (empty($object->comments)): ?>
<tr>
<td>No comments</td>
</tr>
<?php endif; ?>
<?php foreach ($object->comments as $comment): ?>
<tr>
<td>
<div class="pull-right">
<?php
$deleteData = $data;
$deleteData['commentid'] = $comment->comment_internal_id;
$list = array();
foreach ($object->comments as $comment) {
echo $cf->iconSubmitForm(
'img/icons/remove.png',
'Remove comment',
'btn-small',
'removecomment',
$deleteData
);
?>
</div>
<?= $this->escape($comment->comment_author); ?>, <?= $comment->comment_type; ?>
(<?= $this->format()->timeSince($comment->comment_timestamp); ?>)
<div class="small-row">
<?= $this->escape($comment->comment_data); ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
// Ticket hook sample
$text = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(),
array($this->tickets, 'createLink'),
$this->escape($comment->comment_data)
) : $this->escape($comment->comment_data);
$deleteData = $data;
$deleteData['commentid'] = $object->comment_internal_id;
$iconForm = $cf->iconSubmitForm(
'img/icons/remove.png',
'Remove comment',
'btn-small',
'removecomment',
$deleteData
);
$list[] = sprintf(
"<br />%s [%s] %s (%s): %s\n",
//'<input type="submit" value="x" style="width: 2em" />',
'<a href="#">' . $this->icon('remove_petrol.png') . '</a>' . $iconForm, // Test
$this->escape($comment->comment_author),
$this->timeSince($comment->comment_timestamp),
$comment->comment_type,
$text
);
}
?>
<tr>
<th><?= $this->translate('Comments') ?></th>
<td>
<a href="<?= $this->href('monitoring/command/addComment', $data) ?>"><?= $this->icon('comment_petrol.png') ?> <?= $this->translate('Add comment') ?></a>
<?= implode('', $list) ?>
</td>
</tr>

View File

@ -1,66 +1,49 @@
<?php
$o = $this->object;
$isService = (isset($o->service_description)) ? true : false;
$obj = new \stdClass();
$obj->handled =
($isService) ? $o->service_handled : $o->host_handled;
$obj->state =
($isService) ? $o->service_state : $o->host_state;
$obj->acknowledged =
($isService) ? $o->service_acknowledged : $o->host_acknowledged;
$obj->in_downtime =
($isService) ? $o->in_downtime : $o->host_in_downtime;
$obj->is_flapping =
($isService) ? $o->is_flapping : $o->host_is_flapping;
$obj->notifications_enabled =
($isService) ? $o->notifications_enabled : $o->service_notifications_enabled;
$obj->active_checks_enabled =
($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled;
$obj->passive_checks_enabled =
($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled;
$obj->last_comment =
($isService) ? $o->last_comment : $o->host_last_comment;
use Icinga\Module\Monitoring\Object\Service;
$o = $this->object;
$isService = $o instanceof Service;
$obj = new \stdClass();
$obj->handled =
($isService) ? $o->service_handled : $o->host_handled;
$obj->state =
($isService) ? $o->service_state : $o->host_state;
$obj->acknowledged =
($isService) ? $o->service_acknowledged : $o->host_acknowledged;
$obj->in_downtime =
($isService) ? $o->in_downtime : $o->host_in_downtime;
$obj->notifications_enabled =
($isService) ? $o->notifications_enabled : $o->service_notifications_enabled;
$obj->active_checks_enabled =
($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled;
$obj->passive_checks_enabled =
($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled;
$i = array();
if (! $obj->handled && $obj->state > 0) {
$i[] = $this->img('img/icons/unhandled.png', array('title' => 'Unhandled'));
$i[] = $this->icon('unhandled.png', 'Unhandled');
}
if ($obj->acknowledged && ! $obj->in_downtime) {
$i[] = $this->icon('acknowledgement.png', 'Acknowledged');
}
if ($obj->is_flapping) {
$i[] = $this->icon('flapping.png', 'Flapping');
}
if (!$obj->notifications_enabled) {
$i[] = $this->img('img/icons/notification_disabled.png', array('title' => 'Notifications Disabled'));
$i[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
}
if ($obj->in_downtime) {
$i[] = $this->img('img/icons/in_downtime.png', array('title' => 'In Downtime'));
$i[] = $this->icon('in_downtime.png', 'In Downtime');
}
if (! $obj->active_checks_enabled) {
if ($obj->passive_checks_enabled) {
$i[] = $this->img(
'img/icons/active_checks_disabled.png',
array('title' => 'Active Checks Disabled')
);
$i[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
} else {
$i[] = $this->img(
'img/icons/active_passive_checks_disabled.png',
array('title' => 'Active And Passive Checks Disabled')
);
$i[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
}
}
if ($obj->last_comment !== null) {
$i[] = $this->icon('comment.png', 'Comments');
}
?><span>
<?= implode("\n ", $i) . "\n" ?>
</span>
?><?= implode("\n", $i) ?>