From a2f88dc60f231260f64345f9c8c52d0d6101e437 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:39:10 +0100 Subject: [PATCH] Commands: Use native form title and description support where appropriate refs #7947 refs #7976 --- .../controllers/HostController.php | 25 +++++++++------ .../controllers/HostsController.php | 20 +++++++----- .../controllers/ServiceController.php | 25 +++++++++------ .../controllers/ServicesController.php | 20 +++++++----- .../DisableNotificationsExpireCommandForm.php | 12 ++----- .../Object/AcknowledgeProblemCommandForm.php | 32 ++++++++----------- .../Command/Object/AddCommentCommandForm.php | 26 ++++++--------- .../Object/ProcessCheckResultCommandForm.php | 28 ++++++++-------- .../Object/ScheduleHostCheckCommandForm.php | 3 +- .../ScheduleHostDowntimeCommandForm.php | 4 +-- .../ScheduleServiceCheckCommandForm.php | 30 ++++++++--------- .../ScheduleServiceDowntimeCommandForm.php | 32 ++++++++----------- .../command/object-command-form.phtml | 5 ++- .../command/objects-command-form.phtml | 5 ++- .../process/disable-notifications.phtml | 4 +-- modules/monitoring/public/css/module.less | 2 +- 16 files changed, 129 insertions(+), 144 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 9cf3b26ab..4a29750e3 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -66,8 +66,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Host Problem'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Host Problem')); + $this->handleCommandForm($form); } /** @@ -77,8 +78,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/comment/add'); - $this->view->title = $this->translate('Add Host Comment'); - $this->handleCommandForm(new AddCommentCommandForm()); + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Host Comment')); + $this->handleCommandForm($form); } /** @@ -88,8 +90,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Host Check'); - $this->handleCommandForm(new ScheduleHostCheckCommandForm()); + $form = new ScheduleHostCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Host Check')); + $this->handleCommandForm($form); } /** @@ -99,8 +102,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Host Downtime'); - $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); + $form = new ScheduleHostDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Host Downtime')); + $this->handleCommandForm($form); } /** @@ -110,7 +114,8 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Host Check Result'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Host Check Result')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index de1f063ac..5dc72eeb0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -175,8 +175,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Host Problems'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Host Problems')); + $this->handleCommandForm($form); } /** @@ -186,8 +187,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Host Checks'); - $this->handleCommandForm(new ScheduleHostCheckCommandForm()); + $form = new ScheduleHostCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Host Checks')); + $this->handleCommandForm($form); } /** @@ -197,8 +199,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Host Downtimes'); - $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); + $form = new ScheduleHostDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Host Downtimes')); + $this->handleCommandForm($form); } /** @@ -208,7 +211,8 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Host Check Results'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Host Check Results')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 19906f5d2..d717a8e1c 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -43,8 +43,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Service Problem'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Service Problem')); + $this->handleCommandForm($form); } /** @@ -54,8 +55,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/comment/add'); - $this->view->title = $this->translate('Add Service Comment'); - $this->handleCommandForm(new AddCommentCommandForm()); + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Service Comment')); + $this->handleCommandForm($form); } /** @@ -65,8 +67,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Service Check'); - $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); + $form = new ScheduleServiceCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Service Check')); + $this->handleCommandForm($form); } /** @@ -76,8 +79,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Service Downtime'); - $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); + $form = new ScheduleServiceDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Service Downtime')); + $this->handleCommandForm($form); } /** @@ -87,7 +91,8 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Service Check Result'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Service Check Result')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index a74b61074..1e907aab9 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -224,8 +224,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Service Problems'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Service Problems')); + $this->handleCommandForm($form); } /** @@ -235,8 +236,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Service Checks'); - $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); + $form = new ScheduleServiceCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Service Checks')); + $this->handleCommandForm($form); } /** @@ -246,8 +248,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Service Downtimes'); - $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); + $form = new ScheduleServiceDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Service Downtimes')); + $this->handleCommandForm($form); } /** @@ -257,7 +260,8 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Service Check Results'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Service Check Results')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 31e3b37aa..e69b9ea11 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -22,17 +22,9 @@ class DisableNotificationsExpireCommandForm extends CommandForm { $this->setRequiredCue(null); $this->setSubmitLabel($this->translate('Disable Notifications')); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( + $this->addDescription($this->translate( 'This command is used to disable host and service notifications for a specific time.' - ); + )); } /** diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 6f1235363..ef6d626b3 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -13,28 +13,25 @@ use Icinga\Web\Notification; */ class AcknowledgeProblemCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' + . ' future notifications about problems are temporarily disabled until the host or service' + . ' recovers.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Acknowledge problem', 'Acknowledge problems', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' - . ' future notifications about problems are temporarily disabled until the host or service' - . ' recovers.' - ); + return $this->translatePlural('Acknowledge problem', 'Acknowledge problems', count($this->objects)); } /** @@ -156,8 +153,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm } $this->getTransport($this->request)->send($ack); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Acknowledging problem..', 'Acknowledging problems..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index eee671397..d167061f9 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -11,26 +11,21 @@ use Icinga\Web\Notification; */ class AddCommentCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate('This command is used to add host or service comments.')); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Add comment', 'Add comments', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to add host or service comments.' - ); + return $this->translatePlural('Add comment', 'Add comments', count($this->objects)); } /** @@ -84,8 +79,7 @@ class AddCommentCommandForm extends ObjectsCommandForm $comment->setPersistent($this->getElement('persistent')->isChecked()); $this->getTransport($this->request)->send($comment); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Adding comment..', 'Adding comments..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index 1a357bdce..ec80a539f 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -11,25 +11,24 @@ use Icinga\Module\Monitoring\Command\Object\ProcessCheckResultCommand; */ class ProcessCheckResultCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to submit passive host or service check results.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Submit Passive Check Result', 'Submit Passive Check Results', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to submit passive host or service check results.' + return $this->translatePlural( + 'Submit Passive Check Result', 'Submit Passive Check Results', count($this->objects) ); } @@ -108,8 +107,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm $this->getTransport($this->request)->send($command); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Processing check result..', 'Processing check results..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index 7789460e3..0fa748fc4 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -47,8 +47,7 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm ->setOfAllServices($this->getElement('all_services')->isChecked()); $this->scheduleCheck($check, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling host check..', 'Scheduling host checks..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index 6c7823dca..c35cb5413 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -7,7 +7,6 @@ use Icinga\Module\Monitoring\Command\Object\PropagateHostDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleHostDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleServiceDowntimeCommand; use Icinga\Web\Notification; -use Icinga\Web\Request; /** * Form for scheduling host downtimes @@ -83,8 +82,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm $hostDowntime->setObject($object); $this->scheduleDowntime($hostDowntime, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling host downtime..', 'Scheduling host downtimes..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index e6686a9b8..f0f15559e 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -14,27 +14,24 @@ use Icinga\Web\Request; */ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' + . ' hosts or services to be checked at the time you specify.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Schedule check', 'Schedule checks', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' - . ' hosts or services to be checked at the time you specify.' - ); + return $this->translatePlural('Schedule check', 'Schedule checks', count($this->objects)); } /** @@ -99,8 +96,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm $check->setObject($object); $this->scheduleCheck($check, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling service check..', 'Scheduling service checks..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 00487e115..627138a88 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -25,29 +25,26 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm const FLEXIBLE = 'flexible'; /** - * (non-PHPDoc) - * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. + * Initialize this form */ - public function getSubmitLabel() + public function init() { - return mtp( - 'monitoring', 'Schedule downtime', 'Schedule downtimes', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( + $this->addDescription($this->translate( 'This command is used to schedule host and service downtimes. During the specified downtime,' . ' Icinga will not send notifications out about the hosts and services. When the scheduled' . ' downtime expires, Icinga will send out notifications for the hosts and services as it' . ' normally would. Scheduled downtimes are preserved across program shutdowns and' . ' restarts.' - ); + )); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. + */ + public function getSubmitLabel() + { + return $this->translatePlural('Schedule downtime', 'Schedule downtimes', count($this->objects)); } /** @@ -206,8 +203,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm $downtime->setObject($object); $this->scheduleDowntime($downtime, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling service downtime..', 'Scheduling service downtimes..', count($this->objects) diff --git a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml index 7f4314cbf..dbcf0bc03 100644 --- a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml @@ -7,7 +7,6 @@
-
-

icon('help', $form->getHelp()); ?>

- +
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml index da58fc9cb..d387202c2 100644 --- a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml @@ -5,7 +5,7 @@ render('partials/host/objects-header.phtml'); ?>
-
+
@@ -27,6 +27,5 @@

-

icon('help', $form->getHelp()) ?>

- +
diff --git a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml index 2fb3c6c6e..9b9a2b133 100644 --- a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml +++ b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml @@ -2,7 +2,7 @@ tabs->showOnlyCloseButton() ?>
-

icon('help', $form->getHelp()) ?>

+

notifications_enabled === false): ?>
translate('Host and service notifications are already disabled.') ?> @@ -13,6 +13,6 @@
- +
diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 26cd5bc38..02ef9be6c 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -190,7 +190,7 @@ div.selection-info { vertical-align: middle; } -h1.command-title { +.object-command h1.form-title, .objects-command h1.form-title { border: none; }