You are here

function navbar_get_rendered_subtrees in Navbar 7

Returns the rendered subtree of each top-level navbar link.

2 calls to navbar_get_rendered_subtrees()
navbar_subtrees_jsonp in ./navbar.module
Page callback: Returns the rendered subtree of each top-level navbar link.
_navbar_get_subtree_hash in ./navbar.module
Returns the hash of the per-user rendered navbar subtrees.

File

./navbar.module, line 559
Administration navbar for quick access to top level administration items.

Code

function navbar_get_rendered_subtrees() {
  $subtrees = array();
  $tree = navbar_get_menu_tree();
  foreach ($tree as $tree_item) {
    $item = $tree_item['link'];
    if (!$item['hidden'] && $item['access']) {
      if ($item['has_children']) {
        $query = db_select('menu_links');
        $query
          ->addField('menu_links', 'mlid');
        $query
          ->condition('has_children', 1);
        for ($i = 1; $i <= $item['depth']; $i++) {
          $query
            ->condition('p' . $i, $item['p' . $i]);
        }
        $parents = $query
          ->execute()
          ->fetchCol();
        $subtree = menu_build_tree($item['menu_name'], array(
          'expanded' => $parents,
          'min_depth' => $item['depth'] + 1,
        ));
        navbar_menu_navigation_links($subtree);
        $subtree = menu_tree_output($subtree);
        $subtree = drupal_render($subtree);
      }
      else {
        $subtree = '';
      }
      $id = str_replace(array(
        '/',
        '<',
        '>',
      ), array(
        '-',
        '',
        '',
      ), $item['href']);
      $subtrees[$id] = $subtree;
    }
  }
  return $subtrees;
}