function i18n_book_navigation_translate_tree in Book translation 6.2
Same name and namespace in other branches
- 7.2 i18n_book_navigation.module \i18n_book_navigation_translate_tree()
 
Translates the tree. Walks down the tree and translates every item. Will respect the translation settings from the i18n module.
Parameters
array $tree: The menu tree
string $lan = NULL: (optional) The language to translate the tree in. Defaults to the current language
Return value
array The translated menu tree
6 calls to i18n_book_navigation_translate_tree()
- i18n_book_navigation in ./
i18n_book_navigation.module  - Gets the translated menu tree for the original node.
 - i18n_book_navigation_children in ./
i18n_book_navigation.module  - Loads the direct child elements. Port from book_children(). Will perform a similar task, but will also translate the links.
 - i18n_book_navigation_link_load in ./
i18n_book_navigation.module  - Loads a link. Port from book_link_load(). Will translate the link after loading it.
 - i18n_book_navigation_menu_titles in ./
i18n_book_navigation.module  - Gets the menu titles for the book path. Port of _menu_titles of the token module. Will translate the tree before fetching the titles.
 - i18n_book_navigation_next in ./
i18n_book_navigation.module  - Loads the next link in the book. Port from book_next(). Will translate the link after loading it.
 
File
- ./
i18n_book_navigation.module, line 271  - Defines the i18n book navigation module. Contains all necessary data and hooks
 
Code
function i18n_book_navigation_translate_tree($tree, $lan = NULL) {
  foreach ($tree as $key => &$item) {
    if ($node = i18n_book_navigation_get_translated_node($item['link']['link_path'], $lan)) {
      $item['link']['title'] = $item['link']['link_title'] = $node->title;
      $item['link']['href'] = $item['link']['link_path'] = 'node/' . $node->nid;
    }
    else {
      $item = array();
    }
    if ($item['below']) {
      $item['below'] = i18n_book_navigation_translate_tree($item['below'], $lan);
    }
  }
  return $tree;
}