monitoring: Fix code style in the show/components/comments.phtml view script

refs #9611
This commit is contained in:
Eric Lippmann 2015-08-03 10:58:57 +02:00
parent b6caeb6c17
commit a379a448d9

View File

@ -1,7 +1,5 @@
<?php <?php
$addLink = false;
$addLink = '';
if ($this->hasPermission('monitoring/command/comment/add')) { if ($this->hasPermission('monitoring/command/comment/add')) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) { if ($object->getType() === $object::TYPE_HOST) {
@ -28,55 +26,49 @@ if ($this->hasPermission('monitoring/command/comment/add')) {
); );
} }
} }
if (empty($object->comments) && ! $addLink) { if (empty($object->comments) && ! $addLink) {
return; return;
} }
?> ?>
<tr> <tr>
<th><?php <th><?php
echo $this->translate('Comments'); echo $this->translate('Comments');
if (! empty($object->comments) && $addLink) { if (! empty($object->comments) && $addLink) {
echo '<br />' . $addLink; echo '<br />' . $addLink;
} }
?></th> ?></th>
<td data-base-target="_self"> <td data-base-target="_self">
<?php if (empty($object->comments)): ?> <?php if (empty($object->comments)):
<?= $addLink ?> echo $addLink;
<?php else: ?> else: ?>
<ul class="inline-comments"> <ul class="inline-comments">
<?php foreach ($object->comments as $comment): ?> <?php foreach ($object->comments as $comment):
<?php // Form is unset if the current user lacks the respective permission
if (isset($delCommentForm)) {
// Form is unset if the current user lacks the respective permission $deleteButton = clone($delCommentForm);
if (isset($delCommentForm)) { $deleteButton->populate(
$deleteButton = clone($delCommentForm); array(
$deleteButton->populate( 'comment_id' => $comment->id,
array( 'comment_is_service' => isset($comment->service_description)
'comment_id' => $comment->id, )
'comment_is_service' => isset($comment->service_description) );
) } else {
); $deleteButton = '';
} else { }
$deleteButton = ''; ?>
} <li class="comment-item">
<h3>
?> <span class="author"><?= $this->escape($comment->author) ?></span>
<li class="comment-item"> <?= $this->timeAgo($comment->timestamp) ?>
<h3>
<span class="author"><?= $this->escape($comment->author) ?></span>
<?= $this->timeAgo($comment->timestamp) ?>
<?= $deleteButton ?> <?= $deleteButton ?>
</h3> </h3>
<p><span class="sr-only">(<?= $this->translate('Comment'); ?>): </span><?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($comment->comment)) ?></p> <p>
</li> <span class="sr-only">(<?= $this->translate('Comment') ?>): </span>
<?php endforeach ?> <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($comment->comment)) ?>
</ul> </p>
<?php endif ?> </li>
<?php endforeach ?>
</ul>
<?php endif ?>
</td> </td>
</tr> </tr>