diff options
Diffstat (limited to 'modules/gallery/helpers/theme.php')
-rw-r--r-- | modules/gallery/helpers/theme.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 16ed104e..efc9b9e6 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -24,6 +24,8 @@ * Note: by design, this class does not do any permission checking. */ class theme_Core { + public static $active_theme; + /** * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. @@ -35,15 +37,22 @@ class theme_Core { $path = "/" . $input->get("kohana_uri"); } + $is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); + $setting_name = $is_admin ? "active_admin_theme" : "active_site_theme"; if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) { - $theme_name = module::get_var( - "gallery", - $path == "/admin" || !strncmp($path, "/admin/", 7) ? - "active_admin_theme" : "active_site_theme"); + $theme_name = module::get_var("gallery", $setting_name); + + if (!file_exists(THEMEPATH . $theme_name)) { + Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme."); + $theme_name = $is_admin ? "admin_wind" : "wind"; + module::set_var("gallery", $setting_name, $theme_name); + } } $modules = Kohana::config("core.modules"); array_unshift($modules, THEMEPATH . $theme_name); Kohana::config_set("core.modules", $modules); + + self::$active_theme = $theme_name; } static function get_edit_form_admin() { |