From 72e44a39af7ab15e2c95474dda3ad5bea6c28340 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 11 Jun 2010 12:30:30 +0000 Subject: [PATCH] =?UTF-8?q?-=20Patch=20#743908=20by=20David=5FRothstein,?= =?UTF-8?q?=20casey,=20G=C3=A1bor=20Hojtsy:=20skip=20overlay=20initializat?= =?UTF-8?q?ion=20if=20already=20done.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/overlay/overlay.module | 38 ++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module index 541d7641ea8..2b2b31124a0 100644 --- a/modules/overlay/overlay.module +++ b/modules/overlay/overlay.module @@ -68,9 +68,12 @@ function overlay_theme() { function overlay_init() { // @todo: custom_theme does not exist anymore. global $custom_theme; - // Only act if the user has access to administration pages. Other modules can - // also enable the overlay directly for other uses of the JavaScript. - if (user_access('access overlay')) { + + $mode = overlay_get_mode(); + + // Only act if the user has access to the overlay and a mode was not already + // set. Other modules can also enable the overlay directly for other uses. + if (empty($mode) && user_access('access overlay')) { $current_path = current_path(); // After overlay is enabled on the modules page, redirect to // #overlay=admin/modules to actually enable the overlay. @@ -469,16 +472,28 @@ function overlay_get_mode() { } /** - * Set overlay mode and add proper JavaScript and styles to the page. + * Sets the overlay mode and adds proper JavaScript and styles to the page. + * + * Note that since setting the overlay mode triggers a variety of behaviors + * (including hooks being invoked), it can only be done once per page request. + * Therefore, the first call to this function which passes along a value of the + * $mode parameter controls the overlay mode that will be used. * * @param $mode - * To set the mode, pass in either 'parent' or 'child'. 'parent' is used in - * the context of a parent window (a regular browser window), and JavaScript - * is added so that administrative links in the parent window will open in - * an overlay. 'child' is used in the context of the child overlay window (the - * page actually appearing within the overlay iframe) and JavaScript and CSS - * are added so that Drupal behaves nicely from within the overlay. - * + * To set the mode, pass in one of the following values: + * - 'parent': This is used in the context of a parent window (a regular + * browser window). If set, JavaScript is added so that administrative + * links in the parent window will open in an overlay. + * - 'child': This is used in the context of the child overlay window (the + * page actually appearing within the overlay iframe). If set, JavaScript + * and CSS are added so that Drupal behaves nicely from within the overlay. + * - 'none': This is used to avoid adding any overlay-related code to the + * page at all. Modules can set this to explicitly prevent the overlay from + * being used. For example, since the overlay module itself sets the mode + * to 'parent' or 'child' in overlay_init() when certain conditions are + * met, other modules which want to override that behavior can do so by + * setting the mode to 'none' earlier in the page request - e.g., in their + * own hook_init() implementations, if they have a lower weight. * This parameter is optional, and if omitted, the current mode will be * returned with no action taken. * @@ -486,6 +501,7 @@ function overlay_get_mode() { * The current mode, if any has been set, or NULL if no mode has been set. * * @ingroup overlay_api + * @see overlay_init() */ function overlay_set_mode($mode = NULL) { global $base_path;