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

refs #9611
This commit is contained in:
Eric Lippmann 2015-08-03 15:03:31 +02:00
parent 0809caa86b
commit d8e6418e94

View File

@ -1,7 +1,5 @@
<?php <?php
$addLink = false;
$addLink = '';
if ($this->hasPermission('monitoring/command/downtime/schedule')) { if ($this->hasPermission('monitoring/command/downtime/schedule')) {
/** @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) {
@ -32,32 +30,23 @@ if ($this->hasPermission('monitoring/command/downtime/schedule')) {
); );
} }
} }
if (empty($object->comments) && ! $addLink) { if (empty($object->comments) && ! $addLink) {
return; return;
} }
?> ?>
<tr> <tr>
<th><?php <th><?php
echo $this->translate('Downtimes'); echo $this->translate('Downtimes');
if (! empty($object->downtimes) && $addLink) { if (! empty($object->downtimes) && $addLink) {
echo '<br />' . $addLink; echo '<br />' . $addLink;
} }
?></th> ?></th>
<td data-base-target="_self"> <td data-base-target="_self">
<?php if (empty($object->downtimes)): ?> <?php if (empty($object->downtimes)):
<?= $addLink ?> echo $addLink;
<?php else: ?> else: ?>
<ul class="inline-comments"> <ul class="inline-comments">
<?php foreach ($object->downtimes as $downtime):
<?php foreach ($object->downtimes as $downtime): ?>
<?php
if ((bool) $downtime->is_in_effect) { if ((bool) $downtime->is_in_effect) {
$state = sprintf( $state = sprintf(
$this->translate('in downtime %s', 'Last format parameter represents the time in downtime'), $this->translate('in downtime %s', 'Last format parameter represents the time in downtime'),
@ -76,8 +65,6 @@ if (empty($object->comments) && ! $addLink) {
); );
} }
} }
// Form is unset if the current user lacks the respective permission // Form is unset if the current user lacks the respective permission
if (isset($delDowntimeForm)) { if (isset($delDowntimeForm)) {
$deleteButton = clone($delDowntimeForm); $deleteButton = clone($delDowntimeForm);
@ -90,20 +77,21 @@ if (isset($delDowntimeForm)) {
} else { } else {
$deleteButton = ''; $deleteButton = '';
} }
?> ?>
<li class="comment-item"> <li class="comment-item">
<h3> <h3>
<span class="author"><?= $this->escape($downtime->author_name) ?></span> <span class="author"><?= $this->escape($downtime->author_name) ?></span>
<?= $this->timeAgo($downtime->entry_time) ?> <?= $this->timeAgo($downtime->entry_time) ?>
<?= $deleteButton ?> <?= $deleteButton ?>
</h3> </h3>
<p> <span class="sr-only"><?= $this->translate('Downtime'); ?></span><?= $state; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)); ?></p> <p>
<span class="sr-only"><?= $this->translate('Downtime') ?></span>
<?= $state ?> -
<?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)) ?>
</p>
</li> </li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>