Calling all Drupal developers!
Help us get this on the first page of Digg. DIGG NOW!
Help us get this on the first page of Digg. DIGG NOW!
_menu_translate(&$router_item, $map, $to_arg = FALSE)
6/includes/menu.inc, line 553
Handles dynamic path translation and menu access control.
When a user arrives on a page such as node/5, this function determines what "5" corresponds to, by inspecting the page's menu path definition, node/%node. This will call node_load(5) to load the corresponding node object.
It also works in reverse, to allow the display of tabs and menu items which contain these dynamic arguments, translating node/%node to node/5.
Translation of menu item titles and descriptions are done here to allow for storage of English strings in the database, and translation to the language required to generate the current page
$router_item A menu router item
$map An array of path arguments (ex: array('node', '5'))
$to_arg Execute $item['to_arg_functions'] or not. Use only if you want to render a path from the menu table, for example tabs.
Returns the map with objects loaded as defined in the $item['load_functions. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is set according to the map. If an error occurs during calling the load_functions (like trying to load a non existing node) then this function return FALSE.
| Name | Description |
|---|---|
| Menu system | Define the navigation menus, and route page requests to code based on URLs. |
<?php
function _menu_translate(&$router_item, $map, $to_arg = FALSE) {
$path_map = $map;
if (!_menu_load_objects($router_item, $map)) {
// An error occurred loading an object.
$router_item['access'] = FALSE;
return FALSE;
}
if ($to_arg) {
_menu_link_map_translate($path_map, $router_item['to_arg_functions']);
}
// Generate the link path for the page request or local tasks.
$link_map = explode('/', $router_item['path']);
for ($i = 0; $i < $router_item['number_parts']; $i++) {
if ($link_map[$i] == '%') {
$link_map[$i] = $path_map[$i];
}
}
$router_item['href'] = implode('/', $link_map);
$router_item['options'] = array();
_menu_check_access($router_item, $map);
// For performance, don't localize an item the user can't access.
if ($router_item['access']) {
_menu_item_localize($router_item, $map);
}
return $map;
}
?>