You are here

function _dhtml_menu_index in DHTML Menu 6.4

Same name and namespace in other branches
  1. 8 dhtml_menu.theme.inc \_dhtml_menu_index()
  2. 6.3 dhtml_menu.module \_dhtml_menu_index()
  3. 7 dhtml_menu.theme.inc \_dhtml_menu_index()

Indexes the menu tree by mlid. This is needed to identify the items without relying on titles or stacks. This function is recursive.

Parameters

$tree: A tree of menu items such as the return value of menu_tree_all_data().

$ancestors: Optional, used only by internal recursion.

$parent: Optional, used only by internal recursion.

Return value

An array associating mlid values with the internal keys of the menu tree, and all the mlids of the item's ancestors.

1 call to _dhtml_menu_index()
_dhtml_menu_subtree in ./dhtml_menu.theme.inc
Traverses the menu tree and returns the sub-tree of the item indicated by the parameter.

File

./dhtml_menu.theme.inc, line 187
dhtml_menu.theme.inc All functions related to generating the menu markup.

Code

function _dhtml_menu_index($tree, $ancestors = array(), $parent = NULL) {
  $index = array();
  if ($parent) {
    $ancestors[] = $parent;
  }
  foreach ($tree as $key => $item) {
    $index[$item['link']['mlid']] = array(
      'key' => $key,
      'parents' => $ancestors,
    );
    if (!empty($item['below'])) {
      $index += _dhtml_menu_index($item['below'], $ancestors, $item['link']['mlid']);
    }
  }
  return $index;
}