You are here

function i18n_book_navigation_translate_tree in Book translation 7.2

Same name and namespace in other branches
  1. 6.2 i18n_book_navigation.module \i18n_book_navigation_translate_tree()

Translate the menu 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: (optional) The language to translate the tree in. Defaults to the current language. Defaults to null.

Return value

array The translated menu tree

6 calls to i18n_book_navigation_translate_tree()
i18n_book_navigation in ./i18n_book_navigation.module
Get the translated menu tree for the original node.
i18n_book_navigation_block_view in ./i18n_book_navigation.module
Implements hook_block_view().
i18n_book_navigation_children in ./i18n_book_navigation.module
Load the direct child elements.
i18n_book_navigation_link_load in ./i18n_book_navigation.module
Load a link.
i18n_book_navigation_next in ./i18n_book_navigation.module
Load the next link in the book.

... See full list

File

./i18n_book_navigation.module, line 328
Defines the Book translation module.

Code

function i18n_book_navigation_translate_tree($tree, $lan = NULL) {
  if (!$lan) {
    $lan = i18n_langcode();
  }
  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 (!empty($item['below'])) {
      $item['below'] = i18n_book_navigation_translate_tree($item['below'], $lan);
    }
  }
  return $tree;
}