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

49 lines
1.2 KiB
PHTML

<?php
$cf = $this->getHelper('CommandForm');
$data = array('host' => $object->host_name);
if ($object->service_description) {
$data['service'] = $object->service_description;
}
$list = array();
foreach ($object->comments as $comment) {
// Ticket hook sample
$text = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(),
array($this->tickets, 'createLink'),
$this->escape($comment->comment)
) : $this->escape($comment->comment);
$deleteData = $data;
$deleteData['commentid'] = $comment->id;
$iconForm = $cf->iconSubmitForm(
'img/icons/remove_petrol.png',
'Remove comment',
'link-like',
'removecomment',
$deleteData
);
$list[] = sprintf(
'<tr><th>%s (%s)</th><td data-base-target="_self">%s (%s) %s</td></tr>',
$this->escape($comment->author),
$this->timeSince($comment->timestamp),
$iconForm,
ucfirst($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>
</td>
</tr>
<?= implode("\n", $list) ?>