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

51 lines
1.4 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',
$iconForm = $cf->labelSubmitForm(
'X',
'Remove comment',
'link-like',
'removecomment',
$deleteData
);
$list[] = sprintf(
'<tr><th>%s (%s)</th><td><table><tr><td style="vertical-align: top;" data-base-target="_self">%s (%s):</td><td style="padding-left: .5em;">%s</td></tr></table></td></tr>',
$this->escape($comment->author),
$this->timeSince($comment->timestamp),
$iconForm,
ucfirst($comment->type),
str_replace(array('\r\n', '\n'), '<br>', $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) ?>