function token_book_link_load in Token 7
Same name and namespace in other branches
- 6 token.module \token_book_link_load()
Get a translated book menu link by its mlid, without access checking.
This function is a copy of book_link_load() but with its own cache and a simpler query to load the link. This also skips normal menu link access checking by using _token_menu_link_translate().
Parameters
$mlid: The mlid of the book menu item.
Return value
A book menu link translated for rendering.
See also
1 call to token_book_link_load()
- book_tokens in ./
token.tokens.inc - Implements hook_tokens() on behalf of book.module.
1 string reference to 'token_book_link_load'
- token_clear_cache in ./
token.module - Clear token caches and static variables.
File
- ./
token.module, line 1076 - Enhances the token API in core: adds a browseable UI, missing tokens, etc.
Code
function token_book_link_load($mlid) {
$cache =& drupal_static(__FUNCTION__, array());
if (!is_numeric($mlid)) {
return FALSE;
}
if (!isset($cache[$mlid])) {
$item = db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = :mlid", array(
':mlid' => $mlid,
))
->fetchAssoc();
if (!empty($item)) {
_token_menu_link_translate($item);
}
$cache[$mlid] = $item;
}
return $cache[$mlid];
}