Conform to coding guidelines

This commit is contained in:
Matthias Jentsch 2015-05-04 16:29:07 +02:00
parent 5477a2f18e
commit e5e3e80300
4 changed files with 65 additions and 33 deletions

View File

@ -11,17 +11,27 @@ use Icinga\Web\Widget\Tabextension\DashboardAction;
*/ */
class Monitoring_CommentController extends Controller class Monitoring_CommentController extends Controller
{ {
/**
* The fetched comment
*
* @var stdClass
*/
protected $comment; protected $comment;
/**
* Fetch the first comment with the given id and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init() public function init()
{ {
$commentId = $this->params->get('comment_id'); $commentId = $this->params->get('comment_id');
$this->comment = $this->backend->select()->from('comment', array( $this->comment = $this->backend->select()->from('comment', array(
'id' => 'comment_internal_id', 'id' => 'comment_internal_id',
'objecttype' => 'comment_objecttype', 'objecttype' => 'comment_objecttype',
'comment' => 'comment_data', 'comment' => 'comment_data',
'author' => 'comment_author_name', 'author' => 'comment_author_name',
'timestamp' => 'comment_timestamp', 'timestamp' => 'comment_timestamp',
'type' => 'comment_type', 'type' => 'comment_type',
'persistent' => 'comment_is_persistent', 'persistent' => 'comment_is_persistent',
@ -35,21 +45,23 @@ class Monitoring_CommentController extends Controller
if (false === $this->comment) { if (false === $this->comment) {
throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
} }
$this->getTabs() $this->getTabs()->add(
->add( 'comment',
'comment', array(
array( 'title' => $this->translate(
'title' => $this->translate( 'Display detailed information about a comment.'
'Display detailed information about a comment.' ),
), 'icon' => 'comment',
'icon' => 'comment', 'label' => $this->translate('Comment'),
'label' => $this->translate('Comment'), 'url' =>'monitoring/comments/show'
'url' =>'monitoring/comments/show' )
)
)->activate('comment')->extend(new DashboardAction()); )->activate('comment')->extend(new DashboardAction());
} }
/**
* Display comment detail view
*/
public function showAction() public function showAction()
{ {
$this->view->comment = $this->comment; $this->view->comment = $this->comment;
@ -57,7 +69,12 @@ class Monitoring_CommentController extends Controller
$this->view->delCommentForm = $this->createDelCommentForm(); $this->view->delCommentForm = $this->createDelCommentForm();
} }
} }
/**
* Create a command form to delete a single comment
*
* @return DeleteCommentCommandForm
*/
private function createDelCommentForm() private function createDelCommentForm()
{ {
$this->assertPermission('monitoring/command/comment/delete'); $this->assertPermission('monitoring/command/comment/delete');

View File

@ -12,14 +12,24 @@ use Icinga\Data\Filter\Filter;
*/ */
class Monitoring_CommentsController extends Controller class Monitoring_CommentsController extends Controller
{ {
/**
* The fetched comments
*
* @var array
*/
protected $comments; protected $comments;
/**
* Fetch all comments matching the current filter and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init() public function init()
{ {
$this->filter = Filter::fromQueryString(str_replace( $this->filter = Filter::fromQueryString(str_replace(
'comment_id', 'comment_id',
'comment_internal_id', 'comment_internal_id',
(string)$this->params (string)$this->params
)); ));
$this->comments = $this->backend->select()->from('comment', array( $this->comments = $this->backend->select()->from('comment', array(
'id' => 'comment_internal_id', 'id' => 'comment_internal_id',
@ -40,20 +50,22 @@ class Monitoring_CommentsController extends Controller
throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
} }
$this->getTabs() $this->getTabs()->add(
->add( 'comments',
'comments', array(
array( 'title' => $this->translate(
'title' => $this->translate( 'Display detailed information about multiple comments.'
'Display detailed information about multiple comments.' ),
), 'icon' => 'comment',
'icon' => 'comment', 'label' => $this->translate('Comments'),
'label' => $this->translate('Comments'), 'url' =>'monitoring/comments/show'
'url' =>'monitoring/comments/show' )
)
)->activate('comments')->extend(new DashboardAction()); )->activate('comments')->extend(new DashboardAction());
} }
/**
* Display the detail view for a comment list
*/
public function showAction() public function showAction()
{ {
$this->view->comments = $this->comments; $this->view->comments = $this->comments;
@ -63,6 +75,9 @@ class Monitoring_CommentsController extends Controller
->setParams($this->params); ->setParams($this->params);
} }
/**
* Display the form for removing a comment list
*/
public function removeAllAction() public function removeAllAction()
{ {
$this->assertPermission('monitoring/command/comment/delete'); $this->assertPermission('monitoring/command/comment/delete');

View File

@ -21,7 +21,7 @@
$this->comment->service_description, $this->comment->service_description,
$this->comment->service_display_name, $this->comment->service_display_name,
$this->comment->host_name, $this->comment->host_name,
$this->comment->host_display_name $this->comment->host_display_names
); ?> ); ?>
</td> </td>
<?php else: ?> <?php else: ?>

View File

@ -22,7 +22,7 @@ if (count($comments) === 0) {
} }
?> ?>
<table data-base-target="_next" <table data-base-target="_next"
class="action comments multiselect" class="action comments multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show" data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show"
data-icinga-multiselect-data="comment_id"> data-icinga-multiselect-data="comment_id">
<tbody> <tbody>