function fp_build_tab_array

6.x theme.inc fp_build_tab_array($page)
4.x theme.inc fp_build_tab_array($page)
5.x theme.inc fp_build_tab_array($page)

Looks at the current page array and returns a valid $tab_array Meant for the top of the screen.

1 call to fp_build_tab_array()
fp_display_page in includes/theme.inc
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.

File

includes/theme.inc, line 1750

Code

function fp_build_tab_array($page) {
  global $current_student_id;
  $tab_array = array();

  $tab_family = $page ["router_item"]["tab_family"];
  $active_tab_path = $page ["path"];

  if ($page ["router_item"]["tab_parent"] != "") {
    // We want to know the PARENT's tab_family, so we can display the correct tabs at the top of the page.
    $tab_parent = $page ["router_item"]["tab_parent"];

    $item = menu_get_item($tab_parent);
    $tab_family = $item ["tab_family"];
    $active_tab_path = $item ["path"];

  }

  // look for other possible tabs, based on the "tab_family" value 
  // Also check to make sure the user has access to the tab.   
  $items = menu_get_items_in_tab_family($tab_family);
  foreach ($items as $item) {

    // Does the user have access to this tab?
    if (!menu_check_user_access($item)) {
      continue;
    }

    $title = $tab_title = $item ["title"];
    $path = $item ["path"];

    if (isset($item ["page_settings"]["tab_title"])) {
      $tab_title = $item ["page_settings"]["tab_title"];
    }


    if (strstr($path, "%")) {
      // it contains at least one wildcard.  So, let's replace the wildcard with
      // the coresponding value from arg().  Ex:  content/%/edit  (when we are on content/55/view) would == content/55/edit.
      $new_path = "";
      $pieces = explode("/", $path);
      foreach ($pieces as $c => $piece) {
        if ($piece != "%") {
          $new_path .= $piece . "/";
        }
        else {
          // This WAS a wildcard.  Replace with arg() value.
          $a = @arg($c);
          $new_path .= $a . "/";
        }

      }
      $new_path = rtrim($new_path, "/"); // get rid of trailing slash.
      $path = $new_path;
    }


    $active = FALSE;
    $on_click = @$page ["page_settings"]["tab_on_click"];
    $href = "";
    if ($on_click == "") {
      // Just a simple link to the path
      // Include the current_student_id!
      $query = "current_student_id=$current_student_id";

      $turl = fp_url($path, $query, TRUE);

      //$on_click = "window.location=\"" . $turl . "\"";
      $href = $turl;
    }

    if ($path == $active_tab_path) {
      // This is the current page we are on.
      $active = TRUE;
      $title = $tab_title;
      $on_click = "";
      $href = "";
    }

    $tab_array [] = array(
      "title" => $tab_title,
      "active" => $active,
      "on_click" => $on_click,
      "href" => $href,
    );

  }

  return $tab_array;
}