summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-05 01:05:21 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-05 01:05:21 +0000
commit667d79c705f83b9752e30553f94a94cba25227a2 (patch)
tree21856e8d91da4cd8ce40126d786edcc46edcf000 /core
parentda286fbf6b18b9a4839e26f23f09a3217d93ea3e (diff)
_readModules -> _readModules
Simplify the installer-detection code.
Diffstat (limited to 'core')
-rw-r--r--core/controllers/welcome.php30
1 files changed, 9 insertions, 21 deletions
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;