/** * @brief parse an xml file and generate administrator's menus. */ function getMenu(&$in_xml_obj, $depth = 0, &$parent_item = null) { if (!is_array($in_xml_obj)) { $xml_obj = array($in_xml_obj); } else { $xml_obj = $in_xml_obj; } $act = Context::get('act'); $menus = array(); foreach ($xml_obj as $it) { $obj = new StdClass(); $obj->id = $it->id->body; if ($parent_item) { $obj->parent_id = $parent_item->id; } $obj->title = $it->title->body; $obj->action = array(); if (is_array($it->action)) { foreach ($it->action as $action) { $obj->action[] = $action->body; } } else { $obj->action[] = $it->action->body; } $obj->description = $it->description->body; $obj->selected = false; if (in_array($act, $obj->action)) { $obj->selected = true; if ($parent_item) { $parent_item->selected = true; } } if ($it->item && ($it->attrs->modinst != 'true' || Context::get('module_srl'))) { $obj->submenu = nucommon::getMenu($it->item, $depth + 1, $obj); if ($obj->selected && $parent_item) { $parent_item->selected = true; } if ($obj->selected) { Context::set('selected_menu', $obj); } } $menus[$obj->id] = $obj; unset($obj); } return $menus; }