diff --git a/library/Icinga/Data/BaseQuery.php b/library/Icinga/Data/BaseQuery.php index 0bbcc281c..559386099 100644 --- a/library/Icinga/Data/BaseQuery.php +++ b/library/Icinga/Data/BaseQuery.php @@ -15,7 +15,7 @@ abstract class BaseQuery implements Filterable /** * Sort ascending */ - const SORT_ASC = 1; + const SORT_ASC = 1; /** * Sort descending @@ -97,7 +97,7 @@ abstract class BaseQuery implements Filterable * The Query will return the default attribute the attributes parameter is omitted * * @param String $target The target of this query (tablename, objectname, depends on the concrete implementation) - * @param array $columns An optional array of columns to select, if none are given the default + * @param array $columns An optional array of columns to select, if none are given the default * columnset is returned * * @return self Fluent interface @@ -119,7 +119,7 @@ abstract class BaseQuery implements Filterable * backend-specific query implementation. * * @param string $expression Implementation specific search expression - * @param mixed $parameters Implementation specific search value to use for query placeholders + * @param mixed $parameters Implementation specific search value to use for query placeholders * * @return self Fluent Interface * @see BaseQuery::andWhere() This is an alias to andWhere() @@ -136,21 +136,20 @@ abstract class BaseQuery implements Filterable * backend-specific query implementation. * * @param string $expression Implementation specific search expression - * @param mixed $parameters Implementation specific search value to use for query placeholders - + * @param mixed $parameters Implementation specific search value to use for query placeholders * @return self Fluent interface */ - public function andWhere($expression, $parameters = null) - { - $node = $this->parseFilterExpression($expression, $parameters); - if ($node === null) { - Logger::debug('Ignoring invalid filter expression: %s (params: %s)', $expression, $parameters); - return $this; - } - $this->filter->insert(Node::createAndNode()); - $this->filter->insert($node); - return $this; - } + public function andWhere($expression, $parameters = null) + { + $node = $this->parseFilterExpression($expression, $parameters); + if ($node === null) { + Logger::debug('Ignoring invalid filter expression: %s (params: %s)', $expression, $parameters); + return $this; + } + $this->filter->insert(Node::createAndNode()); + $this->filter->insert($node); + return $this; + } /** * Add an lower priority filter expression to be applied on this query @@ -159,8 +158,7 @@ abstract class BaseQuery implements Filterable * backend-specific query implementation. * * @param string $expression Implementation specific search expression - * @param mixed $parameters Implementation specific search value to use for query placeholders - + * @param mixed $parameters Implementation specific search value to use for query placeholders * @return self Fluent interface */ public function orWhere($expression, $parameters = null) @@ -256,7 +254,7 @@ abstract class BaseQuery implements Filterable * * * @param string $columnOrAlias Column, may contain direction separated by space - * @param int $dir Sort direction + * @param int $dir Sort direction * * @return BaseQuery */ @@ -299,7 +297,7 @@ abstract class BaseQuery implements Filterable */ public function limit($count = null, $offset = null) { - $this->limitCount = $count !== null ? intval($count) : null; + $this->limitCount = $count !== null ? intval($count) : null; $this->limitOffset = intval($offset); return $this; diff --git a/library/Icinga/Data/DataArray/Query.php b/library/Icinga/Data/DataArray/Query.php index a1c412053..6b62a3295 100644 --- a/library/Icinga/Data/DataArray/Query.php +++ b/library/Icinga/Data/DataArray/Query.php @@ -96,6 +96,4 @@ class Query extends BaseQuery { return null; } - - } diff --git a/library/Icinga/Data/DatasourceInterface.php b/library/Icinga/Data/DatasourceInterface.php index 71dffbf79..1088010af 100644 --- a/library/Icinga/Data/DatasourceInterface.php +++ b/library/Icinga/Data/DatasourceInterface.php @@ -11,5 +11,4 @@ interface DatasourceInterface * @return BaseQuery */ public function select(); - } diff --git a/library/Icinga/Data/Db/Query.php b/library/Icinga/Data/Db/Query.php index 97f1db136..92f37448b 100644 --- a/library/Icinga/Data/Db/Query.php +++ b/library/Icinga/Data/Db/Query.php @@ -111,7 +111,7 @@ class Query extends BaseQuery /** * Create the Zend_Db select query for this query */ - private function createSelectQuery() + private function createSelectQuery() { $this->selectQuery = clone($this->baseQuery); $this->selectQuery->columns($this->getColumns()); @@ -170,7 +170,7 @@ class Query extends BaseQuery if ($this->useSubqueryCount) { $this->countQuery = $this->createCountAsSubquery(); } else { - $this->countQuery =$this->createCustomCountQuery(); + $this->countQuery = $this->createCustomCountQuery(); } } @@ -184,6 +184,7 @@ class Query extends BaseQuery { } + /** * Create the Zend_Db select and count query objects for this instance */ @@ -268,10 +269,10 @@ class Query extends BaseQuery public function dump() { return "QUERY\n=====\n" - . $this->getSelectQuery() - . "\n\nCOUNT\n=====\n" - . $this->getCountQuery() - . "\n\n"; + . $this->getSelectQuery() + . "\n\nCOUNT\n=====\n" + . $this->getCountQuery() + . "\n\n"; } /** @@ -310,7 +311,7 @@ class Query extends BaseQuery } } return null; - } + } public function applyFilter() { @@ -318,6 +319,4 @@ class Query extends BaseQuery $parser->treeToSql($this->getFilter(), $this->baseQuery); $this->clearFilter(); } - - } diff --git a/library/Icinga/Data/Db/TreeToSqlParser.php b/library/Icinga/Data/Db/TreeToSqlParser.php index ec26a621a..79de0e53d 100644 --- a/library/Icinga/Data/Db/TreeToSqlParser.php +++ b/library/Icinga/Data/Db/TreeToSqlParser.php @@ -130,7 +130,8 @@ class TreeToSqlParser if ($this->query->isAggregateColumn($node->left)) { $this->type = 'HAVING'; } - $queryString .= ' ' . (is_integer($node->right) ? $node->operator : $this->getSqlOperator($node->operator)) . ' '; + $queryString .= ' ' . (is_integer($node->right) ? + $node->operator : $this->getSqlOperator($node->operator)) . ' '; $queryString .= $this->getParameterValue($node); return $queryString; } @@ -152,11 +153,8 @@ class TreeToSqlParser if ($this->query->isTimestamp($node->left)) { $node->context = Node::CONTEXT_TIMESTRING; } - switch($node->context) { - case Node::CONTEXT_TIMESTRING: - $value = strtotime($value); - default: - break; + if ($node->context === Node::CONTEXT_TIMESTRING) { + $value = strtotime($value); } return $this->query->getDatasource()->getConnection()->quote($value); } diff --git a/library/Icinga/Filter/Registry.php b/library/Icinga/Filter/Registry.php index 83b8a726c..83a1a3911 100644 --- a/library/Icinga/Filter/Registry.php +++ b/library/Icinga/Filter/Registry.php @@ -40,4 +40,4 @@ use Icinga\Filter\Query\Tree; interface Registry { public static function getUrlForTarget($domain, Tree $filter); -} \ No newline at end of file +} diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php index 1ee620514..ca620916d 100644 --- a/library/Icinga/Web/Request.php +++ b/library/Icinga/Web/Request.php @@ -62,6 +62,4 @@ class Request extends Zend_Controller_Request_Http { return $this->user; } - - } diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 63fd1244b..769271024 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -34,7 +34,6 @@ use Zend_View_Abstract; use Icinga\Web\Form\Decorator\ConditionalHidden; use Zend_Form_Element_Submit; - /** * Sortbox widget * diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index 424076824..c3b78022e 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -238,7 +238,8 @@ class Tab implements Widget $tagParams .= ' ' . $key . '="' . $value . '"'; } } - $tab = '' . $caption . ''; + $tab = '' . $caption . ''; } else { $tab = $caption; } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php index e47a2a32b..bac78a7cd 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php @@ -19,4 +19,3 @@ class CommenthistoryQuery extends IdoQuery ) ); } - diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index c4d6d152c..9958a3819 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -80,8 +80,7 @@ class Controller extends ActionController exit; } if ($this->_getParam('format') === 'json' - || $this->_request->getHeader('Accept') === 'application/json') - { + || $this->_request->getHeader('Accept') === 'application/json') { header('Content-type: application/json'); echo json_encode($query->fetchAll()); exit; diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroup.php b/modules/monitoring/library/Monitoring/DataView/Hostgroup.php index 876ad398e..20ab4e279 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroup.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroup.php @@ -71,5 +71,4 @@ class Hostgroup extends DataView ) ); } - } diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroup.php b/modules/monitoring/library/Monitoring/DataView/Servicegroup.php index bbbc7d243..897f26b66 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroup.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroup.php @@ -65,6 +65,4 @@ class Servicegroup extends DataView ) ); } - - -} \ No newline at end of file +} diff --git a/modules/monitoring/library/Monitoring/Filter/Registry.php b/modules/monitoring/library/Monitoring/Filter/Registry.php index 3f8f7a232..e7c42db87 100644 --- a/modules/monitoring/library/Monitoring/Filter/Registry.php +++ b/modules/monitoring/library/Monitoring/Filter/Registry.php @@ -79,9 +79,9 @@ class Registry implements FilterRegistry $type = new TimeRangeSpecifier(); $type->setOperator( array( - 'Older Than' => Node::OPERATOR_LESS_EQ, + 'Older Than' => Node::OPERATOR_LESS_EQ, 'Is Older Than' => Node::OPERATOR_LESS_EQ, - 'Newer Than' => Node::OPERATOR_GREATER_EQ, + 'Newer Than' => Node::OPERATOR_GREATER_EQ, 'Is Newer Than' => Node::OPERATOR_GREATER_EQ, ) )->setForcePastValue(true); @@ -101,21 +101,23 @@ class Registry implements FilterRegistry FilterAttribute::create(new TextFilter()) ->setHandledAttributes('Name', 'Hostname') ->setField('host_name') + )->registerAttribute( + FilterAttribute::create(StatusFilter::createForHost()) + ->setField('host_state') )->registerAttribute( - FilterAttribute::create(StatusFilter::createForHost()) - ->setField('host_state') - )->registerAttribute( - FilterAttribute::create(new BooleanFilter( - array( - 'host_is_flapping' => 'Flapping', - 'host_problem' => 'In Problem State', - 'host_notifications_enabled' => 'Sending Notifications', - 'host_active_checks_enabled' => 'Active', - 'host_passive_checks_enabled' => 'Accepting Passive Checks', - 'host_handled' => 'Handled', - 'host_in_downtime' => 'In Downtime', + FilterAttribute::create( + new BooleanFilter( + array( + 'host_is_flapping' => 'Flapping', + 'host_problem' => 'In Problem State', + 'host_notifications_enabled' => 'Sending Notifications', + 'host_active_checks_enabled' => 'Active', + 'host_passive_checks_enabled' => 'Accepting Passive Checks', + 'host_handled' => 'Handled', + 'host_in_downtime' => 'In Downtime', + ) ) - )) + ) )->registerAttribute( FilterAttribute::create(self::getLastCheckFilterType()) ->setHandledAttributes('Last Check', 'Check') @@ -141,26 +143,28 @@ class Registry implements FilterRegistry FilterAttribute::create(new TextFilter()) ->setHandledAttributes('Name', 'Servicename') ->setField('service_name') - )->registerAttribute( - FilterAttribute::create(StatusFilter::createForService()) - ->setField('service_state') + )->registerAttribute( + FilterAttribute::create(StatusFilter::createForService()) + ->setField('service_state') )->registerAttribute( FilterAttribute::create(StatusFilter::createForHost()) ->setHandledAttributes('Host') ->setField('host_state') )->registerAttribute( - FilterAttribute::create(new BooleanFilter( + FilterAttribute::create( + new BooleanFilter( array( - 'service_is_flapping' => 'Flapping', - 'service_problem' => 'In Problem State', - 'service_notifications_enabled' => 'Sending Notifications', - 'service_active_checks_enabled' => 'Active', - 'service_passive_checks_enabled' => 'Accepting Passive Checks', - 'service_handled' => 'Handled', - 'service_in_downtime' => 'In Downtime', - 'host_in_downtime' => 'In Host Downtime' + 'service_is_flapping' => 'Flapping', + 'service_problem' => 'In Problem State', + 'service_notifications_enabled' => 'Sending Notifications', + 'service_active_checks_enabled' => 'Active', + 'service_passive_checks_enabled' => 'Accepting Passive Checks', + 'service_handled' => 'Handled', + 'service_in_downtime' => 'In Downtime', + 'host_in_downtime' => 'In Host Downtime' ) - )) + ) + ) )->registerAttribute( FilterAttribute::create(self::getLastCheckFilterType()) ->setHandledAttributes('Last Check', 'Check') @@ -201,7 +205,7 @@ class Registry implements FilterRegistry } $urlParser = new UrlViewFilter($view); $lastQuery = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY); - $lastPath = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH); + $lastPath = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH); $lastFilter = $urlParser->parseUrl($lastQuery); $lastParameters = array(); @@ -226,5 +230,4 @@ class Registry implements FilterRegistry $urlString .= $urlParser->fromTree($filter); return '/' . $urlString; } - } diff --git a/modules/monitoring/library/Monitoring/Filter/UrlViewFilter.php b/modules/monitoring/library/Monitoring/Filter/UrlViewFilter.php index cc5900d5b..34e045648 100644 --- a/modules/monitoring/library/Monitoring/Filter/UrlViewFilter.php +++ b/modules/monitoring/library/Monitoring/Filter/UrlViewFilter.php @@ -26,10 +26,8 @@ */ // {{{ICINGA_LICENSE_HEADER}}} - namespace Icinga\Module\Monitoring\Filter; - use Icinga\Filter\Filterable; use Icinga\Filter\Query\Tree; use Icinga\Filter\Query\Node; @@ -117,7 +115,7 @@ class UrlViewFilter public function fromRequest($request) { - if($request->getParam('query')) { + if ($request->getParam('query')) { return $this->parseUrl(urldecode($request->getParam('query'))); } else { return $this->parseUrl(parse_url($request->getBaseUrl(), PHP_URL_QUERY)); diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index d66d12f4f..0c3ff8927 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -181,7 +181,7 @@ abstract class AbstractObject { if ($request->has('service') && $request->has('host')) { return new Service($request); - } else if ($request->has('host')) { + } elseif ($request->has('host')) { return new Host($request); } } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 99008a031..ab812bed1 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -27,5 +27,4 @@ class Host extends AbstractObject $this->view = HostStatus::fromRequest($this->getRequest()); return $this->view->getQuery()->fetchRow(); } - }