| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: menu_block.follow.inc,v 1.4 2010/03/22 14:11:27 johnalbin Exp $ 3 4 /** 5 * @file 6 * Provides active menu item pruning. 7 */ 8 9 /** 10 * Prune a tree so that it begins at the active menu item. 11 * 12 * @param $tree 13 * array The menu tree to prune. 14 * @param $level 15 * string The level which the tree will be pruned to: 'active' or 'child'. 16 * @return 17 * void 18 */ 19 function _menu_tree_prune_active_tree(&$tree, $level) { 20 do { 21 $found_active_trail = FALSE; 22 // Examine each element at this level for the active trail. 23 foreach (array_keys($tree) AS $key) { 24 if ($tree[$key]['link']['in_active_trail']) { 25 $found_active_trail = TRUE; 26 // If the active trail item has children, examine them. 27 if ($tree[$key]['below']) { 28 // If we are pruning to the active menu item's level, check if this 29 // is the active menu item by checking its children. 30 if ($level == 'active') { 31 foreach (array_keys($tree[$key]['below']) AS $child_key) { 32 if ($tree[$key]['below'][$child_key]['link']['in_active_trail']) { 33 // Get the title for the pruned tree. 34 menu_block_set_title($tree[$key]['link']); 35 $tree = $tree[$key]['below']; 36 // Continue in the pruned tree. 37 break 2; 38 } 39 } 40 // If we've found the active item, we're done. 41 break 2; 42 } 43 // Set the title for the pruned tree. 44 menu_block_set_title($tree[$key]['link']); 45 // If we are pruning to the children of the active menu item, just 46 // prune the tree to the children of the item in the active trail. 47 $tree = $tree[$key]['below']; 48 // Continue in the pruned tree. 49 break; 50 } 51 // If the active menu item has no children, we're done. 52 else { 53 if ($level == 'child') { 54 $tree = array(); 55 } 56 break 2; 57 } 58 } 59 } 60 } while ($found_active_trail); 61 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |