function _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL, $SECTION_ID, $arSectionsChain = false) { //Determine opened sections if ($arSectionsChain === false) { $arSectionsChain = array(); if (isset($_REQUEST['admin_mnu_menu_id'])) { $menu_id = "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/"; if (strncmp($_REQUEST['admin_mnu_menu_id'], $menu_id, strlen($menu_id)) == 0) { $rsSections = CIBlockSection::GetNavChain($arIBlock["ID"], substr($_REQUEST['admin_mnu_menu_id'], strlen($menu_id)), array('ID', 'IBLOCK_ID')); while ($arSection = $rsSections->Fetch()) { $arSectionsChain[$arSection["ID"]] = $arSection["ID"]; } } } if (isset($_REQUEST["find_section_section"]) && (int) $_REQUEST["find_section_section"] > 0 && isset($_REQUEST["IBLOCK_ID"]) && $_REQUEST["IBLOCK_ID"] == $arIBlock["ID"]) { $rsSections = CIBlockSection::GetNavChain($arIBlock["ID"], $_REQUEST["find_section_section"], array('ID', 'IBLOCK_ID')); while ($arSection = $rsSections->Fetch()) { $arSectionsChain[$arSection["ID"]] = $arSection["ID"]; } } } $urlSectionAdminPage = CIBlock::GetAdminSectionListLink($arIBlock["ID"], array("menu" => null)); $arSections = array(); if (CIBlock::GetAdminListMode($arIBlock["ID"]) == 'S') { $arSections[] = _get_elements_menu($arType, $arIBlock, $SECTION_ID); } $rsSections = CIBlockSection::GetList(array("left_margin" => "ASC"), array("IBLOCK_ID" => $arIBlock["ID"], "SECTION_ID" => $SECTION_ID), false, array("ID", "IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN")); $sectionCount = 0; $limit = COption::GetOptionInt("iblock", "iblock_menu_max_sections"); while ($arSection = $rsSections->Fetch()) { if ($limit > 0 && $sectionCount >= $limit) { $arSections[] = array("text" => GetMessage("IBLOCK_MENU_ALL_OTH"), "url" => htmlspecialcharsbx($urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"]), "more_url" => array($urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"], $urlSectionAdminPage, "iblock_section_edit.php?" . $arIBlock["URL_PART"], "iblock_element_edit.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"], "iblock_history_list.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"]), "title" => GetMessage("IBLOCK_MENU_ALL_OTH_TITLE"), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"], "module_id" => "iblock", "items" => array()); _get_other_elements_menu($arType, $arIBlock, $arSection, $arSections[0]["more_url"]); break; } $arSectionTmp = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => htmlspecialcharsbx($urlSectionAdminPage . "&find_section_section=" . $arSection["ID"]), "more_url" => array($urlSectionAdminPage . "&find_section_section=" . $arSection["ID"], "iblock_section_edit.php?" . $arIBlock["URL_PART"] . "&ID=" . $arSection["ID"], "iblock_section_edit.php?" . $arIBlock["URL_PART"] . "&ID=0&find_section_section=" . $arSection["ID"], "iblock_element_edit.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"] . "&find_section_section=" . $arSection["ID"], "iblock_history_list.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"] . "&find_section_section=" . $arSection["ID"]), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "dynamic" => CIBlock::GetAdminListMode($arIBlock["ID"]) == 'S' || $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1, "items_id" => "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"], "module_id" => "iblock", "items" => array()); if (array_key_exists($arSection["ID"], $arSectionsChain)) { $arSectionTmp["items"] = _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain); } elseif (method_exists($GLOBALS["adminMenu"], "IsSectionActive")) { if ($GLOBALS["adminMenu"]->IsSectionActive("menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"])) { $arSectionTmp["items"] = _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain); } } $arSections[] = $arSectionTmp; $sectionCount++; } while ($arSection = $rsSections->Fetch()) { $urlElementAdminPage = CIBlock::GetAdminElementListLink($arIBlock["ID"], array("menu" => null)); $arSections[0]["more_url"][] = $urlElementAdminPage . "&find_section_section=" . (int) $arSection["ID"]; } return $arSections; }
public static function GetAdminSectionListLink($IBLOCK_ID, $arParams = array(), $strAdd = "") { if ((defined("CATALOG_PRODUCT") || array_key_exists('catalog', $arParams)) && !array_key_exists("menu", $arParams)) { $url = "cat_section_admin.php"; } elseif (CIBlock::GetAdminListMode($IBLOCK_ID) == 'C') { $url = "iblock_list_admin.php"; } else { $url = "iblock_section_admin.php"; } $url .= "?IBLOCK_ID=" . intval($IBLOCK_ID); $url .= "&type=" . urlencode(CIBlock::GetArrayByID($IBLOCK_ID, "IBLOCK_TYPE_ID")); $url .= "&lang=" . urlencode(LANGUAGE_ID); foreach ($arParams as $name => $value) { if (isset($value)) { $url .= "&" . urlencode($name) . "=" . urlencode($value); } } return $url . $strAdd; }
function OnBuildGlobalMenu(&$aGlobalMenu, &$aModuleMenu) { if (defined("BX_CATALOG_UNINSTALLED")) return; if (!Loader::includeModule("iblock")) return; $aMenu = array( "text" => Loc::getMessage("CAT_MENU_ROOT"), "title" => "", "items_id" => "menu_catalog_list", "items" => array(), ); $arCatalogs = array(); $arCatalogSku = array(); $rsCatalog = CCatalog::GetList( array(), array(), false, false, array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID') ); while ($ar = $rsCatalog->Fetch()) { $ar["PRODUCT_IBLOCK_ID"] = (int)$ar["PRODUCT_IBLOCK_ID"]; $ar["IBLOCK_ID"] = (int)$ar["IBLOCK_ID"]; if ($ar["PRODUCT_IBLOCK_ID"] > 0) { $arCatalogs[$ar["PRODUCT_IBLOCK_ID"]] = 1; $arCatalogSku[$ar["PRODUCT_IBLOCK_ID"]] = $ar["IBLOCK_ID"]; } else { $arCatalogs[$ar["IBLOCK_ID"]] = 1; } } if (empty($arCatalogs)) { return; } $rsIBlocks = CIBlock::GetList( array("SORT" => "ASC", "NAME" => "ASC"), array('ID' => array_keys($arCatalogs), "MIN_PERMISSION" => "S") ); while ($arIBlock = $rsIBlocks->Fetch()) { if (CIBlock::GetAdminListMode($arIBlock["ID"]) == 'C') $url = "cat_product_list.php"; else $url = "cat_product_admin.php"; $arItems = array( array( "text" => Loc::getMessage("CAT_MENU_PRODUCT_LIST"), "url" => $url."?lang=".LANGUAGE_ID."&IBLOCK_ID=".$arIBlock["ID"]."&type=".urlencode($arIBlock["IBLOCK_TYPE_ID"]).'&find_section_section=-1', "more_url" => array( "cat_product_admin.php?IBLOCK_ID=".$arIBlock["ID"], "cat_product_list.php?IBLOCK_ID=".$arIBlock["ID"].'&find_section_section=-1', "cat_product_edit.php?IBLOCK_ID=".$arIBlock["ID"], ), "title" => "", "page_icon" => "iblock_page_icon_elements", "items_id" => "menu_catalog_goods_".$arIBlock["ID"], "module_id" => "catalog", ), array( "text" => htmlspecialcharsex(CIBlock::GetArrayByID($arIBlock["ID"], "SECTIONS_NAME")), "url" => "cat_section_admin.php?lang=".LANGUAGE_ID."&type=".$arIBlock["IBLOCK_TYPE_ID"]."&IBLOCK_ID=".$arIBlock["ID"]."&find_section_section=0", "more_url" => array( "cat_section_admin.php?IBLOCK_ID=".$arIBlock["ID"]."&find_section_section=0", "cat_section_edit.php?IBLOCK_ID=".$arIBlock["ID"]."&find_section_section=0", ), "title" => "", "page_icon" => "iblock_page_icon_sections", "items_id" => "menu_catalog_category_".$arIBlock["ID"], "module_id" => "catalog", "items" => CCatalogAdmin::get_sections_menu($arIBlock["IBLOCK_TYPE_ID"], $arIBlock["ID"], 1, 0), ), ); if(CIBlockRights::UserHasRightTo($arIBlock["ID"], $arIBlock["ID"], "iblock_edit")) { $arItems[] = array( "text" => Loc::getMessage("CAT_MENU_PRODUCT_PROPERTIES"), "url" => "iblock_property_admin.php?lang=".LANGUAGE_ID."&IBLOCK_ID=".$arIBlock["ID"]."&admin=N", "more_url" => array( "iblock_property_admin.php?IBLOCK_ID=".$arIBlock["ID"]."&admin=N", "iblock_edit_property.php?IBLOCK_ID=".$arIBlock["ID"]."&admin=N", ), "title" => "", "page_icon" => "iblock_page_icon_settings", "items_id" => "menu_catalog_attributes_".$arIBlock["ID"], "module_id" => "catalog", ); } if (isset($arCatalogSku[$arIBlock["ID"]])) { $intOffersIBlockID = $arCatalogSku[$arIBlock["ID"]]; if (CIBlockRights::UserHasRightTo($intOffersIBlockID, $intOffersIBlockID, "iblock_edit")) { $arItems[] = array( "text" => Loc::getMessage("CAT_MENU_SKU_PROPERTIES"), "url" => "iblock_property_admin.php?lang=".LANGUAGE_ID."&IBLOCK_ID=".$intOffersIBlockID."&admin=N", "more_url" => array( "iblock_property_admin.php?IBLOCK_ID=".$intOffersIBlockID."&admin=N", "iblock_edit_property.php?IBLOCK_ID=".$intOffersIBlockID."&admin=N", ), "title" => "", "page_icon" => "iblock_page_icon_settings", "items_id" => "menu_catalog_attributes_".$intOffersIBlockID, "module_id" => "catalog", ); } } if(CIBlockRights::UserHasRightTo($arIBlock["ID"], $arIBlock["ID"], "iblock_edit")) { $arItems[] = array( "text" => Loc::getMessage("CAT_MENU_CATALOG_SETTINGS"), "url" => "cat_catalog_edit.php?lang=".LANGUAGE_ID."&IBLOCK_ID=".$arIBlock["ID"], "more_url" => array( "cat_catalog_edit.php?IBLOCK_ID=".$arIBlock["ID"], ), "title" => "", "page_icon" => "iblock_page_icon_settings", "items_id" => "menu_catalog_edit_".$arIBlock["ID"], "module_id" => "catalog", ); } $aMenu["items"][] = array( "text" => htmlspecialcharsEx($arIBlock["NAME"]), "title" => "", "page_icon" => "iblock_page_icon_sections", "items_id" => "menu_catalog_".$arIBlock["ID"], "module_id" => "catalog", "items" => $arItems, ); } if (!empty($aMenu["items"])) { if (count($aMenu["items"]) == 1) $aMenu = $aMenu["items"][0]; $aMenu["parent_menu"] = "global_menu_store"; $aMenu["section"] = "catalog_list"; $aMenu["sort"] = 200; $aMenu["icon"] = "iblock_menu_icon_sections"; $aMenu["page_icon"] = "iblock_page_icon_types"; $aModuleMenu[] = $aMenu; } }