From 3e6ba7acc3291f2268cbe9c9bef0a492b557babb Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 4 Oct 2009 00:27:22 -0600 Subject: Renamed most, if not all css selectors from gName to g-name. Moved a few shared images from wind to lib. Deleted unused images in the admin_wind. This will likely break a few ajax features. --- modules/gallery/helpers/theme.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/gallery/helpers/theme.php') diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index b46a2c14..fb8f7ca7 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -40,22 +40,22 @@ class theme_Core { } static function get_edit_form_admin() { - $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"gThemeOptionsForm")); + $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); $group = $form->group("edit_theme"); - $group->input("page_size")->label(t("Items per page"))->id("gPageSize") + $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "page_size")); - $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("gThumbSize") + $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "thumb_size")); - $group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("gResizeSize") + $group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("g-resize-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "resize_size")); - $group->textarea("header_text")->label(t("Header text"))->id("gHeaderText") + $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") ->value(module::get_var("gallery", "header_text")); - $group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText") + $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") ->value(module::get_var("gallery", "footer_text")); - $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText") + $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text") ->checked(module::get_var("gallery", "show_credits")); $group->submit("")->value(t("Save")); return $form; -- cgit v1.2.3 From aa0529d557ed0609bf7e5b23a5cf2437f7998c4b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 4 Oct 2009 09:45:17 -0700 Subject: 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. --- modules/gallery/controllers/admin_themes.php | 31 +++++++++++++----------- modules/gallery/helpers/gallery.php | 13 ++++++++++ modules/gallery/helpers/gallery_installer.php | 4 ++-- modules/gallery/helpers/module.php | 34 +++++++++++++++++---------- modules/gallery/helpers/theme.php | 7 ++---- 5 files changed, 55 insertions(+), 34 deletions(-) (limited to 'modules/gallery/helpers/theme.php') 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); 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); } -- cgit v1.2.3 From 2634a683b30982963264faf9867d32d1aa71a182 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 4 Oct 2009 10:04:35 -0700 Subject: Revert "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." This reverts commit e1e1461a77caf5bff457927f098366497de6ffff. --- modules/gallery/controllers/admin_themes.php | 31 +++++++++++------------- modules/gallery/helpers/gallery.php | 13 ---------- modules/gallery/helpers/gallery_installer.php | 4 ++-- modules/gallery/helpers/module.php | 34 ++++++++++----------------- modules/gallery/helpers/theme.php | 7 ++++-- 5 files changed, 34 insertions(+), 55 deletions(-) (limited to 'modules/gallery/helpers/theme.php') 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); } -- cgit v1.2.3 From 68411cc903a1fedd5014763f55f3925c5a971b0f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 23 Oct 2009 17:58:55 -0700 Subject: Allow themes to override event handlers. In gallery::ready() grab the server PATH_INFO and pass it to the theme::load_themes method. If it starts with \"/admin\", then set the theme to the active admin theme, otherwise set it to the active site theme. Fixes ticket #841: Themes cannot overload event classes." --- modules/gallery/helpers/gallery_event.php | 1 + modules/gallery/helpers/theme.php | 5 ++--- modules/gallery/hooks/init_gallery.php | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'modules/gallery/helpers/theme.php') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index e0de2152..d45f5316 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -23,6 +23,7 @@ class gallery_event_Core { * Initialization. */ static function gallery_ready() { + theme::load_themes(Input::instance()->server("PATH_INFO")); user::load_user(); locales::set_request_locale(); } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index fb8f7ca7..5588fbce 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -28,14 +28,13 @@ class theme_Core { * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. */ - static function load_themes() { + static function load_themes($path) { $modules = Kohana::config("core.modules"); - if (Router::$controller == "admin") { + if (strpos($path, "/admin") === 0) { 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); } diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index da7eeb0f..b2d9c4de 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -27,7 +27,6 @@ if (!file_exists(VARPATH . "database.php")) { Event::add("system.ready", array("I18n", "instance")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); -Event::add("system.post_routing", array("theme", "load_themes")); Event::add("system.post_routing", array("url", "parse_url")); Event::add("system.post_routing", array("gallery", "maintenance_mode")); Event::add("system.shutdown", array("gallery", "shutdown")); -- cgit v1.2.3 From 91e9df7834b98088ba478f691fee73f75ed092fa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 24 Oct 2009 10:37:12 -0700 Subject: Update themes::load_theme() to work with mod_rewrite's short urls. --- modules/gallery/helpers/gallery_event.php | 2 +- modules/gallery/helpers/theme.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules/gallery/helpers/theme.php') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 9fc68af5..216efa36 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -23,7 +23,7 @@ class gallery_event_Core { * Initialization. */ static function gallery_ready() { - theme::load_themes(Input::instance()->server("PATH_INFO")); + theme::load_themes(); identity::load_user(); locales::set_request_locale(); } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 5588fbce..64e919e3 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -28,13 +28,17 @@ class theme_Core { * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. */ - static function load_themes($path) { - $modules = Kohana::config("core.modules"); - if (strpos($path, "/admin") === 0) { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme")); - } else { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme")); + static function load_themes() { + $path = Input::instance()->server("PATH_INFO"); + if (empty($path)) { + $path = "/" . Input::instance()->get("kohana_uri"); } + + $theme_name = module::get_var( + "gallery", + !strncmp($path, "/admin", 6) ? "active_admin_theme" : "active_site_theme"); + $modules = Kohana::config("core.modules"); + array_unshift($modules, THEMEPATH . $theme_name); Kohana::config_set("core.modules", $modules); } -- cgit v1.2.3 From 96cbfe23a6031fc8fb87aadb37fec2e4e479bc0c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 3 Nov 2009 14:03:36 -0800 Subject: Respect the "theme" variable if we're an admin. This requires us to change the order of operations in gallery_event::gallery_ready() so that we load users before themes. Fixes ticket #836. --- modules/gallery/helpers/gallery_event.php | 2 +- modules/gallery/helpers/theme.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'modules/gallery/helpers/theme.php') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 67a6f41f..e3cb6a9b 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -23,8 +23,8 @@ class gallery_event_Core { * Initialization. */ static function gallery_ready() { - theme::load_themes(); identity::load_user(); + theme::load_themes(); locales::set_request_locale(); } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 64e919e3..da57a37e 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -30,13 +30,16 @@ class theme_Core { */ static function load_themes() { $path = Input::instance()->server("PATH_INFO"); + $input = Input::instance(); if (empty($path)) { - $path = "/" . Input::instance()->get("kohana_uri"); + $path = "/" . $input->get("kohana_uri"); } - $theme_name = module::get_var( - "gallery", - !strncmp($path, "/admin", 6) ? "active_admin_theme" : "active_site_theme"); + if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) { + $theme_name = module::get_var( + "gallery", + !strncmp($path, "/admin", 6) ? "active_admin_theme" : "active_site_theme"); + } $modules = Kohana::config("core.modules"); array_unshift($modules, THEMEPATH . $theme_name); Kohana::config_set("core.modules", $modules); -- cgit v1.2.3