public static function getLocationSubMenu() { // how it works: every time when we call for the next sub-level, we must // obtain not sublevel itself, but a whole parent-tree of it $queryParams = self::unPackItemsQueryString(); $requiredToShow = false; // three situations: // 1) node id comes in $_REQUEST['admin_mnu_menu_id'] parameter when user walks along left menu tree $id = false; if (self::checkRequestIsMenuRequest()) { $requiredToShow = true; $id = $queryParams['ID']; } if (!$id) { // 2) node id comes in $_REQUEST['id'] or in $_REQUEST['parent_id'] when user enters self::LIST_PAGE_URL or self::EDIT_PAGE_URL page $page = $GLOBALS['APPLICATION']->GetCurPage(); if ($page == '/bitrix/admin/' . self::LIST_PAGE_URL || $page == '/bitrix/admin/' . self::EDIT_PAGE_URL) { $requiredToShow = true; /* if(intval($_REQUEST['id'])) $id = intval($_REQUEST['id']); */ if (intval($_REQUEST['find_PARENT_ID'])) { $id = intval($_REQUEST['find_PARENT_ID']); } elseif (intval($_REQUEST['parent_id'])) { $id = intval($_REQUEST['parent_id']); } } } // 3) there is no node id at all $tree = array(); if ($requiredToShow) { $parameters = array('select' => array('ID', 'LOCATION_NAME' => 'NAME.NAME', 'DEPTH_LEVEL', 'PARENT_ID', 'CHILD_CNT'), 'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID), 'order' => array('LOCATION_NAME' => 'asc')); if ($id) { $res = Location\LocationTable::getParentTree($id, $parameters, array('SHOW_CHILDREN' => true)); } else { $res = Location\LocationTable::getChildren(false, $parameters); } $index = array(); while ($item = $res->Fetch()) { $index[$item['PARENT_ID']][$item['ID']] = array('NAME' => htmlspecialcharsbx($item['LOCATION_NAME']), 'PARENT_ID' => intval($item['PARENT_ID']), 'CHILD_CNT' => intval($item['CHILD_CNT'])); } unset($res); unset($item); self::appendMenuChildren($tree, 0, $index, $queryParams); } return $tree; }