function fp_display_page

7.x theme.inc fp_display_page($page)
6.x theme.inc fp_display_page($page)
4.x theme.inc fp_display_page($page)
5.x theme.inc fp_display_page($page)

Output the contents of the $page variable to the screen. $page is an array containing details about the page, as well as its original menu item (router_item) definition.

3 calls to fp_display_page()
display_access_denied in includes/theme.inc
display_not_found in includes/theme.inc
index.php in ./index.php
The primary entry point for FlightPath.

File

includes/theme.inc, line 593

Code

function fp_display_page($page) {

  global $current_student_id, $screen, $user;
  $page_title = $page ["title"];
  if (@$GLOBALS ["fp_set_title"] != "") {
    $page_title = $GLOBALS ["fp_set_title"];
  }

  if (!is_object($screen)) {
    $screen = new AdvisingScreen("", null, "not_advising");
  }
  $screen->page_title = $page_title;
  $screen->page_has_search = @$page ["router_item"]["page_settings"]["page_has_search"];

  // Add some body classes to the page for this student.
  $student = $screen->student;
  if (!is_object($student)) {
    $student = new Student();
    $student->student_id = $current_student_id;
    $student->load_student_data();
  }
  if (is_object($student)) {
    fp_add_body_class("student-rank-$student->db_rank  student-catalog-year-$student->catalog_year");
  }


  $screen->page_banner_is_link = @$page ["router_item"]["page_settings"]["page_banner_is_link"];
  $screen->page_hide_report_error = @$page ["router_item"]["page_settings"]["page_hide_report_error"];
  $screen->page_is_popup = @$page ["router_item"]["page_settings"]["page_is_popup"];
  if (isset($page ["router_item"]["page_settings"]["screen_mode"])) {
    $screen->screen_mode = $page ["router_item"]["page_settings"]["screen_mode"];
  }
  if (isset($page ["router_item"]["page_settings"]["bool_print"])) {
    $screen->bool_print = $page ["router_item"]["page_settings"]["bool_print"];
  }


  if (@$_REQUEST ["scroll_top"] != "") {
    $screen->page_scroll_top = $_REQUEST ["scroll_top"];
  }

  // If there is a SESSION var for scroll_top, use that instead, then wipe it.
  if (@$_SESSION ['scroll_top'] != "") {
    $screen->page_scroll_top = $_SESSION ["scroll_top"];
    $_SESSION ['scroll_top'] = "";
    unset($_SESSION ['scroll_top']);
  }

  // Was this page a tab?  And if so, are there any other tabs we need to display? //
  if (@$page ["router_item"]["type"] == MENU_TYPE_TAB || @$page ["router_item"]["type"] == MENU_TYPE_DEFAULT_TAB || @$page ["router_item"]["tab_parent"] != "") {
    // We know we should have at least 1 tab for this page.
    $tab_array = fp_build_tab_array($page);
    $screen->page_tabs = fp_render_tab_array($tab_array);
  }

  // Should we override the page_tabs with what is in "fp_set_page_tabs" ?
  if (isset($GLOBALS ["fp_set_page_tabs"]) && is_array($GLOBALS ["fp_set_page_tabs"])) {
    //fpm($GLOBALS["fp_set_page_tabs"]);
    $screen->page_tabs = fp_render_tab_array($GLOBALS ["fp_set_page_tabs"]);
  }


  // Build up the content //

  $content_top = "";
  $page_show_title = @$page ["router_item"]["page_settings"]["page_show_title"];
  if (isset($GLOBALS ["fp_set_show_title"])) {
    $page_show_title = $GLOBALS ["fp_set_show_title"];
  }

  if ($page_show_title == FALSE) {
    $page_title = "";
  }


  $c = 0;

  // Are there any "menu_link"s for this?  In order words, little links at the top of the page,
  // where breadcrumbs might appear.
  if (!$screen->bool_print && @is_array($page ["router_item"]["page_settings"]["menu_links"])) {
    //$content_top .= "<ul class='top-menu-links'>";
    $crumbs = array();
    foreach ($page ["router_item"]["page_settings"]["menu_links"] as $item) {
      $lclass = "";
      if ($c == 0) {
        $lclass = 'first';
      }

      $p = menu_convert_replacement_pattern(@$item ["path"]);
      $q = menu_convert_replacement_pattern(@$item ["query"]);
      $t = @$item ["text"];
      $a = @$item ["attributes"];
      if (!is_array($a)) {
        $a = array();
      }

      // Make sure the current user has access to view this link.  Otherwise, do not even
      // bother showing it.
      $test_item = menu_get_item($p);
      if (!menu_check_user_access($test_item)) {
        continue;
      }


      //$content_top .= "<li class='$lclass'>" . l($t, $p, $q, $a) . "</li>";
      $crumbs [] = array('text' => $t, 'path' => $p, 'query' => $q, 'attributes' => $a);

      $c++;
    }
    //$content_top .= "</ul>";

    // If not already set!
    if (!isset($GLOBALS ['fp_breadcrumbs'])) {
      fp_set_breadcrumbs($crumbs);
    }
  }




  // Any sub-tabs we need to render?
  if (@$page ["router_item"]["type"] == MENU_TYPE_SUB_TAB) {
    $sub_tab_array = fp_build_sub_tab_array($page);
    $content_top .= fp_render_sub_tab_array($sub_tab_array);
  }

  // Should we override the page sub-tabs with what is in "fp_set_page_sub_tabs" ?
  if (isset($GLOBALS ["fp_set_page_sub_tabs"]) && is_array($GLOBALS ["fp_set_page_sub_tabs"])) {
    $content_top .= fp_render_sub_tab_array($GLOBALS ["fp_set_page_sub_tabs"]);
  }


  // If the REQUEST specifically asks NOT to show waiting fp_messages, then clear them from the session.
  if (isset($_REQUEST ['fp_messages']) && $_REQUEST ['fp_messages'] == 'none') {
    unset($_SESSION ['fp_messages']);
  }


  // If there are "messages" waiting, then let's add them to the top of content.
  if (isset($_SESSION ["fp_messages"]) && is_array($_SESSION ["fp_messages"]) && count($_SESSION ["fp_messages"]) > 0) {

    $content_top .= "<div class='fp-messages'>";
    foreach ($_SESSION ["fp_messages"] as $key => $tmsg) {
      $type = $tmsg ["type"];
      $message = $tmsg ["msg"];
      $content_top .= "<div class='fp-message fp-message-$type'>$message</div>";
    }
    $content_top .= "</div>";

    unset($_SESSION ["fp_messages"]);
  }


  // content_top gets the Currently Advising box.
  if (@$page ["router_item"]["page_settings"]["display_currently_advising"] == TRUE) {
    // To do this, we need to make sure the $screen->student object is loaded.
    $screen->page_display_currently_advising = TRUE;
    if (!$screen->student) {
      $screen->student = new Student($current_student_id);
    }
  }

  if (isset($page ["router_item"]["page_settings"]["display_currently_advising"])) {
    if ($page ["router_item"]["page_settings"]["display_currently_advising"] === FALSE) {
      // Meaning, we are explicitly saying do NOT show the currently advising box!
      $screen->page_display_currently_advising = FALSE;
    }
  }



  $screen->page_content = $content_top .= $page ["content"];

  if ($user->id > 0) {
    // meaning, they are logged in.
    $screen->page_content .= fp_render_mobile_hamburger_menu(); // add to the bottom
  }

  // Add in the body classes
  $screen->page_body_classes .= " " . @$GLOBALS ["fp_add_body_classes"];

  // Add in our URL  (after we sanitize it appropriately)
  $class = @$_REQUEST ['q'];
  $class = str_replace("'", '', $class);
  $class = str_replace('"', '', $class);
  $class = str_replace('(', '', $class);
  $class = str_replace(')', '', $class);
  $class = str_replace(';', '', $class);
  $class = str_replace('.', '', $class);
  $class = str_replace('<', '', $class);
  $class = str_replace('>', '', $class);
  $class = str_replace('/', '-', $class);
  $class = str_replace('\\', '', $class);
  $class = str_replace('#', '', $class);
  $class = str_replace('&', '', $class);

  $screen->page_body_classes .= " page--" . str_replace("/", "-", $class);


  $screen->output_to_browser();
}