Add requirements page

refs #7163
This commit is contained in:
Johannes Meyer 2014-09-29 12:26:54 +02:00
parent 226575eddd
commit a39c6a475a
2 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,69 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Setup;
use Icinga\Web\Form;
use Icinga\Web\Setup\Requirements;
/**
* Wizard page to list installation requirements
*/
class RequirementsPage extends Form
{
/**
* The requirements to list
*
* @var Requirements
*/
protected $requirements;
/**
* Initialize this page
*/
public function init()
{
$this->setName('setup_requirements');
$this->setViewScript('form/setup-requirements.phtml');
}
/**
* Set the requirements to list
*
* @param Requirements $requirements
*
* @return self
*/
public function setRequirements(Requirements $requirements)
{
$this->requirements = $requirements;
return $this;
}
/**
* Return the requirements to list
*
* @return Requirements
*/
public function getRequirements()
{
return $this->requirements;
}
/**
* Validate the given form data and check whether the requirements are fulfilled
*
* @param array $data The data to validate
*
* @return bool
*/
public function isValid($data)
{
if (false === parent::isValid($data)) {
return false;
}
return $this->requirements->fulfilled();
}
}

View File

@ -0,0 +1,33 @@
<?php
use Icinga\Web\Wizard;
use Icinga\Web\Setup\Requirements;
$requirements = $form->getRequirements();
?>
<table>
<tbody>
<?php foreach ($requirements as $requirement): ?>
<tr>
<td><?= $requirement->title; ?></td>
<td><?= $requirement->description; ?></td>
<td style="background-color: <?= $requirement->state === Requirements::STATE_OK ? 'green' : (
$requirement->state === Requirements::STATE_OPTIONAL ? 'yellow' : 'red'
); ?>"><?= $requirement->message; ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>">
<?= $form->getElement($form->getTokenElementName()); ?>
<?= $form->getElement($form->getUidElementName()); ?>
<?= $form->getElement(Wizard::BTN_PREV); ?>
<?php
$btn = $form->getElement(Wizard::BTN_NEXT);
if (false === $requirements->fulfilled()) {
$btn->setAttrib('disabled', 1);
}
echo $btn;
?>
</form>