monitoring: Fix mess in CommentsController and the related view script

This commit is contained in:
Eric Lippmann 2015-08-27 16:04:24 +02:00
parent 78701ab2b6
commit 2533ebc8d5
2 changed files with 28 additions and 27 deletions

View File

@ -9,21 +9,26 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm;
use Icinga\Web\Url;
/**
* Display detailed information about a comment
* Display detailed information about comments
*/
class CommentsController extends Controller
{
/**
* The fetched comments
* The comments view
*
* @var array
* @var \Icinga\Module\Monitoring\DataView\Comment
*/
protected $comments;
/**
* Fetch all comments matching the current filter and add tabs
* Filter from request
*
* @throws Zend_Controller_Action_Exception
* @var Filter
*/
protected $filter;
/**
* Fetch all comments matching the current filter and add tabs
*/
public function init()
{
@ -48,19 +53,16 @@ class CommentsController extends Controller
))->addFilter($this->filter);
$this->applyRestriction('monitoring/filter/objects', $query);
$this->comments = $query->getQuery()->fetchAll();
if (false === $this->comments) {
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
}
$this->comments = $query;
$this->getTabs()->add(
'comments',
array(
'icon' => 'comment',
'label' => $this->translate('Comments') . sprintf(' (%d)', $query->count()),
'title' => $this->translate(
'Display detailed information about multiple comments.'
),
'icon' => 'comment',
'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)),
'url' =>'monitoring/comments/show'
)
)->activate('comments');
@ -91,9 +93,9 @@ class CommentsController extends Controller
$delCommentForm->setTitle($this->view->translate('Remove all Comments'));
$delCommentForm->addDescription(sprintf(
$this->translate('Confirm removal of %d comments.'),
count($this->comments)
$this->comments->count()
));
$delCommentForm->setComments($this->comments)
$delCommentForm->setComments($this->comments->fetchAll())
->setRedirectUrl($listCommentsLink)
->handleRequest();
$this->view->delCommentForm = $delCommentForm;

View File

@ -1,10 +1,9 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?= $this->tabs ?>
<?php endif ?>
<div data-base-target='_next'>
<?= $this->render('partials/comment/comments-header.phtml'); ?>
<?= $this->render('partials/comment/comments-header.phtml') ?>
</div>
</div>
@ -13,7 +12,7 @@
<?= $this->qlink(
sprintf(
$this->translate('Remove %d comments'),
count($comments)
$comments->count()
),
$removeAllLink,
null,