monitoring: Use Form::translate() in the backend configuration form

refs #7551
This commit is contained in:
Eric Lippmann 2014-12-30 10:02:31 +01:00
parent e05e04bb74
commit d6e331018b

View File

@ -28,7 +28,7 @@ class BackendConfigForm extends ConfigForm
public function init() public function init()
{ {
$this->setName('form_config_monitoring_backends'); $this->setName('form_config_monitoring_backends');
$this->setSubmitLabel(mt('monitoring', 'Save Changes')); $this->setSubmitLabel($this->translate('Save Changes'));
} }
/** /**
@ -50,7 +50,7 @@ class BackendConfigForm extends ConfigForm
} }
if (empty($resources)) { if (empty($resources)) {
throw new ConfigurationError(mt('monitoring', 'Could not find any valid monitoring backend resources')); throw new ConfigurationError($this->translate('Could not find any valid monitoring backend resources'));
} }
$this->resources = $resources; $this->resources = $resources;
@ -72,9 +72,9 @@ class BackendConfigForm extends ConfigForm
{ {
$name = isset($values['name']) ? $values['name'] : ''; $name = isset($values['name']) ? $values['name'] : '';
if (! $name) { if (! $name) {
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); throw new InvalidArgumentException($this->translate('Monitoring backend name missing'));
} elseif ($this->config->hasSection($name)) { } elseif ($this->config->hasSection($name)) {
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists')); throw new InvalidArgumentException($this->translate('Monitoring backend already exists'));
} }
unset($values['name']); unset($values['name']);
@ -95,11 +95,11 @@ class BackendConfigForm extends ConfigForm
public function edit($name, array $values) public function edit($name, array $values)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing')); throw new InvalidArgumentException($this->translate('Old monitoring backend name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing')); throw new InvalidArgumentException($this->translate('New monitoring backend name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided'));
} }
unset($values['name']); unset($values['name']);
@ -119,9 +119,9 @@ class BackendConfigForm extends ConfigForm
public function remove($name) public function remove($name)
{ {
if (! $name) { if (! $name) {
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); throw new InvalidArgumentException($this->translate('Monitoring backend name missing'));
} elseif (! $this->config->hasSection($name)) { } elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided'));
} }
$backendConfig = $this->config->getSection($name); $backendConfig = $this->config->getSection($name);
@ -131,8 +131,6 @@ class BackendConfigForm extends ConfigForm
/** /**
* Add or edit a monitoring backend and save the configuration * Add or edit a monitoring backend and save the configuration
*
* @see Form::onSuccess()
*/ */
public function onSuccess() public function onSuccess()
{ {
@ -140,10 +138,10 @@ class BackendConfigForm extends ConfigForm
try { try {
if ($monitoringBackend === null) { // Create new backend if ($monitoringBackend === null) { // Create new backend
$this->add($this->getValues()); $this->add($this->getValues());
$message = mt('monitoring', 'Monitoring backend "%s" has been successfully created'); $message = $this->translate('Monitoring backend "%s" has been successfully created');
} else { // Edit existing backend } else { // Edit existing backend
$this->edit($monitoringBackend, $this->getValues()); $this->edit($monitoringBackend, $this->getValues());
$message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed'); $message = $this->translate('Monitoring backend "%s" has been successfully changed');
} }
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Notification::error($e->getMessage()); Notification::error($e->getMessage());
@ -167,9 +165,9 @@ class BackendConfigForm extends ConfigForm
$monitoringBackend = $this->request->getQuery('backend'); $monitoringBackend = $this->request->getQuery('backend');
if ($monitoringBackend !== null) { if ($monitoringBackend !== null) {
if ($monitoringBackend === '') { if ($monitoringBackend === '') {
throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing')); throw new ConfigurationError($this->translate('Monitoring backend name missing'));
} elseif (! $this->config->hasSection($monitoringBackend)) { } elseif (! $this->config->hasSection($monitoringBackend)) {
throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided')); throw new ConfigurationError($this->translate('Unknown monitoring backend provided'));
} }
$backendConfig = $this->config->getSection($monitoringBackend)->toArray(); $backendConfig = $this->config->getSection($monitoringBackend)->toArray();
@ -199,7 +197,7 @@ class BackendConfigForm extends ConfigForm
'disabled', 'disabled',
array( array(
'required' => true, 'required' => true,
'label' => mt('monitoring', 'Disable This Backend') 'label' => $this->translate('Disable This Backend')
) )
); );
$this->addElement( $this->addElement(
@ -207,8 +205,8 @@ class BackendConfigForm extends ConfigForm
'name', 'name',
array( array(
'required' => true, 'required' => true,
'label' => mt('monitoring', 'Backend Name'), 'label' => $this->translate('Backend Name'),
'description' => mt('monitoring', 'The identifier of this backend') 'description' => $this->translate('The identifier of this backend')
) )
); );
$this->addElement( $this->addElement(
@ -217,8 +215,8 @@ class BackendConfigForm extends ConfigForm
array( array(
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
'label' => mt('monitoring', 'Backend Type'), 'label' => $this->translate('Backend Type'),
'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), 'description' => $this->translate('The data source used for retrieving monitoring information'),
'multiOptions' => $resourceTypes, 'multiOptions' => $resourceTypes,
'value' => $resourceType 'value' => $resourceType
) )
@ -229,8 +227,8 @@ class BackendConfigForm extends ConfigForm
'resource', 'resource',
array( array(
'required' => true, 'required' => true,
'label' => mt('monitoring', 'Resource'), 'label' => $this->translate('Resource'),
'description' => mt('monitoring', 'The resource to use'), 'description' => $this->translate('The resource to use'),
'multiOptions' => $this->resources[$resourceType], 'multiOptions' => $this->resources[$resourceType],
'autosubmit' => true 'autosubmit' => true
) )
@ -253,7 +251,7 @@ class BackendConfigForm extends ConfigForm
'value' => sprintf( 'value' => sprintf(
'<a href="%s" data-base-target="_main">%s</a>', '<a href="%s" data-base-target="_main">%s</a>',
$this->getView()->url('config/editresource', array('resource' => $resourceName)), $this->getView()->url('config/editresource', array('resource' => $resourceName)),
mt('monitoring', 'Show resource configuration') $this->translate('Show resource configuration')
), ),
'escape' => false 'escape' => false
) )