From 28b41056e3ea962dce1ad017a3c0a60252195e7a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 27 May 2009 15:07:27 -0700 Subject: Restructure things so that the application is now just another module. Kohana makes this type of transition fairly straightforward in that all controllers/helpers/etc are still located in the cascading filesystem without any extra effort, except that I've temporarily added a hack to force modules/gallery into the module path. Rename what's left of "core" to be "application" so that it conforms more closely to the Kohana standard (basically, just application/config/config.php which is the minimal thing that you need in the application directory) There's still considerable work left to be done here. --- modules/gallery/controllers/admin_themes.php | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 modules/gallery/controllers/admin_themes.php (limited to 'modules/gallery/controllers/admin_themes.php') diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php new file mode 100644 index 00000000..05c134d1 --- /dev/null +++ b/modules/gallery/controllers/admin_themes.php @@ -0,0 +1,79 @@ +content = new View("admin_themes.html"); + $view->content->admin = module::get_var("core", "active_admin_theme"); + $view->content->site = module::get_var("core", "active_site_theme"); + $view->content->themes = $this->_get_themes(); + print $view; + } + + 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); + $themes[$theme_name] = $theme_info; + } + 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->type = $type; + if ($type == "admin") { + $view->url = url::site("admin?theme=$theme_name"); + } else { + $view->url = url::site("albums/1?theme=$theme_name"); + } + print $view; + } + + 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); + + if ($type == "admin" && $info->admin) { + module::set_var("core", "active_admin_theme", $theme_name); + message::success(t("Successfully changed your admin theme to %theme_name", + array("theme_name" => $info->name))); + } else if ($type == "site" && $info->site) { + module::set_var("core", "active_site_theme", $theme_name); + message::success(t("Successfully changed your Gallery theme to %theme_name", + array("theme_name" => $info->name))); + } + + url::redirect("admin/themes"); + } +} + -- cgit v1.2.3