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
$addLink = '';
$addLink = false;
if ($this->hasPermission('monitoring/command/downtime/schedule')) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
@ -32,78 +30,68 @@ if ($this->hasPermission('monitoring/command/downtime/schedule')) {
);
}
}
if (empty($object->comments) && ! $addLink) {
return;
}
?>
<tr>
<th><?php
echo $this->translate('Downtimes');
if (! empty($object->downtimes) && $addLink) {
echo '<br />' . $addLink;
}
?></th>
<td data-base-target="_self">
<?php if (empty($object->downtimes)): ?>
<?= $addLink ?>
<?php else: ?>
<ul class="inline-comments">
<?php foreach ($object->downtimes as $downtime): ?>
<?php
if ((bool) $downtime->is_in_effect) {
$state = sprintf(
$this->translate('in downtime %s', 'Last format parameter represents the time in downtime'),
$this->timeSince($downtime->start)
);
} else {
if ((bool) $downtime->is_fixed) {
$state = sprintf(
$this->translate('scheduled %s', 'Last format parameter represents the time scheduled'),
$this->timeUntil($downtime->start)
);
} else {
$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(
'downtime_id' => $downtime->id,
'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE
)
);
} else {
$deleteButton = '';
}
?>
<li class="comment-item">
<h3>
<span class="author"><?= $this->escape($downtime->author_name) ?></span>
<?= $this->timeAgo($downtime->entry_time) ?>
<?= $deleteButton ?>
</h3>
<p> <span class="sr-only"><?= $this->translate('Downtime'); ?></span><?= $state; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)); ?></p>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<?php if (empty($object->downtimes)):
echo $addLink;
else: ?>
<ul class="inline-comments">
<?php foreach ($object->downtimes as $downtime):
if ((bool) $downtime->is_in_effect) {
$state = sprintf(
$this->translate('in downtime %s', 'Last format parameter represents the time in downtime'),
$this->timeSince($downtime->start)
);
} else {
if ((bool) $downtime->is_fixed) {
$state = sprintf(
$this->translate('scheduled %s', 'Last format parameter represents the time scheduled'),
$this->timeUntil($downtime->start)
);
} else {
$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(
'downtime_id' => $downtime->id,
'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE
)
);
} else {
$deleteButton = '';
}
?>
<li class="comment-item">
<h3>
<span class="author"><?= $this->escape($downtime->author_name) ?></span>
<?= $this->timeAgo($downtime->entry_time) ?>
<?= $deleteButton ?>
</h3>
<p>
<span class="sr-only"><?= $this->translate('Downtime') ?></span>
<?= $state ?> -
<?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)) ?>
</p>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</td>
</tr>