diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index c5b0e929c..8b2bb3715 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -148,7 +148,6 @@ class AuthenticationController extends ActionController $isRemoteUser = $auth->getUser()->isRemoteUser(); $auth->removeAuthorization(); if ($isRemoteUser === true) { - $this->_helper->layout->setLayout('login'); $this->_response->setHttpResponseCode(401); } else { $this->redirectToLogin(); diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 83ec0dd1d..05e66504b 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -19,7 +19,7 @@ class IndexController extends ActionController public function preDispatch() { if ($this->getRequest()->getActionName() !== 'welcome') { - $this->redirectNow('dashboard'); + $this->redirectNow(Url::fromRequest()->setPath('dashboard')); } } diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index c4354cee2..e00b9371d 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -29,7 +29,7 @@ $iframeClass = $isIframe ? ' iframe' : ''; <?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?> - + - diff --git a/application/views/scripts/config/module.phtml b/application/views/scripts/config/module.phtml index 8b82b02be..c74cac80d 100644 --- a/application/views/scripts/config/module.phtml +++ b/application/views/scripts/config/module.phtml @@ -4,7 +4,7 @@
translate('There is no such module installed.') ?> - + getDependencies(); $restrictions = $module->getProvidedRestrictions(); diff --git a/application/views/scripts/config/modules.phtml b/application/views/scripts/config/modules.phtml index e0204b24f..c0951d415 100644 --- a/application/views/scripts/config/modules.phtml +++ b/application/views/scripts/config/modules.phtml @@ -14,7 +14,7 @@ icon('success.png', $this->translate('Module is enabled')) ?> icon('remove.png', $this->translate('Module is disabled')) ?> - + level) !== null) { if (is_numeric($level)) { - if (! isset(static::$levels[(int) $level])) { + $level = (int) $level; + if (! isset(static::$levels[$level])) { throw new ConfigurationError( 'Can\'t set logging level %d. Logging level is not defined. Use one of %s or one of the' . ' Logger\'s constants.', @@ -92,7 +93,7 @@ class Logger implode(', ', array_keys(static::$levels)) ); } - $this->level = static::$levels[(int) $level]; + $this->level = $level; } else { $level = strtoupper($level); $levels = array_flip(static::$levels); @@ -155,7 +156,7 @@ class Logger */ public function log($level, $message) { - if ($this->writer !== null && $this->level >= $level) { + if ($this->writer !== null && $this->level <= $level) { $this->writer->log($level, $message); } } diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 02c8bb3db..e90bc1c5e 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -342,7 +342,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', t('Notifications')) + $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0) ->setYAxis(new LinearUnit(10)); @@ -470,7 +470,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', t('Notifications')) + $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0) ->setYAxis(new LinearUnit(10)); @@ -530,12 +530,12 @@ class Monitoring_AlertsummaryController extends Controller $box = new SelectBox( 'intervalBox', array( - '1d' => t('One day'), - '1w' => t('One week'), - '1m' => t('One month'), - '1y' => t('One year') + '1d' => mt('monitoring', 'One day'), + '1w' => mt('monitoring', 'One week'), + '1m' => mt('monitoring', 'One month'), + '1y' => mt('monitoring', 'One year') ), - t('Report interval'), + mt('monitoring', 'Report interval'), 'interval' ); $box->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 0fffcbab7..2024f83f4 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -143,35 +143,35 @@ class Monitoring_ChartController extends Controller } $this->view->chart = new GridChart(); $this->view->chart->alignTopLeft(); - $this->view->chart->setAxisLabel('', t('Services')) + $this->view->chart->setAxisLabel('', mt('monitoring', 'Services')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0); - $tooltip = t('{title}:
{value} of {sum} services are {label}'); + $tooltip = mt('monitoring', '{title}:
{value} of {sum} services are {label}'); $this->view->chart->drawBars( array( - 'label' => t('Ok'), + 'label' => mt('monitoring', 'Ok'), 'color' => '#44bb77', 'stack' => 'stack1', 'data' => $okBars, 'tooltip' => $tooltip ), array( - 'label' => t('Warning'), + 'label' => mt('monitoring', 'Warning'), 'color' => '#ffaa44', 'stack' => 'stack1', 'data' => $warningBars, 'tooltip' => $tooltip ), array( - 'label' => t('Critical'), + 'label' => mt('monitoring', 'Critical'), 'color' => '#ff5566', 'stack' => 'stack1', 'data' => $critBars, 'tooltip' => $tooltip ), array( - 'label' => t('Unknown'), + 'label' => mt('monitoring', 'Unknown'), 'color' => '#dd66ff', 'stack' => 'stack1', 'data' => $unknownBars, @@ -199,29 +199,29 @@ class Monitoring_ChartController extends Controller $hostgroup->hosts_unreachable_unhandled ); } - $tooltip = t('{title}:
{value} of {sum} hosts are {label}'); + $tooltip = mt('monitoring', '{title}:
{value} of {sum} hosts are {label}'); $this->view->chart = new GridChart(); $this->view->chart->alignTopLeft(); - $this->view->chart->setAxisLabel('', t('Hosts')) + $this->view->chart->setAxisLabel('', mt('monitoring', 'Hosts')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0); $this->view->chart->drawBars( array( - 'label' => t('Up'), + 'label' => mt('monitoring', 'Up'), 'color' => '#44bb77', 'stack' => 'stack1', 'data' => $upBars, 'tooltip' => $tooltip ), array( - 'label' => t('Down'), + 'label' => mt('monitoring', 'Down'), 'color' => '#ff5566', 'stack' => 'stack1', 'data' => $downBars, 'tooltip' => $tooltip ), array( - 'label' => t('Unreachable'), + 'label' => mt('monitoring', 'Unreachable'), 'color' => '#dd66ff', 'stack' => 'stack1', 'data' => $unreachableBars, @@ -248,13 +248,13 @@ class Monitoring_ChartController extends Controller 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#ffff00', '#ffff33', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( $query->services_ok . ' Up Services', - $query->services_warning_handled . t(' Warning Services (Handled)'), - $query->services_warning_unhandled . t(' Warning Services (Unhandled)'), - $query->services_critical_handled . t(' Down Services (Handled)'), - $query->services_critical_unhandled . t(' Down Services (Unhandled)'), - $query->services_unknown_handled . t(' Unreachable Services (Handled)'), - $query->services_unknown_unhandled . t(' Unreachable Services (Unhandled)'), - $query->services_pending . t(' Pending Services') + $query->services_warning_handled . mt('monitoring', ' Warning Services (Handled)'), + $query->services_warning_unhandled . mt('monitoring', ' Warning Services (Unhandled)'), + $query->services_critical_handled . mt('monitoring', ' Down Services (Handled)'), + $query->services_critical_unhandled . mt('monitoring', ' Down Services (Unhandled)'), + $query->services_unknown_handled . mt('monitoring', ' Unreachable Services (Handled)'), + $query->services_unknown_unhandled . mt('monitoring', ' Unreachable Services (Unhandled)'), + $query->services_pending . mt('monitoring', ' Pending Services') ) )); } @@ -274,12 +274,12 @@ class Monitoring_ChartController extends Controller ), 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( - (int) $query->hosts_up . t(' Up Hosts'), - (int) $query->hosts_down_handled . t(' Down Hosts (Handled)'), - (int) $query->hosts_down_unhandled . t(' Down Hosts (Unhandled)'), - (int) $query->hosts_unreachable_handled . t(' Unreachable Hosts (Handled)'), - (int) $query->hosts_unreachable_unhandled . t(' Unreachable Hosts (Unhandled)'), - (int) $query->hosts_pending . t(' Pending Hosts') + (int) $query->hosts_up . mt('monitoring', ' Up Hosts'), + (int) $query->hosts_down_handled . mt('monitoring', ' Down Hosts (Handled)'), + (int) $query->hosts_down_unhandled . mt('monitoring', ' Down Hosts (Unhandled)'), + (int) $query->hosts_unreachable_handled . mt('monitoring', ' Unreachable Hosts (Handled)'), + (int) $query->hosts_unreachable_unhandled . mt('monitoring', ' Unreachable Hosts (Unhandled)'), + (int) $query->hosts_pending . mt('monitoring', ' Pending Hosts') ) ), array( 'data' => array( @@ -294,14 +294,14 @@ class Monitoring_ChartController extends Controller ), 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#ffff00', '#ffff33', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( - $query->services_ok . t(' Up Services'), - $query->services_warning_handled . t(' Warning Services (Handled)'), - $query->services_warning_unhandled . t(' Warning Services (Unhandled)'), - $query->services_critical_handled . t(' Down Services (Handled)'), - $query->services_critical_unhandled . t(' Down Services (Unhandled)'), - $query->services_unknown_handled . t(' Unreachable Services (Handled)'), - $query->services_unknown_unhandled . t(' Unreachable Services (Unhandled)'), - $query->services_pending . t(' Pending Services') + $query->services_ok . mt('monitoring', ' Up Services'), + $query->services_warning_handled . mt('monitoring', ' Warning Services (Handled)'), + $query->services_warning_unhandled . mt('monitoring', ' Warning Services (Unhandled)'), + $query->services_critical_handled . mt('monitoring', ' Down Services (Handled)'), + $query->services_critical_unhandled . mt('monitoring', ' Down Services (Unhandled)'), + $query->services_unknown_handled . mt('monitoring', ' Unreachable Services (Handled)'), + $query->services_unknown_unhandled . mt('monitoring', ' Unreachable Services (Unhandled)'), + $query->services_pending . mt('monitoring', ' Pending Services') ) )); } diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index de9c65b04..cfdd73360 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -73,7 +73,7 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(t('Backend "%s" successfully removed.'), $backendName)); + Notification::success(sprintf(mt('monitoring', 'Backend "%s" successfully removed.'), $backendName)); } else { return false; } @@ -105,7 +105,7 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(t('Instance "%s" successfully removed.'), $instanceName)); + Notification::success(sprintf(mt('monitoring', 'Instance "%s" successfully removed.'), $instanceName)); } else { return false; } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 48b068705..d34a8ba2f 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -46,7 +46,7 @@ class Monitoring_HostsController extends Controller $this->getTabs()->add( 'show', array( - 'title' => t('Hosts'), + 'title' => mt('monitoring', 'Hosts'), 'url' => Url::fromRequest() ) )->activate('show'); diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 1c8f671a0..e537496f9 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -395,10 +395,10 @@ class Monitoring_ListController extends Controller $orientationBox = new SelectBox( 'orientation', array( - '0' => t('Vertical'), - '1' => t('Horizontal') + '0' => mt('monitoring', 'Vertical'), + '1' => mt('monitoring', 'Horizontal') ), - t('Orientation'), + mt('monitoring', 'Orientation'), 'horizontal' ); $orientationBox->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php index 3cb15082a..52dfcf07f 100644 --- a/modules/monitoring/application/controllers/MultiController.php +++ b/modules/monitoring/application/controllers/MultiController.php @@ -54,7 +54,7 @@ class Monitoring_MultiController extends Controller $this->view->pie = $this->createPie( $this->view->states, $this->view->getHelper('MonitoringState')->getHostStateColors(), - t('Host State') + mt('monitoring', 'Host State') ); // Handle configuration changes @@ -117,12 +117,12 @@ class Monitoring_MultiController extends Controller $this->view->service_pie = $this->createPie( $this->view->service_states, $this->view->getHelper('MonitoringState')->getServiceStateColors(), - t('Service State') + mt('monitoring', 'Service State') ); $this->view->host_pie = $this->createPie( $this->view->host_states, $this->view->getHelper('MonitoringState')->getHostStateColors(), - t('Host State') + mt('monitoring', 'Host State') ); $this->view->errors = $errors; diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index c421ed881..11b983d45 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -46,7 +46,7 @@ class Monitoring_ServicesController extends Controller $this->getTabs()->add( 'show', array( - 'title' => t('Services'), + 'title' => mt('monitoring', 'Services'), 'url' => Url::fromRequest() ) )->activate('show'); diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index f78caafa6..061765f1c 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -35,32 +35,32 @@ class Monitoring_TimelineController extends Controller array( 'notify' => array( 'detailUrl' => $detailUrl, - 'label' => t('Notifications'), + 'label' => mt('monitoring', 'Notifications'), 'color' => '#3a71ea' ), 'hard_state' => array( 'detailUrl' => $detailUrl, - 'label' => t('Hard state changes'), + 'label' => mt('monitoring', 'Hard state changes'), 'color' => '#ff7000' ), 'comment' => array( 'detailUrl' => $detailUrl, - 'label' => t('Comments'), + 'label' => mt('monitoring', 'Comments'), 'color' => '#79bdba' ), 'ack' => array( 'detailUrl' => $detailUrl, - 'label' => t('Acknowledgements'), + 'label' => mt('monitoring', 'Acknowledgements'), 'color' => '#a2721d' ), 'dt_start' => array( 'detailUrl' => $detailUrl, - 'label' => t('Started downtimes'), + 'label' => mt('monitoring', 'Started downtimes'), 'color' => '#8e8e8e' ), 'dt_end' => array( 'detailUrl' => $detailUrl, - 'label' => t('Ended downtimes'), + 'label' => mt('monitoring', 'Ended downtimes'), 'color' => '#d5d6ad' ) ) @@ -88,13 +88,13 @@ class Monitoring_TimelineController extends Controller $box = new SelectBox( 'intervalBox', array( - '4h' => t('4 Hours'), - '1d' => t('One day'), - '1w' => t('One week'), - '1m' => t('One month'), - '1y' => t('One year') + '4h' => mt('monitoring', '4 Hours'), + '1d' => mt('monitoring', 'One day'), + '1w' => mt('monitoring', 'One week'), + '1m' => mt('monitoring', 'One month'), + '1y' => mt('monitoring', 'One year') ), - t('TimeLine interval'), + mt('monitoring', 'TimeLine interval'), 'interval' ); $box->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 079ea538a..472046636 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -29,7 +29,7 @@ class BackendConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_backends'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -51,7 +51,7 @@ class BackendConfigForm extends ConfigForm } if (empty($resources)) { - throw new ConfigurationError(t('Could not find any valid monitoring backend resources')); + throw new ConfigurationError(mt('monitoring', 'Could not find any valid monitoring backend resources')); } $this->resources = $resources; @@ -73,9 +73,9 @@ class BackendConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); } elseif ($this->config->get($name) !== null) { - throw new InvalidArgumentException(t('Monitoring backend already exists')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists')); } unset($values['name']); @@ -96,11 +96,11 @@ class BackendConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing')); } elseif (($backendConfig = $this->config->get($name)) === null) { - throw new InvalidArgumentException(t('Unknown monitoring backend provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); } unset($values['name']); @@ -121,9 +121,9 @@ class BackendConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); } elseif (($backendConfig = $this->config->get($name)) === null) { - throw new InvalidArgumentException(t('Unknown monitoring backend provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); } unset($this->config->{$name}); @@ -141,10 +141,10 @@ class BackendConfigForm extends ConfigForm try { if ($monitoringBackend === null) { // create new backend $this->add($this->getValues()); - $message = t('Monitoring backend "%s" has been successfully created'); + $message = mt('monitoring', 'Monitoring backend "%s" has been successfully created'); } else { // edit existing backend $this->edit($monitoringBackend, $this->getValues()); - $message = t('Monitoring backend "%s" has been successfully changed'); + $message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -170,9 +170,9 @@ class BackendConfigForm extends ConfigForm $monitoringBackend = $request->getQuery('backend'); if ($monitoringBackend !== null) { if ($monitoringBackend === '') { - throw new ConfigurationError(t('Monitoring backend name missing')); + throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing')); } elseif (false === isset($this->config->{$monitoringBackend})) { - throw new ConfigurationError(t('Unknown monitoring backend provided')); + throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided')); } $backendConfig = $this->config->{$monitoringBackend}->toArray(); @@ -201,7 +201,7 @@ class BackendConfigForm extends ConfigForm 'disabled', array( 'required' => true, - 'label' => t('Disable This Backend') + 'label' => mt('monitoring', 'Disable This Backend') ) ); $this->addElement( @@ -209,8 +209,8 @@ class BackendConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t('The identifier of this backend') + 'label' => mt('monitoring', 'Backend Name'), + 'description' => mt('monitoring', 'The identifier of this backend') ) ); $this->addElement( @@ -219,8 +219,8 @@ class BackendConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => t('Backend Type'), - 'description' => t('The data source used for retrieving monitoring information'), + 'label' => mt('monitoring', 'Backend Type'), + 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), 'multiOptions' => $resourceTypes, 'value' => $resourceType ) @@ -230,8 +230,8 @@ class BackendConfigForm extends ConfigForm 'resource', array( 'required' => true, - 'label' => t('Resource'), - 'description' => t('The resource to use'), + 'label' => mt('monitoring', 'Resource'), + 'description' => mt('monitoring', 'The resource to use'), 'multiOptions' => $this->resources[$resourceType] ) ); diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php index 513ba2433..029da3d35 100644 --- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php @@ -9,7 +9,8 @@ use Icinga\Web\Form; class LocalInstanceForm extends Form { /** - * Initialize this form + * (non-PHPDoc) + * @see Form::init() For the method documentation. */ public function init() { @@ -17,21 +18,21 @@ class LocalInstanceForm extends Form } /** - * @see Form::createElements() + * (non-PHPDoc) + * @see Form::createElements() For the method documentation. */ - public function createElements(array $formData) + public function createElements(array $formData = array()) { $this->addElement( 'text', 'path', array( 'required' => true, - 'label' => t('Local Filepath'), + 'label' => mt('monitoring', 'Command File'), 'value' => '/usr/local/icinga/var/rw/icinga.cmd', - 'description' => t('The file path where the icinga commandpipe can be found') + 'description' => mt('monitoring', 'Path to the local Icinga command file') ) ); - return $this; } } diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php index 0e78a0aec..fbd2ff14b 100644 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php @@ -9,60 +9,65 @@ use Icinga\Web\Form\Element\Number; class RemoteInstanceForm extends Form { + /** + * (non-PHPDoc) + * @see Form::init() For the method documentation. + */ public function init() { $this->setName('form_config_monitoring_instance_remote'); } /** - * @see Form::createElements() + * (non-PHPDoc) + * @see Form::createElements() For the method documentation. */ - public function createElements(array $formData) + public function createElements(array $formData = array()) { - $this->addElement( - 'text', - 'host', + $this->addElements(array( array( - 'required' => true, - 'label' => t('Remote Host'), - 'description' => t( - 'Enter the hostname or address of the machine on which the icinga instance is running' + 'text', + 'host', + array( + 'required' => true, + 'label' => mt('monitoring', 'Host'), + 'description' => mt('monitoring', + 'Hostname or address of the remote Icinga instance' + ) ) - ) - ); - $this->addElement( + ), new Number( array( 'required' => true, 'name' => 'port', - 'label' => t('Remote SSH Port'), - 'description' => t('Enter the ssh port to use for connecting to the remote icinga instance'), + 'label' => mt('monitoring', 'Port'), + 'description' => mt('monitoring', 'SSH port to connect to on the remote Icinga instance'), 'value' => 22 ) - ) - ); - $this->addElement( - 'text', - 'user', + ), array( - 'required' => true, - 'label' => t('Remote SSH User'), - 'description' => t( - 'Enter the username to use for connecting to the remote machine or leave blank for default' + 'text', + 'user', + array( + 'required' => true, + 'label' => mt('monitoring', 'User'), + 'description' => mt('monitoring', + 'User to log in as on the remote Icinga instance. Please note that key-based SSH login must be' + . ' possible for this user' + ) + ) + ), + array( + 'text', + 'path', + array( + 'required' => true, + 'label' => mt('monitoring', 'Command File'), + 'value' => '/usr/local/icinga/var/rw/icinga.cmd', + 'description' => mt('monitoring', 'Path to the Icinga command file on the remote Icinga instance') ) ) - ); - $this->addElement( - 'text', - 'path', - array( - 'required' => true, - 'label' => t('Remote Filepath'), - 'value' => '/usr/local/icinga/var/rw/icinga.cmd', - 'description' => t('The file path where the icinga commandpipe can be found') - ) - ); - + )); return $this; } } diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php index 6f8d04764..2971cb663 100644 --- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php +++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php @@ -5,12 +5,14 @@ namespace Icinga\Module\Monitoring\Form\Config; use InvalidArgumentException; -use Icinga\Web\Request; -use Icinga\Form\ConfigForm; -use Icinga\Web\Notification; use Icinga\Exception\ConfigurationError; +use Icinga\Form\ConfigForm; +use Icinga\Module\Monitoring\Command\Transport\LocalCommandFile; +use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile; use Icinga\Module\Monitoring\Form\Config\Instance\LocalInstanceForm; use Icinga\Module\Monitoring\Form\Config\Instance\RemoteInstanceForm; +use Icinga\Web\Notification; +use Icinga\Web\Request; /** * Form for modifying/creating monitoring instances @@ -18,32 +20,39 @@ use Icinga\Module\Monitoring\Form\Config\Instance\RemoteInstanceForm; class InstanceConfigForm extends ConfigForm { /** - * Initialize this form + * (non-PHPDoc) + * @see Form::init() For the method documentation. */ public function init() { $this->setName('form_config_monitoring_instance'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** - * Return a form object for the given instance type + * Get a form object for the given instance type * - * @param string $type The instance type for which to return a form + * @param string $type The instance type for which to return a form * - * @return Form + * @return LocalInstanceForm|RemoteInstanceForm * * @throws InvalidArgumentException In case the given instance type is invalid */ public function getInstanceForm($type) { - if ($type === 'local') { - return new LocalInstanceForm(); - } elseif ($type === 'remote') { - return new RemoteInstanceForm(); - } else { - throw new InvalidArgumentException(sprintf(t('Invalid instance type "%s" provided'), $type)); + switch (strtolower($type)) { + case LocalCommandFile::TRANSPORT: + $form = new LocalInstanceForm(); + break; + case RemoteCommandFile::TRANSPORT; + $form = new RemoteInstanceForm(); + break; + default: + throw new InvalidArgumentException( + sprintf(mt('monitoring', 'Invalid instance type "%s" given'), $type) + ); } + return $form; } /** @@ -61,9 +70,10 @@ class InstanceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Instance name missing')); - } elseif ($this->config->get($name) !== null) { - throw new InvalidArgumentException(t('Instance already exists')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); + } + if (isset($this->config->{$name})) { + throw new InvalidArgumentException(mt('monitoring', 'Instance already exists')); } unset($values['name']); @@ -84,16 +94,16 @@ class InstanceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'New instance name missing')); } elseif (! ($instanceConfig = $this->config->get($name))) { - throw new InvalidArgumentException(t('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } unset($values['name']); unset($this->config->{$name}); - $this->config->{$newName} = array_merge($instanceConfig->toArray(), $values); + $this->config->{$newName} = $values; return $this->config->{$newName}; } @@ -102,16 +112,16 @@ class InstanceConfigForm extends ConfigForm * * @param string $name The name of the resource to remove * - * @return array The removed resource confguration + * @return array The removed resource configuration * * @throws InvalidArgumentException In case the resource name is missing or invalid */ public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); } elseif (! ($instanceConfig = $this->config->get($name))) { - throw new InvalidArgumentException(t('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } unset($this->config->{$name}); @@ -119,19 +129,40 @@ class InstanceConfigForm extends ConfigForm } /** - * @see Form::onSuccess() + * @see Form::onRequest() For the method documentation. + * @throws ConfigurationError In case the instance name is missing or invalid + */ + public function onRequest(Request $request) + { + $instanceName = $request->getQuery('instance'); + if ($instanceName !== null) { + if (! $instanceName) { + throw new ConfigurationError(mt('monitoring', 'Instance name missing')); + } + if (! isset($this->config->{$instanceName})) { + throw new ConfigurationError(mt('monitoring', 'Unknown instance name given')); + } + + $instanceConfig = $this->config->{$instanceName}->toArray(); + $instanceConfig['name'] = $instanceName; + $this->populate($instanceConfig); + } + } + + /** + * (non-PHPDoc) + * @see Form::onSuccess() For the method documentation. */ public function onSuccess(Request $request) { $instanceName = $request->getQuery('instance'); - try { if ($instanceName === null) { // create new instance $this->add($this->getValues()); - $message = t('Instance "%s" created successfully.'); + $message = mt('monitoring', 'Instance "%s" created successfully.'); } else { // edit existing instance $this->edit($instanceName, $this->getValues()); - $message = t('Instance "%s" edited successfully.'); + $message = mt('monitoring', 'Instance "%s" edited successfully.'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -146,63 +177,37 @@ class InstanceConfigForm extends ConfigForm } /** - * @see Form::onRequest() - * - * @throws ConfigurationError In case the instance name is missing or invalid + * (non-PHPDoc) + * @see Form::createElements() For the method documentation. */ - public function onRequest(Request $request) + public function createElements(array $formData = array()) { - $instanceName = $request->getQuery('instance'); - if ($instanceName !== null) { - if (! $instanceName) { - throw new ConfigurationError(t('Instance name missing')); - } elseif (false === isset($this->config->{$instanceName})) { - throw new ConfigurationError(t('Unknown instance name provided')); - } + $instanceType = isset($formData['transport']) ? $formData['transport'] : LocalCommandFile::TRANSPORT; - $instanceConfig = $this->config->{$instanceName}->toArray(); - $instanceConfig['name'] = $instanceName; - if (isset($instanceConfig['host'])) { - // Necessary as we have no config directive for setting the instance's type - $instanceConfig['type'] = 'remote'; - } - $this->populate($instanceConfig); - } - } - - /** - * @see Form::createElements() - */ - public function createElements(array $formData) - { - $instanceType = isset($formData['type']) ? $formData['type'] : 'local'; - - $this->addElement( - 'text', - 'name', + $this->addElements(array( array( - 'required' => true, - 'label' => t('Instance Name') - ) - ); - $this->addElement( - 'select', - 'type', + 'text', + 'name', + array( + 'required' => true, + 'label' => mt('monitoring', 'Instance Name') + ) + ), array( - 'required' => true, - 'ignore' => true, - 'autosubmit' => true, - 'label' => t('Instance Type'), - 'description' => t( - 'When configuring a remote host, you need to setup passwordless key authentication' - ), - 'multiOptions' => array( - 'local' => t('Local Command Pipe'), - 'remote' => t('Remote Command Pipe') - ), - 'value' => $instanceType + 'select', + 'transport', + array( + 'required' => true, + 'autosubmit' => true, + 'label' => mt('monitoring', 'Instance Type'), + 'multiOptions' => array( + LocalCommandFile::TRANSPORT => mt('monitoring', 'Local Command File'), + RemoteCommandFile::TRANSPORT => mt('monitoring', 'Remote Command File') + ), + 'value' => $instanceType + ) ) - ); + )); $this->addElements($this->getInstanceForm($instanceType)->createElements($formData)->getElements()); } diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php index e0cc68680..a57e82702 100644 --- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php +++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php @@ -19,7 +19,7 @@ class SecurityConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_security'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -30,7 +30,7 @@ class SecurityConfigForm extends ConfigForm $this->config->security = $this->getValues(); if ($this->save()) { - Notification::success(t('New security configuration has successfully been stored')); + Notification::success(mt('monitoring', 'New security configuration has successfully been stored')); } else { return false; } @@ -56,8 +56,8 @@ class SecurityConfigForm extends ConfigForm 'protected_customvars', array( 'required' => true, - 'label' => t('Protected Custom Variables'), - 'description' => t( + 'label' => mt('monitoring', 'Protected Custom Variables'), + 'description' => mt('monitoring', 'Comma separated case insensitive list of protected custom variables.' . ' Use * as a placeholder for zero or more wildcard characters.' . ' Existance of those custom variables will be shown, but their values will be masked.' diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php index ed5710454..bcadeeb66 100644 --- a/modules/monitoring/application/forms/StatehistoryForm.php +++ b/modules/monitoring/application/forms/StatehistoryForm.php @@ -56,14 +56,14 @@ class StatehistoryForm extends Form 'select', 'from', array( - 'label' => t('From'), + 'label' => mt('monitoring', 'From'), 'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')), 'multiOptions' => array( - strtotime('midnight 3 months ago') => t('3 Months'), - strtotime('midnight 4 months ago') => t('4 Months'), - strtotime('midnight 8 months ago') => t('8 Months'), - strtotime('midnight 12 months ago') => t('1 Year'), - strtotime('midnight 24 months ago') => t('2 Years') + strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'), + strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'), + strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'), + strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'), + strtotime('midnight 24 months ago') => mt('monitoring', '2 Years') ), 'class' => 'autosubmit' ) @@ -72,10 +72,10 @@ class StatehistoryForm extends Form 'select', 'to', array( - 'label' => t('To'), + 'label' => mt('monitoring', 'To'), 'value' => $this->getRequest()->getParam('to', time()), 'multiOptions' => array( - time() => t('Today') + time() => mt('monitoring', 'Today') ), 'class' => 'autosubmit' ) @@ -86,11 +86,11 @@ class StatehistoryForm extends Form 'select', 'objecttype', array( - 'label' => t('Object type'), + 'label' => mt('monitoring', 'Object type'), 'value' => $objectType, 'multiOptions' => array( - 'services' => t('Services'), - 'hosts' => t('Hosts') + 'services' => mt('monitoring', 'Services'), + 'hosts' => mt('monitoring', 'Hosts') ), 'class' => 'autosubmit' ) @@ -104,13 +104,13 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => t('State'), + 'label' => mt('monitoring', 'State'), 'value' => $serviceState, 'multiOptions' => array( - 'cnt_critical_hard' => t('Critical'), - 'cnt_warning_hard' => t('Warning'), - 'cnt_unknown_hard' => t('Unknown'), - 'cnt_ok' => t('Ok') + 'cnt_critical_hard' => mt('monitoring', 'Critical'), + 'cnt_warning_hard' => mt('monitoring', 'Warning'), + 'cnt_unknown_hard' => mt('monitoring', 'Unknown'), + 'cnt_ok' => mt('monitoring', 'Ok') ), 'class' => 'autosubmit' ) @@ -124,12 +124,12 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => t('State'), + 'label' => mt('monitoring', 'State'), 'value' => $hostState, 'multiOptions' => array( - 'cnt_up' => t('Up'), - 'cnt_down_hard' => t('Down'), - 'cnt_unreachable_hard' => t('Unreachable') + 'cnt_up' => mt('monitoring', 'Up'), + 'cnt_down_hard' => mt('monitoring', 'Down'), + 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable') ), 'class' => 'autosubmit' ) @@ -143,7 +143,7 @@ class StatehistoryForm extends Form 'escape' => false, 'value' => '1', 'class' => 'btn btn-cta btn-common', - 'label' => t('Apply') + 'label' => mt('monitoring', 'Apply') ) ); } diff --git a/modules/monitoring/application/views/scripts/command/list.phtml b/modules/monitoring/application/views/scripts/command/list.phtml index 8a0340f3b..747dd4b5e 100644 --- a/modules/monitoring/application/views/scripts/command/list.phtml +++ b/modules/monitoring/application/views/scripts/command/list.phtml @@ -1,4 +1,4 @@ -

+

-

Monitoring Backends

+

translate('Monitoring Backends') ?>

icon('create.png'); ?> translate('Create New Monitoring Backend'); ?> @@ -15,7 +15,7 @@ translate('Remove'); ?> -backendsConfig as $backendName => $config): ?> + backendsConfig as $backendName => $config): ?> @@ -32,10 +32,10 @@ - + -

