From c33b24c9faf5d83e4f1bfc6d3778da6c37139b3f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 1 Aug 2010 21:00:30 -0700 Subject: Make maintenance mode a variable instead of a config. Then create links on the Admin > Maintenance page to allow you to turn it on and off. This should be efficient since we cache all vars and look them up on every request anyway. This also allows us to have the Fix task enable maintenance mode while it's running which greatly reduces the chances that somebody will come along and hork the database while we're tinkering with MPTT pointers. Fixes ticket #1259. --- modules/gallery/libraries/Theme_View.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/gallery/libraries/Theme_View.php') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 6246c6f1..7b90c034 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -46,9 +46,11 @@ class Theme_View_Core extends Gallery_View { $this->set_global("thumb_proportion", $this->thumb_proportion()); } - $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); - if ($maintenance_mode) { - message::warning(t("This site is currently in maintenance mode")); + if (module::get_var("gallery", "maintenance_mode", false)) { + if (identity::active_user()->admin) { + message::warning(t("This site is currently in maintenance mode. Visit the maintenance page", array("maintenance_url" => url::site("admin/maintenance")))); + } else + message::warning(t("This site is currently in maintenance mode.")); } } -- cgit v1.2.3 From 400c248e2d2c9acf022a247b80ed298ba0deab85 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 1 Aug 2010 21:10:27 -0700 Subject: default maintenance_mode from false -> 0 for consistency with the value we set in the db --- modules/gallery/helpers/gallery.php | 2 +- modules/gallery/libraries/Theme_View.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gallery/libraries/Theme_View.php') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 33a6830c..82b8a790 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -26,7 +26,7 @@ class gallery_Core { */ static function maintenance_mode() { if (Router::$controller != "login" && - module::get_var("gallery", "maintenance_mode", false) && + module::get_var("gallery", "maintenance_mode", 0) && !identity::active_user()->admin) { Router::$controller = "maintenance"; Router::$controller_path = MODPATH . "gallery/controllers/maintenance.php"; diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 7b90c034..46291005 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -46,7 +46,7 @@ class Theme_View_Core extends Gallery_View { $this->set_global("thumb_proportion", $this->thumb_proportion()); } - if (module::get_var("gallery", "maintenance_mode", false)) { + if (module::get_var("gallery", "maintenance_mode", 0)) { if (identity::active_user()->admin) { message::warning(t("This site is currently in maintenance mode. Visit the maintenance page", array("maintenance_url" => url::site("admin/maintenance")))); } else -- cgit v1.2.3 From ab598b2931dbff1165e66bc271e6b49166fe0a7e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 29 Aug 2010 21:15:58 -0700 Subject: Put the theme CSS at the end of the module CSS so that the theme has the final say. Fixes ticket #1315. --- modules/gallery/libraries/Theme_View.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/gallery/libraries/Theme_View.php') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 46291005..7a6bc1da 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -236,6 +236,13 @@ class Theme_View_Core extends Gallery_View { case "thumb_bottom": case "thumb_info": case "thumb_top": + if ($function == "head") { + // Stash any CSS we have already; that came from the theme and we want theme CSS to + // override module CSs + $save_css = $this->css; + $this->css = array(); + } + $blocks = array(); if (method_exists("gallery_theme", $function)) { switch (count($args)) { @@ -275,6 +282,8 @@ class Theme_View_Core extends Gallery_View { } if ($function == "head") { + // Merge the theme CSS/JS at the end + $this->css = array_merge($this->css, $save_css); array_unshift($blocks, $this->combine_files($this->css, "css")); array_unshift($blocks, $this->combine_files($this->scripts, "javascript")); } -- cgit v1.2.3