diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php deleted file mode 100644 index 5e8927dbc..000000000 --- a/modules/setup/application/forms/ModulePage.php +++ /dev/null @@ -1,161 +0,0 @@ -setName('setup_modules'); - $this->setViewScript('form/setup-modules.phtml'); - $this->session = Session::getSession()->getNamespace(get_class($this)); - - $this->modulePaths = array(); - if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) { - $this->modulePaths[] = $appModulePath; - } - } - - public function setPageData(array $pageData) - { - $this->pageData = $pageData; - return $this; - } - - public function handleRequest(Request $request = null) - { - $isPost = strtolower($request->getMethod()) === 'post'; - if ($isPost && $this->wasSent($request->getPost())) { - if (($newModule = $request->getPost('module')) !== null) { - $this->setCurrentModule($newModule); - $this->getResponse()->redirectAndExit($this->getRedirectUrl()); - } else { - // The user submitted this form but with the parent wizard's navigation - // buttons so it's now up to the parent wizard to handle the request.. - } - } else { - $wizard = $this->getCurrentWizard(); - $wizardPage = $wizard->getCurrentPage(); - - $wizard->handleRequest($request); - if ($isPost && $wizard->isFinished() && $wizardPage->wasSent($request->getPost())) { - $wizards = $this->getWizards(); - - $newModule = null; - foreach ($wizards as $moduleName => $moduleWizard) { - if (false === $moduleWizard->isFinished()) { - $newModule = $moduleName; - } - } - - if ($newModule === null) { - // In case all module wizards were completed just pick the first one again - reset($wizards); - $newModule = key($wizards); - } - - $this->setCurrentModule($newModule); - } - } - } - - public function clearSession() - { - $this->session->clear(); - foreach ($this->getWizards() as $wizard) { - $wizard->clearSession(); - } - } - - public function setCurrentModule($moduleName) - { - if (false === array_key_exists($moduleName, $this->getWizards())) { - throw new InvalidArgumentException(sprintf('Module "%s" does not provide a setup wizard', $moduleName)); - } - - $this->session->currentModule = $moduleName; - } - - public function getCurrentModule() - { - $moduleName = $this->session->get('currentModule'); - if ($moduleName === null) { - $moduleName = key($this->getWizards()); - $this->setCurrentModule($moduleName); - } - - return $moduleName; - } - - public function getCurrentWizard() - { - $wizards = $this->getWizards(); - return $wizards[$this->getCurrentModule()]; - } - - public function getModules() - { - if ($this->modules !== null) { - return $this->modules; - } else { - $this->modules = array(); - } - - $moduleManager = Icinga::app()->getModuleManager(); - $moduleManager->detectInstalledModules($this->modulePaths); - foreach ($moduleManager->listInstalledModules() as $moduleName) { - $this->modules[] = $moduleManager->loadModule($moduleName)->getModule($moduleName); - } - - return $this->modules; - } - - public function getWizards() - { - if ($this->wizards !== null) { - return $this->wizards; - } else { - $this->wizards = array(); - } - - foreach ($this->getModules() as $module) { - if ($module->providesSetupWizard()) { - $this->wizards[$module->getName()] = $module->getSetupWizard(); - } - } - - $this->mergePageData($this->wizards); - return $this->wizards; - } - - protected function mergePageData(array $wizards) - { - foreach ($wizards as $wizard) { - $wizardPageData = & $wizard->getPageData(); - foreach ($this->pageData as $pageName => $pageData) { - $wizardPageData[$pageName] = $pageData; - } - } - } -} diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 68632e305..a33b8c0d7 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -94,7 +94,6 @@ class WebWizard extends Wizard implements SetupWizard $this->addPage(new AdminAccountPage()); $this->addPage(new GeneralConfigPage()); $this->addPage(new DatabaseCreationPage()); - $this->addPage(new ModulePage()); $this->addPage(new SummaryPage()); } @@ -167,9 +166,6 @@ class WebWizard extends Wizard implements SetupWizard unset($pageData['setup_admin_account']); unset($pageData['setup_authentication_backend']); } - } elseif ($page->getName() === 'setup_modules') { - $page->setPageData($this->getPageData()); - $page->handleRequest($request); } } @@ -263,7 +259,6 @@ class WebWizard extends Wizard implements SetupWizard public function clearSession() { parent::clearSession(); - $this->getPage('setup_modules')->clearSession(); $tokenPath = Config::resolvePath('setup.token'); if (file_exists($tokenPath)) { @@ -358,12 +353,6 @@ class WebWizard extends Wizard implements SetupWizard ) ); - foreach ($this->getPage('setup_modules')->setPageData($this->getPageData())->getWizards() as $wizard) { - if ($wizard->isFinished()) { - $setup->addSteps($wizard->getSetup()->getSteps()); - } - } - return $setup; } @@ -548,10 +537,6 @@ class WebWizard extends Wizard implements SetupWizard ) ); - foreach ($this->getPage('setup_modules')->setPageData($this->getPageData())->getWizards() as $wizard) { - $requirements->merge($wizard->getRequirements()->allOptional()); - } - return $requirements; } }