diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 34 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 7 |
4 files changed, 38 insertions, 20 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 37a08d08..6d387d76 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -110,4 +110,17 @@ class gallery_Core { return $file_name; } + /** + * Return a full path to the theme or module file. It checks the APPPATH/(themes|modules) first + * then the THEMEPATH | MODPATH + * @param $file the file or directory + * @param $type ("module" | "theme" optional: defaults to "module") + * @return string + */ + static function plugin_path($file, $type="module") { + if (!file_exists($ofile = APPPATH . "{$type}s/$file")) { + $ofile = $type == "module" ? MODPATH . $file : THEMEPATH . $file; + } + return $ofile; + } }
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b1ea1f19..e834a62c 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -245,8 +245,8 @@ class gallery_installer { // Instantiate default themes (site and admin) foreach (array("wind", "admin_wind") as $theme_name) { - $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), - ArrayObject::ARRAY_AS_PROPS); + $file = gallery::plugin_path("$theme_name/theme.info", "theme"); + $theme_info = new ArrayObject(parse_ini_file($file, ArrayObject::ARRAY_AS_PROPS); $theme = ORM::factory("theme"); $theme->name = $theme_name; $theme->version = $theme_info->version; diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index fe37f4f9..99c52cab 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -77,15 +77,23 @@ class module_Core { static function available() { if (empty(self::$available)) { $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); - foreach (glob(MODPATH . "*/module.info") as $file) { - $module_name = basename(dirname($file)); - $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); - $m =& $modules->$module_name; - $m->installed = self::is_installed($module_name); - $m->active = self::is_active($module_name); - $m->code_version = $m->version; - $m->version = self::get_version($module_name); - $m->locked = false; + foreach (array(APPPATH . "modules/", MODPATH) as $modpath) { + foreach (scandir($modpath) as $module_name) { + if ($module_name[0] == ".") { + continue; + } + $file = "{$modpath}$module_name/module.info"; + if (file_exists($file)) { + $modules->$module_name = + new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); + $m =& $modules->$module_name; + $m->installed = self::is_installed($module_name); + $m->active = self::is_active($module_name); + $m->code_version = $m->version; + $m->version = self::get_version($module_name); + $m->locked = false; + } + } } // Lock certain modules @@ -113,7 +121,7 @@ class module_Core { */ static function install($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); + array_unshift($kohana_modules, gallery::plugin_path($module_name)); Kohana::config_set("core.modules", $kohana_modules); $installer_class = "{$module_name}_installer"; @@ -140,7 +148,7 @@ class module_Core { */ static function upgrade($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); + array_unshift($kohana_modules, gallery::plugin_path($module_name)); Kohana::config_set("core.modules", $kohana_modules); $version_before = module::get_version($module_name); @@ -179,7 +187,7 @@ class module_Core { */ static function activate($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); + array_unshift($kohana_modules, gallery::plugin_path($module_name)); Kohana::config_set("core.modules", $kohana_modules); $installer_class = "{$module_name}_installer"; @@ -271,7 +279,7 @@ class module_Core { $gallery = $module; } else { self::$active[] = $module; - $kohana_modules[] = MODPATH . $module->name; + $kohana_modules[] = gallery::plugin_path($module->name); } } self::$active[] = $gallery; // put gallery last in the module list to match core.modules diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index fb8f7ca7..3ba11aa2 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -30,11 +30,8 @@ class theme_Core { */ static function load_themes() { $modules = Kohana::config("core.modules"); - if (Router::$controller == "admin") { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme")); - } else { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme")); - } + array_unshift($modules, gallery::plugin_path(module::get_var("gallery", + (Router::$controller == "admin") ? "active_admin_theme" : "active_site_theme"), "theme")); Kohana::config_set("core.modules", $modules); } |