summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-28 21:22:34 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-28 21:22:34 +0000
commit6a76d6f747768106f8bccd8b74059371dbac615a (patch)
tree4075552e99833a5a721ca17f6815bacb7baa0fc4
parent8b6ed6c477771e42d43ea0684e5139cf361b6cee (diff)
Dynamically create the list of available modules. This permits new modules to be added without having to update the config.php file
-rw-r--r--core/config/config.php11
-rw-r--r--core/controllers/welcome.php9
-rw-r--r--core/helpers/module.php22
-rw-r--r--core/hooks/load_modules.php21
4 files changed, 46 insertions, 17 deletions
diff --git a/core/config/config.php b/core/config/config.php
index 67c913bb..db016ffd 100644
--- a/core/config/config.php
+++ b/core/config/config.php
@@ -123,16 +123,5 @@ $config['modules'] = array
MODPATH . 'forge',
THEMEPATH . 'default',
-
- MODPATH . 'carousel',
- MODPATH . 'tag',
- MODPATH . 'user',
- MODPATH . 'info',
- MODPATH . 'gmaps',
- MODPATH . 'media_rss',
- MODPATH . 'slideshow',
- MODPATH . 'comment',
- MODPATH . 'atom',
- MODPATH . 'search'
);
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index a75b225f..5cf6d7bf 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -346,16 +346,13 @@ class Welcome_Controller extends Template_Controller {
private function _read_modules() {
$modules = array();
try {
- $installed = ORM::factory("module")->find_all();
+ $installed = module::installed();
foreach ($installed as $installed_module) {
$modules[$installed_module->name] = $installed_module->version;
}
- foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) {
- if (empty($modules[basename(dirname(dirname($file)))])) {
- $modules[basename(dirname(dirname($file)))] = 0;
- }
- }
+ $modules = module::available($modules);
+
} catch (Exception $e) {
// The database may not be installed
}
diff --git a/core/helpers/module.php b/core/helpers/module.php
index afba658a..599cc618 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -64,4 +64,26 @@ class module_Core {
}
}
}
+
+ public static function available($modules=array()) {
+ foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) {
+ if (empty($modules[basename(dirname(dirname($file)))])) {
+ $modules[basename(dirname(dirname($file)))] = 0;
+ }
+ }
+
+ return $modules;
+ }
+
+ public static function load_modules() {
+ Kohana::log("debug", "module::load_modules()");
+ $modules = Kohana::config('core.modules');
+
+ foreach (array_keys(self::available()) as $module_name) {
+ $modules[] = MODPATH . $module_name;
+ }
+ Kohana::log("debug", print_r($modules, true));
+
+ Kohana::config_set('core.modules', $modules);
+ }
}
diff --git a/core/hooks/load_modules.php b/core/hooks/load_modules.php
new file mode 100644
index 00000000..57d0fffb
--- /dev/null
+++ b/core/hooks/load_modules.php
@@ -0,0 +1,21 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+Event::add("system.ready", array("module", "load_modules"));