From 667d79c705f83b9752e30553f94a94cba25227a2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 5 Nov 2008 01:05:21 +0000 Subject: _readModules -> _readModules Simplify the installer-detection code. --- core/controllers/welcome.php | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 4268f7cc..5a6d99f3 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -23,16 +23,10 @@ class Welcome_Controller extends Template_Controller { function index() { $this->template->syscheck = new View("welcome_syscheck.html"); $this->template->syscheck->errors = $this->_get_config_errors(); - - try { - $this->template->syscheck->modules = $this->_readModules(); - } catch (Exception $e) { - $this->template->syscheck->modules = array(); - } - $this->_create_directories(); + $this->template->syscheck->modules = $this->_read_modules(); + $this->_create_directories(); } - function install($module) { call_user_func(array("{$module}_installer", "install")); url::redirect("welcome"); @@ -134,27 +128,21 @@ class Welcome_Controller extends Template_Controller { * Create an array of all the modules that are install or available and the version number * @return array(moduleId => version) */ - private function _readModules() { + private function _read_modules() { $modules = array(); try { $installed = ORM::factory("module")->find_all(); foreach ($installed as $installed_module) { $modules[$installed_module->name] = $installed_module->version; } - } catch (Exception $e) {} + } catch (Exception $e) { + // The database may not be installed + } - if (!empty($modules['core'])) { - if ($dh = opendir(MODPATH)) { - while (($file = readdir($dh)) !== false) { - if ($file[0] != '.' && - file_exists(MODPATH . "$file/helpers/{$file}_installer.php")) { - if (empty($modules[$file])) { - $modules[$file] = 0; - } - } - } + if (!empty($modules["core"])) { + foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { + $modules[basename(dirname(dirname($file)))] = 0; } - closedir($dh); } return $modules; -- cgit v1.2.3