parent
226575eddd
commit
a39c6a475a
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
Loading…
Reference in New Issue