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
1 changed files with 52 additions and 64 deletions

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,78 +30,68 @@ 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): ?> if ((bool) $downtime->is_in_effect) {
<?php $state = sprintf(
$this->translate('in downtime %s', 'Last format parameter represents the time in downtime'),
if ((bool) $downtime->is_in_effect) { $this->timeSince($downtime->start)
$state = sprintf( );
$this->translate('in downtime %s', 'Last format parameter represents the time in downtime'), } else {
$this->timeSince($downtime->start) if ((bool) $downtime->is_fixed) {
); $state = sprintf(
} else { $this->translate('scheduled %s', 'Last format parameter represents the time scheduled'),
if ((bool) $downtime->is_fixed) { $this->timeUntil($downtime->start)
$state = sprintf( );
$this->translate('scheduled %s', 'Last format parameter represents the time scheduled'), } else {
$this->timeUntil($downtime->start) $state = sprintf(
); $this->translate('scheduled flexible %s', 'Last format parameter represents the time scheduled'),
} else { $this->timeUntil($downtime->start)
$state = sprintf( );
$this->translate('scheduled flexible %s', 'Last format parameter represents the time scheduled'), }
$this->timeUntil($downtime->start) }
); // Form is unset if the current user lacks the respective permission
} if (isset($delDowntimeForm)) {
} $deleteButton = clone($delDowntimeForm);
$deleteButton->populate(
array(
// Form is unset if the current user lacks the respective permission 'downtime_id' => $downtime->id,
if (isset($delDowntimeForm)) { 'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE
$deleteButton = clone($delDowntimeForm); )
$deleteButton->populate( );
array( } else {
'downtime_id' => $downtime->id, $deleteButton = '';
'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE }
) ?>
); <li class="comment-item">
} else { <h3>
$deleteButton = ''; <span class="author"><?= $this->escape($downtime->author_name) ?></span>
} <?= $this->timeAgo($downtime->entry_time) ?>
<?= $deleteButton ?>
?> </h3>
<p>
<li class="comment-item"> <span class="sr-only"><?= $this->translate('Downtime') ?></span>
<h3> <?= $state ?> -
<span class="author"><?= $this->escape($downtime->author_name) ?></span> <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)) ?>
<?= $this->timeAgo($downtime->entry_time) ?> </p>
<?= $deleteButton ?> </li>
</h3> <?php endforeach ?>
<p> <span class="sr-only"><?= $this->translate('Downtime'); ?></span><?= $state; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)); ?></p> </ul>
</li> <?php endif ?>
<?php endforeach ?>
</ul>
<?php endif ?>
</td> </td>
</tr> </tr>