You are here

function popups_init in Popups API (Ajax Dialogs) 7

Same name and namespace in other branches
  1. 5 popups.module \popups_init()
  2. 6.2 popups.module \popups_init()
  3. 6 popups.module \popups_init()

hook_init

Look at the page path and see if popup behavior has been requested for any links in this page.

File

./popups.module, line 70
popup.module

Code

function popups_init() {
  $popups = popups_get_popups();
  if (isset($popups[$_GET['q']])) {
    popups_add_popups($popups[$_GET['q']]);
  }

  // Check and see if the page_override param is in the URL.
  // Note - the magic happens here.
  // Need to cache the page_override flag in the session, so it will effect
  // the results page that follows a form submission.
  if (isset($_GET['page_override'])) {
    $_SESSION['page_override'] = $_GET['page_override'];
  }

  // Move the page_override flag back out of the session.
  if (isset($_SESSION['page_override'])) {

    // This call will not return on form submission.
    $return = menu_execute_active_handler();

    // The call did return, so it wasn't a form request,
    // so we are returning a result, so clear the session flag.
    $override = $_SESSION['page_override'];
    unset($_SESSION['page_override']);

    // Menu status constants are integers; page content is a string.
    if (isset($return) && !is_int($return) && isset($override)) {
      print theme($override . '_page', $return);
      exit;

      // Do not continue processing request in index.html.
    }
  }
}