diff options
-rw-r--r-- | modules/gallery/controllers/admin_themes.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 12 |
2 files changed, 17 insertions, 16 deletions
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index 24f91aba..23685c90 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -34,22 +34,15 @@ class Admin_Themes_Controller extends Admin_Controller { 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; + $themes[$theme_name] = theme::get_info($theme_name); } return $themes; } 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->theme_name = $theme_name; + $view->info = theme::get_info($theme_name); + $view->theme_name = t($theme_name); $view->type = $type; if ($type == "admin") { $view->url = url::site("admin?theme=$theme_name"); @@ -62,18 +55,16 @@ class Admin_Themes_Controller extends Admin_Controller { public function choose($type, $theme_name) { 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 = theme::get_info($theme_name); if ($type == "admin" && $info->admin) { module::set_var("gallery", "active_admin_theme", $theme_name); message::success(t("Successfully changed your admin theme to <b>%theme_name</b>", - array("theme_name" => t($info->name)))); + array("theme_name" => $info->name))); } else if ($type == "site" && $info->site) { module::set_var("gallery", "active_site_theme", $theme_name); message::success(t("Successfully changed your Gallery theme to <b>%theme_name</b>", - array("theme_name" => t($info->name)))); + array("theme_name" => $info->name))); } url::redirect("admin/themes"); diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 5a3a328a..16ed104e 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -29,8 +29,8 @@ class theme_Core { * active for any given request. */ static function load_themes() { - $path = Input::instance()->server("PATH_INFO"); $input = Input::instance(); + $path = $input->server("PATH_INFO"); if (empty($path)) { $path = "/" . $input->get("kohana_uri"); } @@ -67,5 +67,15 @@ class theme_Core { $group->submit("")->value(t("Save")); return $form; } + + static function get_info($theme_name) { + $theme_name = preg_replace("/[^\w]/", "", $theme_name); + $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); + + return $theme_info; + } } |