public static function getNavTree($restrictToDepth = FALSE) { if (is_null(self::$navigation)) { return array(); } // loop each enabled module with any navStructures $navTree = array(); foreach (self::$navigation as $module => $navStructure) { // loop the navStructures foreach ((array) $navStructure as $parameters) { // Set a pointer in a multidemensional array limited by $restrictToDepth $navigation = array(); $navPt =& $navigation; $depth = 0; if (!empty($parameters['navBranch'])) { $navBranch = explode('/', $parameters['navBranch']); $navBranch = array_filter($navBranch); foreach ($navBranch as $depth => $branch) { if (is_int($restrictToDepth) && $depth > $restrictToDepth) { break; } $navPt =& $navPt[__($branch)]; } } // if the navStructure does not branch this deep fill to $restriceToDepth if (is_int($restrictToDepth) && $depth < $restrictToDepth) { for ($depth; $depth < $restrictToDepth; $depth++) { $navPt =& $navPt['UNSET']; } } // Mark this as a LEAF $navPt =& $navPt[]; // force the expected keys to have some default value if missing $parameters += array('currentNavItem' => NULL, 'module' => $module); if (self::atModule($parameters['navURL'])) { $parameters['currentNavItem'] = TRUE; self::$currentSubMenu = $parameters['navSubmenu']; self::$currentBaseUrl = $parameters['navURL']; } else { $parameters['currentNavItem'] = FALSE; } $parameters['navLabel'] = __($parameters['navLabel']); // Save these parameters to the pointer $navPt = $parameters; // merge the pointer with the result array $navTree = array_merge_recursive($navTree, $navigation); } } return $navTree; }