Monitoring Instances

+

translate('Monitoring Instances') ?>

icon('create.png'); ?> translate('Create New Instance'); ?> @@ -47,7 +47,7 @@ translate('Remove'); ?> -instancesConfig as $instanceName => $config): ?> + instancesConfig as $instanceName => $config): ?> @@ -64,7 +64,7 @@ - + -

\ No newline at end of file + diff --git a/modules/monitoring/application/views/scripts/list/contactgroups.phtml b/modules/monitoring/application/views/scripts/list/contactgroups.phtml index c110bf011..f25548c52 100644 --- a/modules/monitoring/application/views/scripts/list/contactgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/contactgroups.phtml @@ -8,7 +8,7 @@ $groupInfo): ?> diff --git a/modules/monitoring/application/views/scripts/list/contacts.phtml b/modules/monitoring/application/views/scripts/list/contacts.phtml index a31a79553..a85506841 100644 --- a/modules/monitoring/application/views/scripts/list/contacts.phtml +++ b/modules/monitoring/application/views/scripts/list/contacts.phtml @@ -13,7 +13,7 @@ $contactHelper = $this->getHelper('ContactFlags');
@@ -25,12 +25,12 @@ $contactHelper = $this->getHelper('ContactFlags'); ) ?>">contact_name ?> (contact_alias ?>)
%2$s', - t('Email'), + mt('monitoring', 'Email'), $this->escape($contact->contact_email) ) ?>
contact_pager): ?>
- : + : escape($contact->contact_pager) ?>
@@ -38,13 +38,13 @@ $contactHelper = $this->getHelper('ContactFlags');
contact_notify_service_timeperiod): ?>
- : + : escape($contact->contact_notify_service_timeperiod) ?>
contact_notify_host_timeperiod): ?>
- : + : escape($contact->contact_notify_host_timeperiod) ?>
diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index 56c2198e9..aa120d81d 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -109,7 +109,7 @@
- +
diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 49d8099ff..5a60c7a68 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -8,7 +8,7 @@ diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index d1ff9cdad..365d32f56 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -26,7 +26,7 @@ if (empty($this->notifications)) { diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 66cf14c54..815d43074 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -36,7 +36,7 @@ if (!$this->compact): ?> href( diff --git a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml index cdb19dba7..eb65b779e 100644 --- a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml +++ b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml @@ -23,39 +23,39 @@ use Icinga\Web\Widget\Chart\HistoryColorGrid; $settings = array( 'cnt_up' => array( - 'tooltip' => t('%d ok on %s'), + 'tooltip' => mt('monitoring', '%d ok on %s'), 'color' => '#49DF96', 'opacity' => '0.55' ), 'cnt_unreachable_hard' => array( - 'tooltip' => t('%d unreachable on %s'), + 'tooltip' => mt('monitoring', '%d unreachable on %s'), 'color' => '#77AAFF', 'opacity' => '0.55' ), 'cnt_critical_hard' => array( - 'tooltip' => t('%d critical on %s'), + 'tooltip' => mt('monitoring', '%d critical on %s'), 'color' => '#ff5566', 'opacity' => '0.9' ), 'cnt_warning_hard' => array( - 'tooltip' => t('%d warning on %s'), + 'tooltip' => mt('monitoring', '%d warning on %s'), 'color' => '#ffaa44', 'opacity' => '1.0' ), 'cnt_down_hard' => array( - 'tooltip' => t('%d down on %s'), + 'tooltip' => mt('monitoring', '%d down on %s'), 'color' => '#ff5566', 'opacity' => '0.9' ), 'cnt_unknown_hard' => array( - 'tooltip' => t('%d unknown on %s'), + 'tooltip' => mt('monitoring', '%d unknown on %s'), 'color' => '#cc77ff', 'opacity' => '0.7' ), 'cnt_ok' => array( - 'tooltip' => t('%d ok on %s'), + 'tooltip' => mt('monitoring', '%d ok on %s'), 'color' => '#49DF96', 'opacity' => '0.55' ) @@ -71,7 +71,7 @@ if ($to - $from > 315360000) { $data = array(); if (count($summary) === 0) { - echo t('No state changes in the selected time period.'); + echo mt('monitoring', 'No state changes in the selected time period.'); } foreach ($summary as $entry) { $day = $entry->day; diff --git a/modules/monitoring/application/views/scripts/multi/host.phtml b/modules/monitoring/application/views/scripts/multi/host.phtml index 414609a69..9f61b8fb8 100644 --- a/modules/monitoring/application/views/scripts/multi/host.phtml +++ b/modules/monitoring/application/views/scripts/multi/host.phtml @@ -10,7 +10,7 @@ $this->target = array('host' => $this->hostquery);
- +

Summary for hosts

render('multi/components/objectlist.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/multi/service.phtml b/modules/monitoring/application/views/scripts/multi/service.phtml index ea71693df..ddab8339f 100644 --- a/modules/monitoring/application/views/scripts/multi/service.phtml +++ b/modules/monitoring/application/views/scripts/multi/service.phtml @@ -14,7 +14,7 @@ $this->target = array(
- +

Summary for services

diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index cdb6af12c..c7eac204c 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -19,23 +19,23 @@ contact_email): ?> - + %1$s', $this->escape($contact->contact_email)) ?> contact_pager): ?> - + escape($contact->contact_pager) ?> - + escape($contactHelper->contactFlags($contact, 'host')) ?>
escape($contact->contact_notify_host_timeperiod) ?> - + escape($contactHelper->contactFlags($contact, 'service')) ?>
escape($contact->contact_notify_service_timeperiod) ?> diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 7c72888c4..501c07861 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -142,7 +142,7 @@ $output = $this->tickets ? preg_replace_callback(
- +
diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index 454a33cef..f6aa6b447 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -71,7 +71,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface { $config = IcingaConfig::module('monitoring', 'backends'); if ($config->count() === 0) { - throw new ConfigurationError(t('No backend has been configured')); + throw new ConfigurationError(mt('monitoring', 'No backend has been configured')); } if ($backendName !== null) { $backendConfig = $config->get($backendName); @@ -80,7 +80,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface } if ((bool) $backendConfig->get('disabled', false) === true) { throw new ConfigurationError( - t('Configuration for backend %s available but backend is disabled'), + mt('monitoring', 'Configuration for backend %s available but backend is disabled'), $backendName ); } @@ -92,7 +92,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface } } if ($backendName === null) { - throw new ConfigurationError(t('All backends are disabled')); + throw new ConfigurationError(mt('monitoring', 'All backends are disabled')); } } $resource = ResourceFactory::create($backendConfig->resource); diff --git a/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php b/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php index 84845f23f..53dff5f8c 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php @@ -33,7 +33,10 @@ abstract class CommandTransport if (! isset(self::$config)) { self::$config = Config::module('monitoring', 'instances'); if (self::$config->count() === 0) { - throw new ConfigurationError; + throw new ConfigurationError( + 'No instances have been configured in \'%s\'.', + self::$config->getConfigFile() + ); } } return self::$config; @@ -58,7 +61,12 @@ abstract class CommandTransport $transport = new LocalCommandFile(); break; default: - throw new ConfigurationError(); + throw new ConfigurationError( + 'Can\'t create command transport \'%s\'. Invalid transport defined in \'%s\'.' + . ' Use one of \'local\' or \'remote\'.', + $config->transport, + self::$config->getConfigFile() + ); } unset($config->transport); foreach ($config as $key => $value) { diff --git a/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php b/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php index 2fc68d315..c3133d469 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php @@ -17,6 +17,11 @@ use Icinga\Util\File; */ class LocalCommandFile implements CommandTransportInterface { + /** + * Transport identifier + */ + const TRANSPORT = 'local'; + /** * Path to the icinga command file * @@ -104,15 +109,13 @@ class LocalCommandFile implements CommandTransportInterface public function send(IcingaCommand $command, $now = null) { if (! isset($this->path)) { - throw new LogicException; + throw new LogicException('Can\'t send external Icinga Command. Path to the local command file is missing'); } $commandString = $this->renderer->render($command, $now); Logger::debug( - sprintf( - mt('monitoring', 'Sending external Icinga command "%s" to the local command file "%s"'), - $commandString, - $this->path - ) + 'Sending external Icinga command "%s" to the local command file "%s"', + $commandString, + $this->path ); try { $file = new File($this->path, $this->openMode); @@ -120,10 +123,7 @@ class LocalCommandFile implements CommandTransportInterface $file->fflush(); } catch (Exception $e) { throw new TransportException( - mt( - 'monitoring', - 'Can\'t send external Icinga command "%s" to the local command file "%s": %s' - ), + 'Can\'t send external Icinga command "%s" to the local command file "%s": %s', $commandString, $this->path, $e diff --git a/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php b/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php index fad4eb0a2..d22e2c863 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php @@ -17,6 +17,11 @@ use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer; */ class RemoteCommandFile implements CommandTransportInterface { + /** + * Transport identifier + */ + const TRANSPORT = 'remote'; + /** * Remote host * @@ -168,20 +173,18 @@ class RemoteCommandFile implements CommandTransportInterface public function send(IcingaCommand $command, $now = null) { if (! isset($this->path)) { - throw new LogicException; + throw new LogicException('Can\'t send external Icinga Command. Path to the remote command file is missing'); } if (! isset($this->host)) { - throw new LogicException; + throw new LogicException('Can\'t send external Icinga Command. Remote host is missing'); } $commandString = $this->renderer->render($command, $now); Logger::debug( - sprintf( - mt('monitoring', 'Sending external Icinga command "%s" to the remote command file "%s:%u%s"'), - $commandString, - $this->host, - $this->port, - $this->path - ) + 'Sending external Icinga command "%s" to the remote command file "%s:%u%s"', + $commandString, + $this->host, + $this->port, + $this->path ); $ssh = sprintf('ssh -o BatchMode=yes -p %u', $this->port); // -o BatchMode=yes for disabling interactive authentication methods @@ -197,10 +200,7 @@ class RemoteCommandFile implements CommandTransportInterface exec($ssh, $output, $status); if ($status !== 0) { throw new TransportException( - mt( - 'monitoring', - 'Can\'t send external Icinga command "%s": %s' - ), + 'Can\'t send external Icinga command "%s": %s', $ssh, implode(' ', $output) ); diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index df331999e..2c4ec5380 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -245,7 +245,7 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable foreach ($sortColumns['columns'] as $column) { if (! $this->isValidFilterTarget($column)) { throw new QueryException( - t('The sort column "%s" is not allowed in "%s".'), + mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), $column, get_class($this) ); @@ -336,7 +336,7 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable if ($filter instanceof FilterMatch) { if (! $this->isValidFilterTarget($filter->getColumn())) { throw new QueryException( - t('The filter column "%s" is not allowed here.'), + mt('monitoring', 'The filter column "%s" is not allowed here.'), $filter->getColumn() ); } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index e7521ae6b..455d29980 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -164,6 +164,7 @@ class Host extends MonitoredObject */ public static function getStateText($state, $translate = false) { + $translate = (bool) $translate; switch ((int) $state) { case self::STATE_UP: $text = $translate ? mt('monitoring', 'up') : 'up'; @@ -179,7 +180,6 @@ class Host extends MonitoredObject break; default: throw new InvalidArgumentException('Invalid host state \'%s\'', $state); - break; } return $text; } diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 36a763101..7a0812d8b 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -199,34 +199,35 @@ class Service extends MonitoredObject } /** - * Get the translated textual representation of a service state + * Get the optional translated textual representation of a service state * - * @param int $state + * @param int $state + * @param bool $translate * * @return string * @throws InvalidArgumentException If the service state is not valid */ - public static function getStateText($state) + public static function getStateText($state, $translate = false) { + $translate = (bool) $translate; switch ((int) $state) { case self::STATE_OK: - $text = mt('monitoring', 'ok'); + $text = $translate ? mt('monitoring', 'ok') : 'ok'; break; case self::STATE_WARNING: - $text = mt('monitoring', 'warning'); + $text = $translate ? mt('monitoring', 'warning') : 'warning'; break; case self::STATE_CRITICAL: - $text = mt('monitoring', 'critical'); + $text = $translate ? mt('monitoring', 'critical') : 'critical'; break; case self::STATE_UNKNOWN: - $text = mt('monitoring', 'unknown'); + $text = $translate ? mt('monitoring', 'unknown') : 'unknown'; break; case self::STATE_PENDING: - $text = mt('monitoring', 'pending'); + $text = $translate ? mt('monitoring', 'pending') : 'pending'; break; default: throw new InvalidArgumentException('Invalid service state \'%s\'', $state); - break; } return $text; }