? modules/overlay/overlay.css Index: modules/overlay/overlay.module =================================================================== RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v retrieving revision 1.31 diff -u -p -r1.31 overlay.module --- modules/overlay/overlay.module 31 Aug 2010 15:04:09 -0000 1.31 +++ modules/overlay/overlay.module 1 Sep 2010 19:23:53 -0000 @@ -30,6 +30,28 @@ function overlay_menu() { 'access arguments' => array('access overlay'), 'type' => MENU_CALLBACK, ); + // disable the overlays directly without potentially opening an overlay + $items['overlay/disable/%'] = array( + 'type' => MENU_CALLBACK, + 'access arguments' => array('access overlay'), + 'page callback' => 'overlay_user_disable', + 'page arguments' => array(2), + ); + // dismiss the accessibility message + $items['overlay/message-dismiss/%'] = array( + 'type' => MENU_CALLBACK, + 'access arguments' => array('access overlay'), + 'page callback' => 'overlay_user_message_dismiss', + 'page arguments' => array(2), + ); + // provide a dedicated explanatory page + $items['overlay/accessibility-explanation'] = array( + 'title' => 'Administrative overlays and accessibility', + 'type' => MENU_CALLBACK, + 'access arguments' => array('access overlay'), + 'page callback' => 'overlay_accessibility_page', + 'page arguments' => array(2), + ); return $items; } @@ -253,14 +275,94 @@ function overlay_page_alter(&$page) { $page[$skipped_region]['#access'] = FALSE; } } - if (overlay_get_mode() == 'child') { // Add the overlay wrapper before the html wrapper. array_unshift($page['#theme_wrappers'], 'overlay'); } + else { + global $user; + $use_overlay = !isset($user->data['overlay']) || $user->data['overlay']; + if (user_access('access overlay') && $use_overlay) { + // @todo: no UI for "revoking" the dismissal. Once dismissed situations can occur in which the overlays will have to used to disable the overlays + $dismissed = isset($user->data['overlay_message_dismissed']) && $user->data['overlay_message_dismissed']; + // show the disabled disable overlay link only if + // - the message has not been dismissed + // - the user is not on the explanatory page + // - the user is on a page on which links open in overlays (e.g. typing user/X/edit into a browser gets you onto a page that does not open links in overlays) + if ( !$dismissed && $_GET['q'] != 'overlay/accessibility-explanation' && overlay_get_mode() == 'parent') { + // Insert the link at the top and wrap it in a
to keep it similar to "skip-link" + // @todo: .element-invisible will need to be replaced/fixed cf. "Make .element-invisible work for focusable elements like links" (http://drupal.org/node/897638) + $page['page_top']['disable_overlay'] = array( + '#markup' => '
' . l(t('Click here if you have problems accessing the administrative pages (opening in Administrative overlays) or you want to dismiss this message.'), 'overlay/accessibility-explanation', array('query' => drupal_get_destination())) . '
', + '#weight' => -99 + ); + } + } + } } /** + * Menu callback disabling the overlay and redirecting back to the last page. + * If no destination was given, this redirects to the user edit page. + */ +function overlay_user_disable($token) { + if ($token == drupal_get_token('overlay')) { + global $user; + user_save(user_load($user->uid), array('data' => array('overlay' => 0))); + drupal_set_message( + t('The administrative overlay has been disabled. !user_profile_link', + array('!user_profile_link' => l( t('You can (re-)enable the overlay by editing your User Profile.'), 'user/' . $user->uid . '/edit' ) ) + ) + ); + drupal_goto('user/' . $user->uid . '/edit'); + } + else { + drupal_access_denied(); + } +} + +/** + * Menu callback dismissing the accessibility messag redirecting back to the last page. + * If no destination was given, this redirects to the user edit page. + */ +function overlay_user_message_dismiss($token) { + if ($token == drupal_get_token('overlay')) { + global $user; + user_save(user_load($user->uid), array('data' => array('overlay_message_dismissed' => 1))); + drupal_set_message(t('The message displayed at the top of the page has been dismissed.')); + drupal_goto('user/' . $user->uid . '/edit'); + } + else { + drupal_access_denied(); + } +} + +/** + * Page explaining accessibility issues/concerns of overlays. Links to disabling overlays, dismissing message (and when overlays disabled link to user profile) + */ +function overlay_accessibility_page() { + global $user; + $text = t('Explain here in detail what this whole thing is and why it may interfere.'); + $use_overlay = !isset($user->data['overlay']) || $user->data['overlay']; + $links = array(); + if ( $use_overlay ) { + $links[] = array('title' => t('Disable the Administrative overlay.'), 'href' => 'overlay/disable/' . drupal_get_token('overlay'), 'query' => drupal_get_destination()); + $dismissed = isset($user->data['overlay_message_dismissed']) && $user->data['overlay_message_dismissed']; + if (!$dismissed) { + $links[] = array('title' => t('Dismiss the message displayed at the top of pages.'), 'href' => 'overlay/message-dismiss/' . drupal_get_token('overlay'), 'query' => drupal_get_destination()); + } + } + else { + // the overlay is not active therefore the user profile will not open in an overlay and be accessible + $links[] = array('title' => t('Enable the Administrative overlay from your User Profile.'), 'href' => 'user/' . $user->uid . '/edit'); + } + // @todo: theming? + $text .= theme('links', array('links' => $links)); + return $text; +} + + +/** * Implements hook_block_list_alter(). */ function overlay_block_list_alter(&$blocks) {