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

60 lines
1.7 KiB
PHTML

<tr>
<th><?= $this->translate('Comments') ?></th>
<td>
<?php
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$addCommentLink = $this->href(
'monitoring/host/add-comment',
array('host' => $object->getHost())
);
} else {
$addCommentLink = $this->href(
'monitoring/service/add-comment',
array('host' => $object->getHost(), 'service' => $object->getService())
);
}
?>
<a href="<?= $addCommentLink ?>">
<?= $this->icon('comment_petrol.png') ?> <?= $this->translate('Add comment') ?>
</a>
</td>
</tr>
<?php
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);
$form = clone $delCommentForm;
$form->populate(array('comment_id' => $comment->id));
?>
<tr>
<th><?= $this->escape($comment->author) ?> (<?= $this->timeSince($comment->timestamp) ?>)</th>
<td>
<table>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?= $form ?> (<?= ucfirst($comment->type) ?>):
</td>
<td style="padding-left: .5em;">
<?= str_replace(array('\r\n', '\n'), '<br>', $text) ?>
</td>
</tr>
</table>
</td>
</tr>
<?php } // endforeach ?>