function menu_get_menu_router_item_from_db

7.x menu.inc menu_get_menu_router_item_from_db($path)
6.x menu.inc menu_get_menu_router_item_from_db($path)
4.x menu.inc menu_get_menu_router_item_from_db($path)
5.x menu.inc menu_get_menu_router_item_from_db($path)

Return array from menu_router for this item. *

1 call to menu_get_menu_router_item_from_db()
menu_get_item in includes/menu.inc
Figure out which menu_router path matches the supplied path and return it.

File

includes/menu.inc, line 286

Code

function menu_get_menu_router_item_from_db($path) {
  $res = db_query("SELECT * FROM menu_router WHERE path = '?' ", $path);
  $cur = db_fetch_array($res);

  if ($cur ["path"] != $path) {
    // It was not found!
    return NULL;
  }

  // Unserialize the things which are supposed to be unserialized.
  $cur ["page_arguments"] = unserialize($cur ["page_arguments"]);
  if (!is_array($cur ["page_arguments"])) {
    $cur ["page_arguments"] = array();
  }

  // If any of the page_arguments is a number by itself, we will instead
  // use the number of the URL args.
  // For example, if the URL path is "node/edit/apple"
  // and there is a page_argument for the number 2, we will replace
  // it with "apple".  This is how the menu system can use wildcards from the url
  // for the page arguments.
  foreach ($cur ["page_arguments"] as $c => $arg) {
    if (is_numeric($arg)) {
      $temp = explode("/", $_REQUEST ["q"]);
      $cur ["page_arguments"][$c] = $temp [$arg];
    }
  }


  $cur ["access_arguments"] = unserialize($cur ["access_arguments"]);
  if (!is_array($cur ["access_arguments"])) {
    $cur ["access_arguments"] = array();
  }


  // Same situation for access_arguments as the page_arguments above.
  foreach ($cur ["access_arguments"] as $c => $arg) {
    if (is_numeric($arg)) {
      $temp = explode("/", $_REQUEST ["q"]);
      $cur ["access_arguments"][$c] = $temp [$arg];
    }
  }



  $cur ["page_settings"] = unserialize($cur ["page_settings"]);
  if (!is_array($cur ["page_settings"])) {
    $cur ["page_settings"] = array();
  }

  // If there is a title property, run it through t()
  if ($cur ["title"] != "") {
    $cur ["title"] = t($cur ["title"]);
  }

  // If there is a description, run through t()
  if ($cur ["description"] != "") {
    $cur ["description"] = t($cur ["description"]);
  }

  // If the page_settings has menu links, run their texts through t().
  foreach ($cur ["page_settings"] as $key => $val) {
    if ($key == "menu_links" && is_array($val)) {
      foreach ($val as $c => $mitems) {
        if ($mitems ["text"] != "") {
          $cur ["page_settings"]["menu_links"][$c]["text"] = t($mitems ["text"]);
        }
      }
    }
  }


  return $cur;

}