_menu_link_translate

Versions
6 – 7
_menu_link_translate(&$item)

This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions.

Parameters

$item A menu link

Return value

Returns the map of path arguments with objects loaded as defined in the $item['load_functions']:

  • $item['access'] becomes TRUE if the item is accessible, FALSE otherwise.
  • $item['href'] is generated from link_path, possibly by to_arg functions.
  • $item['title'] is generated from link_title, and may be localized.
  • $item['options'] is unserialized; it is also changed within the call here to $item['localized_options'] by _menu_item_localize().

Related topics

▾ 7 functions call _menu_link_translate()

book_link_load in modules/book/book.module
Like menu_link_load(), but adds additional data from the {book} table.
menu_link_load in includes/menu.inc
Get a menu link by its mlid, access checked and link translated for rendering.
menu_valid_path in includes/menu.inc
Validates the path of a menu link being created or edited.
system_admin_menu_block in modules/system/system.module
Provide a single block on the administration overview page.
system_get_module_admin_tasks in modules/system/system.module
Generate a list of tasks offered by a specified module.
system_main_admin_page in modules/system/system.admin.inc
Menu callback; Provide the administration overview page.
_menu_tree_check_access in includes/menu.inc
Recursive helper function for menu_tree_check_access()

Code

includes/menu.inc, line 635

<?php
function _menu_link_translate(&$item) {
  $item['options'] = unserialize($item['options']);
  if ($item['external']) {
    $item['access'] = 1;
    $map = array();
    $item['href'] = $item['link_path'];
    $item['title'] = $item['link_title'];
    $item['localized_options'] = $item['options'];
  }
  else {
    $map = explode('/', $item['link_path']);
    _menu_link_map_translate($map, $item['to_arg_functions']);
    $item['href'] = implode('/', $map);

    // Note - skip callbacks without real values for their arguments.
    if (strpos($item['href'], '%') !== FALSE) {
      $item['access'] = FALSE;
      return FALSE;
    }
    // menu_tree_check_access() may set this ahead of time for links to nodes.
    if (!isset($item['access'])) {
      if (!_menu_load_objects($item, $map)) {
        // An error occurred loading an object.
        $item['access'] = FALSE;
        return FALSE;
      }
      _menu_check_access($item, $map);
    }
    // For performance, don't localize a link the user can't access.
    if ($item['access']) {
      _menu_item_localize($item, $map, TRUE);
    }
  }

  // Allow other customizations - e.g. adding a page-specific query string to the
  // options array. For performance reasons we only invoke this hook if the link
  // has the 'alter' flag set in the options array.
  if (!empty($item['options']['alter'])) {
    drupal_alter('translated_menu_link', $item, $map);
  }

  return $map;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.