You are here

function i18n_book_navigation_menu_titles in Book translation 6

Same name and namespace in other branches
  1. 6.2 i18n_book_navigation.module \i18n_book_navigation_menu_titles()
1 call to i18n_book_navigation_menu_titles()
i18n_book_navigation_token_values in ./i18n_book_navigation.module
hook_token_values()

File

./i18n_book_navigation.module, line 597

Code

function i18n_book_navigation_menu_titles($menu_link, $nid, $language) {
  $tree = menu_tree_data(i18n_book_navigation_menu_all_data($menu_link['menu_name'], $menu_link));

  // 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)) {
      $node = _i18n_book_navigation_get_translated_node($current['link']['link_path'], $language);
      $titles[] = $node ? $node->title : $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;
}