function _token_menu_link_translate in Token 7
Same name and namespace in other branches
- 6 token.module \_token_menu_link_translate()
2 calls to _token_menu_link_translate()
- token_book_link_load in ./
token.module - Get a translated book menu link by its mlid, without access checking.
- token_menu_link_load in ./
token.module - Get a translated menu link by its mlid, without access checking.
File
- ./
token.module, line 1094 - Enhances the token API in core: adds a browseable UI, missing tokens, etc.
Code
function _token_menu_link_translate(&$item) {
$map = array();
if (!is_array($item['options'])) {
$item['options'] = unserialize($item['options']);
}
if ($item['external']) {
$item['access'] = 1;
$item['href'] = $item['link_path'];
$item['title'] = $item['link_title'];
$item['localized_options'] = $item['options'];
}
else {
// Complete the path of the menu link with elements from the current path,
// if it contains dynamic placeholders (%).
$map = explode('/', $item['link_path']);
if (strpos($item['link_path'], '%') !== FALSE) {
// Invoke registered to_arg callbacks.
if (!empty($item['to_arg_functions'])) {
_menu_link_map_translate($map, $item['to_arg_functions']);
}
}
$item['href'] = implode('/', $map);
// Skip links containing untranslated arguments.
if (strpos($item['href'], '%') !== FALSE) {
$item['access'] = FALSE;
return FALSE;
}
$item['access'] = TRUE;
_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;
}