diff options
-rw-r--r-- | modules/gallery/controllers/admin_themes.php | 31 | ||||
-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 |
5 files changed, 34 insertions, 55 deletions
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index 722cfb45..24f91aba 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -29,20 +29,17 @@ class Admin_Themes_Controller extends Admin_Controller { private function _get_themes() { $themes = array(); - foreach (array(APPPATH . "themes/", THEMEPATH) as $themepath) { - foreach (scandir($themepath) as $theme_name) { - if ($theme_name[0] == ".") { - continue; - } - $file = $themepath . "$theme_name/theme.info"; - if (file_exists($file)) { - $theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); - $theme_info->description = t($theme_info->description); - $theme_info->name = t($theme_info->name); - - $themes[$theme_name] = $theme_info; - } + foreach (scandir(THEMEPATH) as $theme_name) { + if ($theme_name[0] == ".") { + continue; } + + $file = THEMEPATH . "$theme_name/theme.info"; + $theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); + $theme_info->description = t($theme_info->description); + $theme_info->name = t($theme_info->name); + + $themes[$theme_name] = $theme_info; } return $themes; } @@ -50,8 +47,8 @@ class Admin_Themes_Controller extends Admin_Controller { public function preview($type, $theme_name) { $view = new View("admin_themes_preview.html"); $theme_name = preg_replace("/[^\w]/", "", $theme_name); - $view->info = new ArrayObject(parse_ini_file( - gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS); + $view->info = new ArrayObject( + parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); $view->theme_name = $theme_name; $view->type = $type; if ($type == "admin") { @@ -66,8 +63,8 @@ class Admin_Themes_Controller extends Admin_Controller { access::verify_csrf(); $theme_name = preg_replace("/[^\w]/", "", $theme_name); - $info = new ArrayObject(parse_ini_file( - gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS); + $info = new ArrayObject( + parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); if ($type == "admin" && $info->admin) { module::set_var("gallery", "active_admin_theme", $theme_name); diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 6d387d76..37a08d08 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -110,17 +110,4 @@ 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 e834a62c..b1ea1f19 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) { - $file = gallery::plugin_path("$theme_name/theme.info", "theme"); - $theme_info = new ArrayObject(parse_ini_file($file, ArrayObject::ARRAY_AS_PROPS); + $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), + 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 99c52cab..fe37f4f9 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -77,23 +77,15 @@ class module_Core { static function available() { if (empty(self::$available)) { $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); - 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; - } - } + 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; } // Lock certain modules @@ -121,7 +113,7 @@ class module_Core { */ static function install($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, gallery::plugin_path($module_name)); + array_unshift($kohana_modules, MODPATH . $module_name); Kohana::config_set("core.modules", $kohana_modules); $installer_class = "{$module_name}_installer"; @@ -148,7 +140,7 @@ class module_Core { */ static function upgrade($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, gallery::plugin_path($module_name)); + array_unshift($kohana_modules, MODPATH . $module_name); Kohana::config_set("core.modules", $kohana_modules); $version_before = module::get_version($module_name); @@ -187,7 +179,7 @@ class module_Core { */ static function activate($module_name) { $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, gallery::plugin_path($module_name)); + array_unshift($kohana_modules, MODPATH . $module_name); Kohana::config_set("core.modules", $kohana_modules); $installer_class = "{$module_name}_installer"; @@ -279,7 +271,7 @@ class module_Core { $gallery = $module; } else { self::$active[] = $module; - $kohana_modules[] = gallery::plugin_path($module->name); + $kohana_modules[] = MODPATH . $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 3ba11aa2..fb8f7ca7 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -30,8 +30,11 @@ class theme_Core { */ static function load_themes() { $modules = Kohana::config("core.modules"); - array_unshift($modules, gallery::plugin_path(module::get_var("gallery", - (Router::$controller == "admin") ? "active_admin_theme" : "active_site_theme"), "theme")); + 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")); + } Kohana::config_set("core.modules", $modules); } |