_menu_build_local_tasks

Versions
4.6 – 5
_menu_build_local_tasks($pid)

Find all the items in the current local task tree.

Since this is only for display, we only need title, path, and children for each item.

At the close of this function, $_menu['local tasks'] is populated with the menu items in the local task tree.

Return value

TRUE if the local task tree is forked. It does not need to be displayed otherwise.

▾ 2 functions call _menu_build_local_tasks()

menu_get_local_tasks in includes/menu.inc
Return the local task tree.
_menu_build_local_tasks in includes/menu.inc
Find all the items in the current local task tree.

Code

includes/menu.inc, line 1016

<?php
function _menu_build_local_tasks($pid) {
  global $_menu;

  $forked = FALSE;

  if (isset($_menu['items'][$pid])) {
    $parent = $_menu['items'][$pid];

    $children = array();
    if (array_key_exists('children', $parent)) {
      foreach ($parent['children'] as $mid) {
        if (($_menu['items'][$mid]['type'] & MENU_IS_LOCAL_TASK) && _menu_item_is_accessible($mid)) {
          $children[] = $mid;
          // Beware short-circuiting || operator!
          $forked = _menu_build_local_tasks($mid) || $forked;
        }
      }
    }
    usort($children, '_menu_sort');
    $forked = $forked || count($children) > 1;

    $_menu['local tasks'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
    foreach ($children as $mid) {
      $_menu['local tasks'][$mid]['pid'] = $pid;
    }
  }

  return $forked;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.