mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
1f942acd38
commit
754f854dd0
@ -15,6 +15,13 @@ class Page extends Form
|
|||||||
*/
|
*/
|
||||||
protected $tokenDisabled = true;
|
protected $tokenDisabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wizard this page is part of
|
||||||
|
*
|
||||||
|
* @var Wizard
|
||||||
|
*/
|
||||||
|
protected $wizard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The title of this wizard page
|
* The title of this wizard page
|
||||||
*
|
*
|
||||||
@ -22,6 +29,18 @@ class Page extends Form
|
|||||||
*/
|
*/
|
||||||
protected $title = '';
|
protected $title = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new wizard page
|
||||||
|
*
|
||||||
|
* @param Wizard $wizard The wizard this page is part of
|
||||||
|
* @param mixed $options Zend_Form options
|
||||||
|
*/
|
||||||
|
public function __construct(Wizard $wizard = null, $options = null)
|
||||||
|
{
|
||||||
|
parent::__construct($options);
|
||||||
|
$this->wizard = $wizard;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrite this to initialize this wizard page
|
* Overwrite this to initialize this wizard page
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +34,27 @@ class Wizard extends Page
|
|||||||
return $this->pages;
|
return $this->pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a page by its name or null if it's not found
|
||||||
|
*
|
||||||
|
* @param string $pageName The name of the page
|
||||||
|
*
|
||||||
|
* @return Page|null
|
||||||
|
*/
|
||||||
|
public function getPage($pageName)
|
||||||
|
{
|
||||||
|
$candidates = array_filter(
|
||||||
|
$this->pages, // Cannot use getPages() here because I might get called as part of Page::isRequired()
|
||||||
|
function ($page) use ($pageName) { return $page->getName() === $pageName; }
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($candidates)) {
|
||||||
|
return array_shift($candidates);
|
||||||
|
} elseif ($this->wizard !== null) {
|
||||||
|
return $this->wizard->getPage($pageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new page to this wizard
|
* Add a new page to this wizard
|
||||||
*
|
*
|
||||||
@ -68,17 +89,14 @@ class Wizard extends Page
|
|||||||
{
|
{
|
||||||
foreach ($pages as $title => $pageClassOrArray) {
|
foreach ($pages as $title => $pageClassOrArray) {
|
||||||
if (is_array($pageClassOrArray)) {
|
if (is_array($pageClassOrArray)) {
|
||||||
$wizard = new static();
|
$wizard = new static($this);
|
||||||
$wizard->setTitle($title);
|
$wizard->setTitle($title);
|
||||||
$this->addPage($wizard);
|
$this->addPage($wizard);
|
||||||
$wizard->addPages($pageClassOrArray);
|
$wizard->addPages($pageClassOrArray);
|
||||||
} elseif (is_string($pageClassOrArray)) {
|
} else {
|
||||||
$page = new $pageClassOrArray();
|
$page = new $pageClassOrArray($this);
|
||||||
$page->setTitle($title);
|
$page->setTitle($title);
|
||||||
$this->addPage($page);
|
$this->addPage($page);
|
||||||
} else {
|
|
||||||
$pageClassOrArray->setTitle($title);
|
|
||||||
$this->addPage($pageClassOrArray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user