Commands: Use native form title and description support where appropriate

refs #7947
refs #7976
This commit is contained in:
Johannes Meyer 2015-03-02 18:39:10 +01:00
parent 4ba281e7e8
commit a2f88dc60f
16 changed files with 129 additions and 144 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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.'
);
));
}
/**

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -7,7 +7,6 @@
<hr class="command-separator">
<?php endif ?>
</div>
<div class="content">
<h1 class="command-title"><?= $title; ?> <?= /** @var \Icinga\Module\Monitoring\Forms\Command\CommandForm $form */ $this->icon('help', $form->getHelp()); ?></h1>
<?= $form ?>
<div class="content object-command">
<?= $form; ?>
</div>

View File

@ -5,7 +5,7 @@
<?= $this->render('partials/host/objects-header.phtml'); ?>
<?php endif ?>
</div>
<div class="content">
<div class="content objects-command">
<table class="objectlist">
<thead>
<tr>
@ -27,6 +27,5 @@
</tbody>
</table>
<hr class="command-separator">
<h1 class="command-title"><?= $title ?> <?= /** @var \Icinga\Module\Monitoring\Forms\Command\CommandForm $form */ $this->icon('help', $form->getHelp()) ?></h1>
<?= $form ?>
<?= $form; ?>
</div>

View File

@ -2,7 +2,7 @@
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<div class="content">
<h1><?= $title ?> <?= $this->icon('help', $form->getHelp()) ?></h1>
<h1><?= $title; ?></h1>
<?php if ((bool) $programStatus->notifications_enabled === false): ?>
<div>
<?= $this->translate('Host and service notifications are already disabled.') ?>
@ -13,6 +13,6 @@
<?php endif; ?>
</div>
<?php else: ?>
<?= $form ?>
<?= $form; ?>
<?php endif ?>
</div>

View File

@ -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;
}