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 @@
<div class="controls">
<?= $this->tabs ?>
<div style="margin: 1em">
<?= $this->sortControl->render($this); ?>
</div>
<?= $this->paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?>
</div>
<div class="content">
<table data-base-target="_next" class="action comments">
<tbody>
<?php <?php
$cf = $this->getHelper('CommandForm'); $helper = $this->getHelper('CommandForm');
if (count($comments) === 0) {
echo t('No comments matching the filter');
}
foreach ($comments as $comment):
?> ?>
<tr>
<td style="width: 5em; text-align: center;"> <?php if (false === $this->compact): ?>
<div class="controls">
<?= $this->tabs->render($this); ?>
<div style="margin: 1em" class="dontprint">
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
</div>
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $comments->count())); ?>
<?= $this->paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?>
</div>
<?php endif ?>
<div class="content">
<?php if (empty($comments)): ?>
<?= $this->translate('No comments matching the filter') ?>
</div>
<?php return; endif ?>
<table data-base-target="_next" class="action comments">
<tbody>
<?php foreach ($comments as $comment): ?>
<?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');
$tooltip = $this->translate('Comment was caused by a flapping host or service.');
break; break;
case 'comment': case 'comment':
$icon = 'user'; $icon = 'user';
$tooltip = 'Comment was created by an user.'; $title = $this->translate('User Comment');
$tooltip = $this->translate('Comment was created by an user.');
break; 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;">
<?= $this->icon($icon . '.png', $tooltip) ?>
<br>
<strong><?= $this->escape($title); ?></strong>
<br>
<?= $this->prefixedTimeSince($comment->timestamp); ?>
</td> </td>
<td> <td>
<?php if ($comment->objecttype === 'service'): ?><?= $this->icon('service.png', 'Service comment') ?> <?= $this->qlink( <?php if ($comment->objecttype === 'service'): ?>
$comment->service, <?= $this->icon('service.png'); ?> <a href="<?= $this->href('monitoring/show/service', array(
'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> </td>
<td style="width: 2em"> <?php
<?php
$data = array( $data = array(
'commentid' => $comment->id, 'commentid' => $comment->id,
'host' => $comment->host 'host' => $comment->host
); );
if ($comment->objecttype === 'service') { if ($comment->objecttype === 'service') {
$data['service'] = $comment->service; $data['service'] = $comment->service;
} }
?>
// echo $cf->iconSubmitForm( <td style="width: 2em">
// 'img/icons/remove.png', <?= $helper->labelSubmitForm(
echo $cf->labelSubmitForm(
'X', 'X',
'Remove comment', $this->translate('Remove Comment'),
'link-like', 'link-like',
'removecomment', 'removecomment',
$data $data
); ); ?>
?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>