Exemple #1
0
 public static function get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL, $SECTION_ID, $arSectionsChain = false)
 {
     global $adminMenu;
     if (false === $arSectionsChain) {
         $arSectionsChain = array();
         if (isset($_REQUEST['admin_mnu_menu_id'])) {
             $menu_id = "menu_catalog_category_" . $IBLOCK_ID . "/";
             if (0 == strncmp($_REQUEST['admin_mnu_menu_id'], $menu_id, strlen($menu_id))) {
                 $rsSections = CIBlockSection::GetNavChain($IBLOCK_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"] == $IBLOCK_ID) {
             $rsSections = CIBlockSection::GetNavChain($IBLOCK_ID, $_REQUEST["find_section_section"], array('ID', 'IBLOCK_ID'));
             while ($arSection = $rsSections->Fetch()) {
                 $arSectionsChain[$arSection["ID"]] = $arSection["ID"];
             }
         }
     }
     $urlSectionAdminPage = CIBlock::GetAdminSectionListLink($IBLOCK_ID, array('catalog' => null));
     $arSections = array();
     $rsSections = CIBlockSection::GetList(array("left_margin" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "SECTION_ID" => $SECTION_ID), false, array("ID", "IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"));
     $intCount = 0;
     $arOtherSectionTmp = array();
     $limit = (int) COption::GetOptionInt("iblock", "iblock_menu_max_sections");
     while ($arSection = $rsSections->Fetch()) {
         if ($limit > 0 && $intCount >= $limit) {
             if (empty($arOtherSectionTmp)) {
                 $arOtherSectionTmp = array("text" => Loc::getMessage("CAT_MENU_ALL_OTH"), "url" => $urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"], "more_url" => array(CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null))), "title" => Loc::getMessage("CAT_MENU_ALL_OTH_TITLE"), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "items" => array());
                 CCatalogAdmin::get_other_elements_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $arSection, $arOtherSectionTmp["more_url"]);
             } else {
                 $arOtherSectionTmp['more_url'][] = $urlSectionAdminPage . "&find_section_section=" . (int) $arSection["ID"];
                 $arOtherSectionTmp['more_url'][] = CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null));
             }
         } else {
             $arSectionTmp = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => $urlSectionAdminPage . "&find_section_section=" . $arSection["ID"], "more_url" => array(CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null))), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "dynamic" => $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1, "items" => array());
             if (isset($arSectionsChain[$arSection["ID"]])) {
                 $arSectionTmp["items"] = CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
             } elseif (method_exists($adminMenu, "IsSectionActive")) {
                 if ($adminMenu->IsSectionActive("menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"])) {
                     $arSectionTmp["items"] = CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
                 }
             }
             $arSections[] = $arSectionTmp;
         }
         $intCount++;
     }
     if (!empty($arOtherSectionTmp)) {
         $arSections[] = $arOtherSectionTmp;
     }
     return $arSections;
 }