diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-04 09:45:17 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-04 10:12:21 -0700 |
commit | aa0529d557ed0609bf7e5b23a5cf2437f7998c4b (patch) | |
tree | 028337388818b1a1ef0de24c9ee7d62162206e05 /modules/gallery/controllers/admin_themes.php | |
parent | 60c15e41b37fbe6b2adc7789b21b7e5acea3e949 (diff) |
Create a gallery::plugin_path which returns the appropriate path to the module or theme. This checks for the existence of an application/modules or application/themes first.
Diffstat (limited to 'modules/gallery/controllers/admin_themes.php')
-rw-r--r-- | modules/gallery/controllers/admin_themes.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index 24f91aba..722cfb45 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -29,17 +29,20 @@ class Admin_Themes_Controller extends Admin_Controller { private function _get_themes() { $themes = array(); - 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); + 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; + $themes[$theme_name] = $theme_info; + } + } } return $themes; } @@ -47,8 +50,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(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); + $view->info = new ArrayObject(parse_ini_file( + gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS); $view->theme_name = $theme_name; $view->type = $type; if ($type == "admin") { @@ -63,8 +66,8 @@ class Admin_Themes_Controller extends Admin_Controller { access::verify_csrf(); $theme_name = preg_replace("/[^\w]/", "", $theme_name); - $info = new ArrayObject( - parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); + $info = new ArrayObject(parse_ini_file( + gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS); if ($type == "admin" && $info->admin) { module::set_var("gallery", "active_admin_theme", $theme_name); |