</a></li> <?php } ?> <?php } echo "</ul>"; ?> <?php // если $ID не задан или это не число, тогда // $ID будет =0, выбираем корневые разделы $ID = IntVal(0); // выберем папки из информационного блока $BID и раздела $ID $items = GetIBlockSectionList(IntVal(5), $ID, array("sort" => "asc"), 50); $i = 0; $cat_array = array(); while ($arItem = $items->GetNext()) { $i++; $cat_array[$i][name] = $arItem[NAME]; $cat_array[$i][id] = $arItem[ID]; } foreach ($cat_array as $category) { $kol++; $arElementSelect = array("ID", "NAME", "DATE_ACTIVE_FROM", "PREVIEW_PICTURE", "PROPERTY_NOVELTY", "SECTION_ID", "PROPERTY_HIT", "PROPERTY_COLLECTION", "IBLOCK_ID"); $arElementFilter = array("IBLOCK_ID" => IntVal(5), "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "SECTION_ID" => IntVal($category[id])); $resElement = CIBlockElement::GetList(array("SORT" => "ASC", "PROPERTY_PRIORITY" => "ASC"), $arElementFilter, false, array("nPageSize" => 50), $arElementSelect); ?> <div class="navHeader" id="navHeader<?php echo $kol;
<select name="sel" style="width: 145px;" onchange="MM_jumpMenu('parent',this,0)"> <option value="" selected>список изделий</option>; <?php CModule::IncludeModule("iblock"); $IBLOCK_TYPE = "catalogue"; // тип инфо-блока $IBLOCK_ID = 5; // ID инфо-блока $SECTION_ID = $arResult["IBLOCK_SECTION_ID"]; $arFilterSect["ACTIVE"] = "Y"; // $arFilterSect["DEPTH_LEVEL"] = 1; $arFilterSect["INCLUDE_SUBSECTIONS"] = "Y"; // иначе собираем разделы $rsSections = GetIBlockSectionList($IBLOCK_ID, false, array("SORT" => "ASC", "ID" => "DESC"), false, $arFilterSect); if ($rsElements = GetIBlockElementListEx($IBLOCK_TYPE, $IBLOCK_ID, false, array("NAME" => "ASC"), false, array("ACTIVE" => "Y", "IBLOCK_ID" => $IBLOCK_ID, "SECTION_ID" => $SECTION_ID), array())) { while ($arElement = $rsElements->GetNext()) { $arrAddLinks[] = $arElement["DETAIL_PAGE_URL"]; if ($arElement["ID"] == $arResult["ID"]) { echo "<option selected value='/catalogue/" . $SECTION_ID . "/tov_" . $arElement["ID"] . ".html' style='font-size: 11px;'> " . $arElement["NAME"] . "</option>"; } else { echo "<option value='/catalogue/" . $SECTION_ID . "/tov_" . $arElement["ID"] . ".html' style='font-size: 11px;'> " . $arElement["NAME"] . "</option>"; } } } ?> </select> <?php if (count($arResult["MORE_PHOTO"]) > 0) {
function GetDepartmentIdForADUser($department, $managerDN, $username, &$cache = FALSE, $iblockId = FALSE, $names = FALSE) { global $USER_FIELD_MANAGER; // check for loops in manager structure, if loop is found - quit // should be done before cache lookup if ($names && isset($names[$username])) { return false; } // if department id for this user is already stored in cache if ($cache) { $departmentCached = $cache[$username]; // if user was not set as head earlier, then do not get his id from cache if ($departmentCached) { return $departmentCached; } } // if it is a first call in recursive chain if (!$iblockId) { // check module inclusions if (!IsModuleInstalled('intranet') || !CModule::IncludeModule('iblock')) { return false; } // get structure's iblock id $iblockId = COption::GetOptionInt("intranet", "iblock_structure", false, false); if (!$iblockId) { return false; } $names = array(); } // save current username as already visited $names[$username] = true; $arManagerDep = null; $mgrDepartment = null; // if there's a manager - query it if ($managerDN) { preg_match('/^(CN=.*?)(\\,){1}([^\\,])*(=){1}/i', $managerDN, $matches); //Extract "CN=User Name" from full name $user = isset($matches[1]) ? str_replace('\\', '', $matches[1]) : ""; $userArr = $this->GetUserArray($user); if (count($userArr) > 0) { // contents of userArr are already in local encoding, no need for conversion here $mgrDepartment = $userArr[0][$this->arFields['USER_DEPARTMENT_ATTR']]; if ($mgrDepartment && trim($mgrDepartment) != '') { // if manager's department name is set - then get it's id $mgrManagerDN = $userArr[0][$this->arFields['USER_MANAGER_ATTR']]; $mgrUserName = $userArr[0][$this->arFields['USER_ID_ATTR']]; $arManagerDep = $this->GetDepartmentIdForADUser($mgrDepartment, $mgrManagerDN, $mgrUserName, $cache, $iblockId, $names); // fill in cache if ($cache && $arManagerDep) { $cache[$mgrUserName] = $arManagerDep; } } } } // prepare result and create department (if needed) $arResult = array('IS_HEAD' => true); // by default, thinking of user as a head of the department if ($arManagerDep) { // if got manager's data correctly if ($department && trim($department) != '' && $mgrDepartment != $department) { // if our department is set && differs from manager's, set manager's as parent $parentSectionId = $arManagerDep['ID']; } else { // - if user has no department, but somehow have manager - then he is assumed to be in manager's department // - if user has same department name as manager - then he is not head // here we can return manager's department id immediately $arResult = $arManagerDep; $arResult['IS_HEAD'] = false; return $arResult; } } else { // if there's no manager's data if ($department && trim($department) != '') { $parentSectionId = $this->arFields['ROOT_DEPARTMENT']; } else { // if have no manager's department and no own department: // - use default as our department and root as parent section if default is set // - or just root if default has empty value // - or return false, if setting of default department is turned off if ($this->arFields['STRUCT_HAVE_DEFAULT'] && $this->arFields['STRUCT_HAVE_DEFAULT'] == "Y") { // if can use default department $department = $this->arFields['DEFAULT_DEPARTMENT_NAME']; if ($department && trim($department) != '') { // if department is not empty $parentSectionId = $this->arFields['ROOT_DEPARTMENT']; } else { // if it is empty - return parent return array('ID' => $this->arFields['ROOT_DEPARTMENT']); } } else { // if have no department in AD and no default - then do not set a department return false; } } } // 3. if there's no department set for this user, this means there was no default department name (which substituted in *) - then there's no need to set department id for this user at all if (!$department || trim($department) == '') { return false; } // 4. detect this user's department ID, using parent id and department name string, which we certainly have now (these 2 parameters are required to get an ID) // see if this department already exists $bs = new CIBlockSection(); $dbExistingSections = GetIBlockSectionList($iblockId, $parentSectionId >= 0 ? $parentSectionId : false, $arOrder = array("left_margin" => "asc"), $cnt = 0, $arFilter = array('NAME' => $department)); $departmentId = false; if ($arItem = $dbExistingSections->GetNext()) { $departmentId = $arItem['ID']; } if (!$departmentId) { //create new department $arNewSectFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $iblockId, "NAME" => $department); if ($parentSectionId >= 0) { $arNewSectFields["IBLOCK_SECTION_ID"] = $parentSectionId; } // and get it's Id $departmentId = $bs->Add($arNewSectFields); } $arElement = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $iblockId . '_SECTION', $departmentId); // if the head of the department is already set, do not change it if (!empty($arElement['UF_HEAD']['VALUE'])) { $arResult['IS_HEAD'] = false; } $arResult['ID'] = $departmentId; return $arResult; }
global ${$FILTER_NAME}; $arrFilter = ${$FILTER_NAME}; $CACHE_FILTER = $CACHE_FILTER == "Y" ? "Y" : "N"; if ($CACHE_FILTER == "N" && count($arrFilter) > 0) { $CACHE_TIME = 0; } /************************************************************************* Work with cache *************************************************************************/ $CACHE_ID = __FILE__ . md5(serialize($arParams) . serialize($arrFilter) . $USER->GetGroups()); $obCache = new CPHPCache(); if ($obCache->StartDataCache($CACHE_TIME, $CACHE_ID, "/")) { /************************************ Groups ************************************/ $rsSections = GetIBlockSectionList($IBLOCK_ID, $PARENT_SECTION_ID, array($SECTION_SORT_FIELD => $SECTION_SORT_ORDER, "ID" => "ASC"), $SECTION_COUNT, array("ACTIVE" => "Y")); $arrProp = ""; while ($arSection = $rsSections->GetNext()) { /************************************ Elements ************************************/ // list of the element fields that will be used in selection $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL"); // adding values to the filter $arrFilter["ACTIVE"] = "Y"; $arrFilter["IBLOCK_ID"] = $IBLOCK_ID; $arrFilter["SECTION_ID"] = $arSection["ID"]; if ($rsElements = GetIBlockElementListEx($IBLOCK_TYPE, false, false, array($ELEMENT_SORT_FIELD => $ELEMENT_SORT_ORDER, "ID" => "ASC"), array("nTopCount" => $ELEMENT_COUNT), $arrFilter, $arSelect)) { $rsElements->NavStart($ELEMENT_COUNT); $count = intval($rsElements->SelectedRowsCount()); if ($count > 0) {
<?php $arFilter = array('ACTIVE' => 'Y', 'IBLOCK_ID' => $arParams['IBLOCK_ID'], 'GLOBAL_ACTIVE' => 'Y'); $arSelect = array('IBLOCK_ID', 'ID', 'NAME', 'DEPTH_LEVEL', 'IBLOCK_SECTION_ID'); $arOrder = array('DEPTH_LEVEL' => 'ASC', 'SORT' => 'ASC'); $rsSections = CIBlockSection::GetList($arOrder, $arFilter, false, $arSelect); $sectionLinc = array(); $arResult['ROOT'] = array(); $sectionLinc[0] =& $arResult['ROOT']; while ($arSection = $rsSections->GetNext()) { $sectionLinc[intval($arSection['IBLOCK_SECTION_ID'])]['CHILD'][$arSection['ID']] = $arSection; $sectionLinc[$arSection['ID']] =& $sectionLinc[intval($arSection['IBLOCK_SECTION_ID'])]['CHILD'][$arSection['ID']]; } //или так получаем все подразделы текущего раздела $sections = GetIBlockSectionList($arParams['IBLOCK_ID_SECTIONS'], false, array(), false, array("LEFT_MARGIN" => $category['LEFT_MARGIN'], "RIGHT_MARGIN" => $category['RIGHT_MARGIN'])); $ids = []; while ($resSub = $sections->fetch()) { $ids[] = $resSub['ID']; }
} $ID = intval($ID); $IBLOCK_ID = intval($IBLOCK_ID); $aMenuLinksNew = array(); if (CModule::IncludeModule("iblock")) { $CACHE_ID = __FILE__ . $IBLOCK_ID; $obMenuCache = new CPHPCache(); // если массив закэширован то if ($obMenuCache->InitCache($CACHE_TIME, $CACHE_ID, "/")) { // берем данные из кэша $arVars = $obMenuCache->GetVars(); $arSections = $arVars["arSections"]; $arElementLinks = $arVars["arElementLinks"]; } else { // иначе собираем разделы $rsSections = GetIBlockSectionList($IBLOCK_ID, 0, array("SORT" => "ASC", "ID" => "ASC"), false, array("ACTIVE" => "Y")); $arSections = array(); while ($arSection = $rsSections->Fetch()) { $arSections[] = $arSection; $arElementLinks[$arSection["ID"]] = array(); } } if ($ID > 0) { $arSelect = array("ID", "IBLOCK_ID", "DETAIL_PAGE_URL", "IBLOCK_SECTION_ID"); $arFilter = array("ID" => $ID, "ACTIVE" => "Y", "IBLOCK_ID" => $IBLOCK_ID); if ($rsElements = GetIBlockElementListEx($IBLOCK_TYPE, false, false, array(), false, $arFilter, $arSelect)) { while ($arElement = $rsElements->GetNext()) { $arElementLinks[$arElement["IBLOCK_SECTION_ID"]][] = $arElement["DETAIL_PAGE_URL"]; } } }
$arResult["PATH"] = array(); while ($section_id) { $arResult["PATH"][] = $section_id; $res = CIBlockSection::GetByID($section_id); $ar_fields = $res->GetNext(); $section_id = $ar_fields["IBLOCK_SECTION_ID"]; } if ($arParams["COLORS_IBLOCK_ID"]) { $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => intval($arParams["COLORS_IBLOCK_ID"]), "ACTIVE" => "Y"), false, false, array("NAME", "PROPERTY_CODE", "PROPERTY_ICON")); while ($ar_fields = $res->GetNext()) { $icon = false; if ($ar_fields["PROPERTY_ICON_VALUE"]) { $arFileTmp = CFile::ResizeImageGet($ar_fields["PROPERTY_ICON_VALUE"], array("width" => 25, "height" => 25), BX_RESIZE_IMAGE_PROPORTIONAL, true); $icon = $arFileTmp["src"]; } $arResult["COLORS"][] = array("NAME" => $ar_fields["NAME"], "CODE" => $ar_fields["PROPERTY_CODE_VALUE"], "ICON" => $icon); } } $curdir = $APPLICATION->GetCurDir(); $po = explode('/', $curdir); $do = CIBlockSection::GetList(array(), array("IBLOCK_ID" => 16, "CODE" => $po[2]), false, array("IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"), false); $kld = $do->GetNext(); while ($kld['IBLOCK_SECTION_ID'] != 0) { $do = CIBlockSection::GetList(array(), array("IBLOCK_ID" => 16, "ID" => $kld['IBLOCK_SECTION_ID']), false, array("IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"), false); $kld = $do->GetNext(); } $sections = GetIBlockSectionList(16, false, array(), false, array("LEFT_MARGIN" => $kld['LEFT_MARGIN'], "RIGHT_MARGIN" => $kld['RIGHT_MARGIN'])); while ($mm = $sections->GetNext()) { $cjo[] = $mm['ID']; } $arResult['SHOW_SECTIONS'] = $cjo;
public function GetSectionFromIB($id) { $mas = array(); $otv = array(); $items = GetIBlockSectionList($id); while ($arItem = $items->GetNext()) { $mas[] = $arItem['ID']; } if (sizeof($this->SECTION_ID) > 0) { foreach ($this->SECTION_ID as $cat) { if (in_array($cat, $mas)) { $otv[] = $cat; } } } return $otv; }