Let comment view look more standardized and add limit control

refs #6637
This commit is contained in:
Johannes Meyer 2014-08-20 11:34:24 +02:00
parent 4eaf94cdf1
commit 4ceecf1146

View File

@ -1,98 +1,114 @@
<?php
$helper = $this->getHelper('CommandForm');
?>
<?php if (false === $this->compact): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->tabs->render($this); ?>
<div style="margin: 1em"> <div style="margin: 1em" class="dontprint">
<?= $this->sortControl->render($this); ?> <?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
</div> </div>
<?= $this->paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?> <?= $this->widget('limiter', array('url' => $this->url, 'max' => $comments->count())); ?>
<?= $this->paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?>
</div> </div>
<?php endif ?>
<div class="content"> <div class="content">
<table data-base-target="_next" class="action comments"> <?php if (empty($comments)): ?>
<tbody> <?= $this->translate('No comments matching the filter') ?>
<?php </div>
<?php return; endif ?>
$cf = $this->getHelper('CommandForm'); <table data-base-target="_next" class="action comments">
<tbody>
if (count($comments) === 0) { <?php foreach ($comments as $comment): ?>
echo t('No comments matching the filter');
}
foreach ($comments as $comment):
?>
<tr>
<td style="width: 5em; text-align: center;">
<?php <?php
switch ($comment->type) { switch ($comment->type) {
case 'flapping': case 'flapping':
$icon = 'flapping'; $icon = 'flapping';
$tooltip = 'Comment was caused by a flapping host or service.'; $title = $this->translate('Flapping');
break; $tooltip = $this->translate('Comment was caused by a flapping host or service.');
break;
case 'comment': case 'comment':
$icon = 'user'; $icon = 'user';
$tooltip = 'Comment was created by an user.'; $title = $this->translate('User Comment');
break; $tooltip = $this->translate('Comment was created by an user.');
break;
case 'downtime': case 'downtime':
$icon = 'down'; $icon = 'down';
$tooltip = 'Comment was caused by a downtime.'; $title = $this->translate('Downtime');
$tooltip = $this->translate('Comment was caused by a downtime.');
case 'ack': case 'ack':
$icon = 'acknowledgement'; $icon = 'acknowledgement';
$tooltip = 'Comment was caused by an acknowledgement.'; $title = $this->translate('Acknowledgement');
} $tooltip = $this->translate('Comment was caused by an acknowledgement.');
}
?> ?>
<?= $this->icon($icon . '.png', $tooltip) ?><br /> <tr class="state invalid">
<?= $this->timeSince($comment->timestamp) ?> <td class="state" style="width: 12em;">
</td> <?= $this->icon($icon . '.png', $tooltip) ?>
<td> <br>
<?php if ($comment->objecttype === 'service'): ?><?= $this->icon('service.png', 'Service comment') ?> <?= $this->qlink( <strong><?= $this->escape($title); ?></strong>
$comment->service, <br>
'monitoring/show/service', <?= $this->prefixedTimeSince($comment->timestamp); ?>
array( </td>
<td>
<?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('service.png'); ?> <a href="<?= $this->href('monitoring/show/service', array(
'host' => $comment->host, 'host' => $comment->host,
'service' => $comment->service, 'service' => $comment->service,
) )); ?>">
) ?> on<?php else: ?><?= $this->icon('host.png', 'Host comment') ?> <?php endif ?> <?= $this->qlink( <?= $comment->service; ?>
$comment->host, </a>
'monitoring/show/host', <small>
array( <?= $this->translate('on') . ' ' . $comment->host; ?>
</small>
<?php else: ?>
<?= $this->icon('host.png'); ?> <a href="<?= $this->href('monitoring/show/host', array(
'host' => $comment->host 'host' => $comment->host
) )); ?>">
) ?> by <strong><?= $this->escape($comment->author) ?></strong><br /> <?= $comment->host; ?>
<p><?= $this->escape($comment->comment) ?></p> </a>
<?php if ($comment->persistent): ?>Comment is persistent<br /><?php endif ?> <?php endif ?>
<b>Expires: </b> <?= <br>
($comment->expiration) ? <?= $this->icon('comment.png'); ?> <?= isset($comment->author)
$this->timeUntil($comment->expiration) : ? '[' . $comment->author . '] '
'Never' : '';
?><?= $this->escape($comment->comment); ?>
<br>
<?= $comment->persistent
? $this->translate('This comment is persistent.')
: $this->translate('This comment is not persistent.');
?>
<br>
<?= $comment->expiration ? sprintf(
$this->translate('This comment expires on %s at %s.'),
date('d.m.y', $comment-expiration),
date('H:i', $comment->expiration)
) : $this->translate('This comment does not expire.'); ?>
</td>
<?php
$data = array(
'commentid' => $comment->id,
'host' => $comment->host
);
if ($comment->objecttype === 'service') {
$data['service'] = $comment->service;
}
?> ?>
</td> <td style="width: 2em">
<td style="width: 2em"> <?= $helper->labelSubmitForm(
<?php 'X',
$this->translate('Remove Comment'),
$data = array( 'link-like',
'commentid' => $comment->id, 'removecomment',
'host' => $comment->host $data
); ); ?>
</td>
if ($comment->objecttype === 'service') { </tr>
$data['service'] = $comment->service; <?php endforeach ?>
} </tbody>
</table>
// echo $cf->iconSubmitForm( </div>
// 'img/icons/remove.png',
echo $cf->labelSubmitForm(
'X',
'Remove comment',
'link-like',
'removecomment',
$data
);
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>