function i18n_book_navigation_menu_titles in Book translation 6.2
Same name and namespace in other branches
- 6 i18n_book_navigation.module \i18n_book_navigation_menu_titles()
Gets the menu titles for the book path. Port of _menu_titles of the token module. Will translate the tree before fetching the titles.
Parameters
array $menu_link: The current menu link data
int $nid: The node nid
string $language: The language of the current node
Return value
array The titles from the book path
See also
_menu_title()
1 call to i18n_book_navigation_menu_titles()
- i18n_book_navigation_token_values in ./
i18n_book_navigation.module - Implementation of hook_token_values()
File
- ./
i18n_book_navigation.module, line 733 - Defines the i18n book navigation module. Contains all necessary data and hooks
Code
function i18n_book_navigation_menu_titles($menu_link, $nid, $language) {
$tree = menu_tree_all_data($menu_link['menu_name'], $menu_link);
// Translate the tree
$tree = i18n_book_navigation_translate_tree($tree, $language);
// Clean it up
$tree = i18n_book_navigation_cleanup($tree);
// Get mlid of all nodes in path - top-most parent to leaf node.
$parents = array();
for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
if ($menu_link["p{$i}"]) {
$parents[] = $menu_link["p{$i}"];
}
}
// Build the titles in this hierarchy.
$titles = array();
$current = array_shift($tree);
while ($current) {
if (in_array($current['link']['mlid'], $parents)) {
$titles[] = $current['link']['title'];
if ($current['link']['href'] == "node/" . $nid) {
break;
}
// Go deeper in tree hierarchy.
$tree = $current['below'];
}
// Go to next sibling at same level in tree hierarchy.
$current = $tree ? array_shift($tree) : NULL;
}
return $titles;
}