static function onBeforeElementAddHandler($arFields) { $IBLOCK_ID = Config\Option::get("citfact.replaceurl", "IBLOCK_ID", ""); $SECTION_ID = Config\Option::get("citfact.replaceurl", "SECTION_BREND_ID", "BRENDI"); $CODE_PROP = Config\Option::get("citfact.replaceurl", "PROPERTY_CODE_BRENDI", "BRENDI"); if ($IBLOCK_ID == $arFields["IBLOCK_ID"]) { $propertyBrand = \CIBlockProperty::GetByID($CODE_PROP, $arFields["IBLOCK_ID"]); if ($arResultProperty = $propertyBrand->GetNext()) { $propertyBrandValue = \CIBlockPropertyEnum::GetByID($arFields["PROPERTY_VALUES"][$arResultProperty["ID"]][0]["VALUE"]); } $rqParentSection = \CIBlockSection::GetByID($SECTION_ID); if ($arParentSection = $rqParentSection->GetNext()) { $arFilter = array('IBLOCK_ID' => $arParentSection['IBLOCK_ID'], '>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'], '<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']); // выберет потомков без учета активности $rqSectChild = \CIBlockSection::GetList(array('left_margin' => 'asc'), $arFilter); while ($arSectChild = $rqSectChild->GetNext()) { $arSections[$arSectChild["NAME"]] = $arSectChild["ID"]; } } if (array_key_exists($propertyBrandValue["VALUE"], $arSections)) { $arFields["IBLOCK_SECTION"][] = $arSections[$propertyBrandValue["VALUE"]]; } else { $arParams = array("replace_space" => "-", "replace_other" => "-"); $trans = \Cutil::translit($propertyBrandValue["VALUE"], "ru", $arParams); $bs = new \CIBlockSection(); $arFieldsNewSection = array("ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $SECTION_ID, "IBLOCK_ID" => $IBLOCK_ID, "NAME" => $propertyBrandValue["VALUE"], "CODE" => $trans); $resultAdd = $bs->Add($arFieldsNewSection); $arFields["IBLOCK_SECTION"][] = $resultAdd; } } return true; }
/** * Получает результат запроса для поиска списка разделов * * @param array $filter * @param array $orderBy * @param bool $calculateCount * @param array $selectedFields * * @return \CIBlockResult */ public function rawFindBy(array $filter = array(), array $orderBy = array('sort' => 'asc'), $calculateCount = false, array $selectedFields = array('*', 'UF_*')) { if (!isset($filter['IBLOCK_ID']) && $this->iBlockId) { $filter['IBLOCK_ID'] = $this->iBlockId; } return $this->iBSGateway->GetList($orderBy, $filter, $calculateCount, $selectedFields); }
function __wd_get_root_section($IBLOCK_ID, $object, $object_id) { $result = CIBlockWebdavSocnet::GetSectionID($IBLOCK_ID, $object, $object_id); if (intval($result) > 0) { return $result; } else { __wd_check_uf_use_bp_property($arParams["IBLOCK_ID"]); $arFields = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N"); if ($object == "user") { $dbUser = CUser::GetByID($object_id); $arUser = $dbUser->Fetch(); $arFields["NAME"] = trim($arUser['LAST_NAME'] . " " . $arUser['FIRST_NAME']); $arFields["NAME"] = trim(!empty($arFields["NAME"]) ? $arFields["NAME"] : $arUser['LOGIN']); $arFields['CREATED_BY'] = $arUser['ID']; $arFields['MODIFIED_BY'] = $arUser['ID']; if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") { $arTasks = CWebDavIblock::GetTasks(); $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $object_id, 'TASK_ID' => $arTasks['X'])); } } else { /* $res = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]); if (!$res) { $arParams["ERROR_MESSAGE"] = GetMessage("SONET_GROUP_NOT_EXISTS"); return 0; } */ $arFields["SOCNET_GROUP_ID"] = $object_id; //$arGroup = CSocNetGroup::GetByID($object_id); $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $object_id; $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $object_id), false, false, array("ID", "SITE_ID", "NAME")); if ($arGroup = $dbGroup->Fetch()) { $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"]; } if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") { $arTasks = CWebDavIblock::GetTasks(); $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W'])); } } if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) { \Bitrix\Disk\Driver::getInstance()->addGroupStorage($arFields["SOCNET_GROUP_ID"]); } $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"]; $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $IBLOCK_ID . "_SECTION", $arFields); $bs = new CIBlockSection(); $sectionID = $bs->Add($arFields); if (!$sectionID) { $arParams["ERROR_MESSAGE"] = $bs->LAST_ERROR; return 0; } WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list")); return true; /* if ($ob->workflow == 'bizproc') { __wd_create_default_bp_user_and_groups($arBizProcParameters); } */ } }
public function testAdd() { $this->_injectDutyCollector(); $ibType = \CIBlockType::GetList()->Fetch(); $ib = new \CIBlock(); $ibId = $ib->Add(array('IBLOCK_TYPE_ID' => $ibType['ID'], 'NAME' => 'New Iblock', 'SITE_ID' => 's1')); $this->assertNotEmpty($ibId, $this->errorMessage('not create iblock id', array(':lastError' => $ib->LAST_ERROR))); $prop = new \CIBlockProperty(); $propId = $prop->Add(array('IBLOCK_ID' => $ibId, 'CODE' => 'propCode', 'NAME' => 'Property NAME')); $this->assertNotEmpty($propId, $this->errorMessage('not create property iblock id', array(':lastError' => $ib->LAST_ERROR))); $sec = new \CIBlockSection(); $secId = $sec->Add(array('IBLOCK_ID' => $ibId, 'NAME' => 'Iblock Section')); $this->assertNotEmpty($secId, $this->errorMessage('not create section iblock id', array(':lastError' => $ib->LAST_ERROR))); // ¬ итоге должны получитс¤ // данные по добавлению »Ѕ $this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockHandler::className())); // данные по добавлению свойства $this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockPropertyHandler::className())); // данные по добавлению секции $this->assertNotEmpty($this->_getCollectorFixes(AddProcess::className(), IblockSectionHandler::className())); $refFixes = $this->_getCollectorFixes('reference'); // фиксаци¤ изменений Module::getInstance()->commitDutyChanges(); // добавлены записи журнала обновлений (в базу) /** @var $logRecords AppliedChangesLogModel[] */ $logRecords = AppliedChangesLogModel::find(array('order' => array('id' => 'desc'), 'limit' => 10)); $this->assertTrue(count($logRecords) > 3); $iterationsCount = 0; foreach ($logRecords as $logRecord) { if ($logRecord->processName == Module::SPECIAL_PROCESS_FIX_REFERENCE) { continue; } if ($logRecord->processName != AddProcess::className()) { $this->throwError($this->errorMessage('last log records need been update process'), $logRecord->processName); } if (++$iterationsCount > 3) { break; } $data = $logRecord->updateData; switch ($logRecord->subjectName) { case IblockHandler::className(): (!$data['iblock'] || $data['iblock']['ID'] != $ibId) && $this->throwError($this->errorMessage('iblock not registered after update', array(':actual' => $data['iblock']['ID'], ':need' => $ibId))); break; case IblockPropertyHandler::className(): $data['ID'] != $propId && $this->throwError($this->errorMessage('property iblock not registered after update', array(':original' => $propId, ':actual' => $data['ID']))); break; case IblockSectionHandler::className(): $data['ID'] != $secId && $this->throwError($this->errorMessage('section iblock not registered after update', array(':original' => $secId, ':actual' => $data['ID']))); break; } } // добавлены три вида ссылок в фиксаци¤х $this->assertEquals(3, count($refFixes), $this->errorMessage('links expected count', array(':count' => 3))); $this->_iblockId = $ibId; $this->_propertyId = $propId; $this->_sectionId = $secId; }
static function existsSectionByExternalId($external_id) { $result = false; $bs = new CIBlockSection(); $ob_section = $bs->GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => self::$IBLOCK_ID, "EXTERNAL_ID" => $external_id), false, array("ID")); if ($ar_section = $ob_section->GetNext()) { $result = $ar_section["ID"]; } return $result; }
function executeUp() { CModule::IncludeModule('iblock'); $obj_ib_section = new CIBlockSection(); $r = $obj_ib_section->Add(array('NAME' => 'new section here', 'CODE' => 'new_section_here', 'ACTIVE' => 'N', 'IBLOCK_ID' => self::IBLOCK_ID)); if (!$r) { throw new \Exception('Err adding section:' . $obj_ib_section->LAST_ERROR); } return true; }
static function existsSectionByCode($code) { $result = false; $bs = new CIBlockSection(); $ob_section = $bs->GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => self::$IBLOCK_ID, "CODE" => $code), false, array("ID", "CODE")); if ($ar_section = $ob_section->GetNext()) { $result = $ar_section["ID"]; } return $result; }
/** * @param array $params */ protected function IblockSectionCreate(array $params) { $bs = new \CIBlockSection(); $res = $bs->Add($params); if (!$res) { throw new \Exception($bs->LAST_ERROR); } else { return $res; } }
private static function EnsureProductSection($externalID, $catalogID, $arFields) { $section = new CIBlockSection(); $rsSections = $section->GetList(array(), array('XML_ID' => $externalID, 'IBLOCK_ID' => $catalogID), false, array('ID')); $arSection = $rsSections->Fetch(); if (is_array($arSection)) { return intval($arSection['ID']); } $sectionID = $section->Add(array('IBLOCK_ID' => $catalogID, 'ACTIVE' => 'Y', 'NAME' => $arFields['NAME'], 'IBLOCK_SECTION_ID' => 0, 'CHECK_PERMISSIONS' => 'N', 'XML_ID' => $externalID)); return $sectionID; }
/** * Verify the existence of duplicate sections. * * @param array $fields Section fields. * @param array $settings Internationalization settings of info block. * @return bool */ protected static function checkDoubleSection(array $fields, $settings) { global $APPLICATION; $sectionModel = new \CIBlockSection(); $rsSection = $sectionModel->GetList([], ['IBLOCK_ID' => $fields['IBLOCK_ID'], 'UF_' . $settings['PROP_CODE_PUBLIC_ID'] => $fields['UF_' . $settings['PROP_CODE_PUBLIC_ID']], 'UF_' . $settings['PROP_CODE_LANG'] => $fields['UF_' . $settings['PROP_CODE_LANG']], '!ID' => $fields['ID']], false, ['ID']); if ($section = $rsSection->Fetch()) { $APPLICATION->ThrowException(Loc::getMessage('NOTAMEDIA_I18N_IBLOCK_HANDLER_ELEMENT_ALREADY_EXIST')); return true; } return false; }
public function addSection($iblockId, $fields = array()) { $default = array("ACTIVE" => "Y", "IBLOCK_SECTION_ID" => false, "NAME" => 'section', "CODE" => '', "SORT" => 100, "PICTURE" => false, "DESCRIPTION" => '', "DESCRIPTION_TYPE" => 'text'); $fields = array_merge($default, $fields); $fields["IBLOCK_ID"] = $iblockId; $ib = new \CIBlockSection(); $id = $ib->Add($fields); if ($id) { return $id; } $this->throwException(__METHOD__, $ib->LAST_ERROR); }
function addSectionReview($NAME, $CODE, $IBLOCK_ID) { CModule::IncludeModule('iblock'); $bs = new CIBlockSection(); $arFields = array("ACTIVE" => 'Y', "IBLOCK_ID" => $IBLOCK_ID, "NAME" => $NAME, "CODE" => $CODE); $ID = $bs->Add($arFields); $res = $ID > 0; if (!$res) { echo $bs->LAST_ERROR; } return $ID; }
public function GetEditFormHTML($userField, $htmlControl) { $request = Application::getInstance()->getContext()->getRequest(); $iblockId = intval(str_replace(['IBLOCK_', '_SECTION'], '', $userField['ENTITY_ID'])); if (empty($userField['VALUE']) && $request->get('I18N_RELATED_ID')) { $sectionModel = new \CIBlockSection(); $rsRelatedSection = $sectionModel->GetList([], ['IBLOCK_ID' => $iblockId, 'ID' => $request->get('I18N_RELATED_ID')], false, ['ID', $userField['FIELD_NAME']]); if ($relatedSection = $rsRelatedSection->Fetch()) { $userField['VALUE'] = $relatedSection[$userField['FIELD_NAME']]; } } return $userField['VALUE'] . '<input type="hidden" name="' . $htmlControl['NAME'] . '" value="' . $userField['VALUE'] . '">'; }
/** * Возвращает путь до картинки */ function getImage($arProperty) { $current = self::getCurrent($arProperty); $image = null; $p = strtoupper($arProperty['USER_TYPE_SETTINGS']['PROPERTY_NAME']); $link = strtoupper($arProperty['USER_TYPE_SETTINGS']['PROPERTY_LINK']); if ($link && !empty($current[$link])) { //узнаем инфоблок привязанного свойства if ($link === 'IBLOCK_SECTION_ID') { $res = \CIBlockSection::GetById($current[$link]); if ($ob = $res->Fetch()) { $image = isset($ob[$p]) ? $ob[$p] : null; } } else { $res = \CIBlockElement::GetById($current[$link]); if ($ob = $res->Fetch()) { if (strpos($p, 'PROPERTY_') === 0) { $pres = \CIBlockElement::GetProperty($ob['IBLOCK_ID'], $ob['ID'], [], ['CODE' => substr($p, 9)]); if ($pob = $pres->Fetch()) { $image = $pob['VALUE']; } } else { $image = isset($ob[$p]) ? $ob[$p] : null; } } } } elseif (!empty($current[$p])) { $image = $current[$p]; } if ($image && is_numeric($image)) { $image = \CFile::GetPath($image); } return $image; }
/** * [addSectionIblock description] * @param object $section * @param int $lvl * @return array */ protected function addSection($section, $lvl, $idParent, $sort){ if (!CModule::IncludeModule("iblock")): return array("result" => false); endif; $bs = new CIBlockSection; $IBLOCK_ID = 17; $NAME = $section->Наименование; $id1c = $section->Ид; $ID = $this->findSection($NAME); $translitParams = $this->translitParams(); $arFields = Array( "ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $idParent, "IBLOCK_ID" => $this->getIblockId(), "NAME" => $NAME, "CODE" => CUtil::translit($NAME, "ru", $translitParams), "DEPTH_LEVEL" => $lvl, "SORT" => $sort, "UF_1C_ID" => $id1c, "PICTURE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/upload/1c_catalog/".$section->Картинка) ); if($ID <= 0): $ID = $bs->Add($arFields); $res = ($ID>0); else: $res = $bs->Update($ID, $arFields); endif; if(!$res): return array("result" => false); else: return array("result" => true, "id" => $ID); endif; }
public function addVariants(&$field, $params) { if (!$params["LINK_IBLOCK_ID"]) { return; } $cacheDir = KFilter::$config['CACHE_DIR'] . self::$cacheSubdir; $obCache = new CPHPCache(); if ($obCache->InitCache(KFilter::$config['CACHE_TIME'], md5($params["LINK_IBLOCK_ID"] . __METHOD__), $cacheDir)) { $field['VARIANTS'] = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { CModule::IncludeModule('iblock'); global $CACHE_MANAGER; $CACHE_MANAGER->StartTagCache($cacheDir); $CACHE_MANAGER->RegisterTag("iblock_id_" . $params["LINK_IBLOCK_ID"]); $CACHE_MANAGER->EndTagCache(); $rsSect = CIBlockSection::GetList(array('sort' => 'asc', 'name' => 'asc'), array('IBLOCK_ID' => $params["LINK_IBLOCK_ID"], 'ACTIVE' => 'Y'), false, array('ID', 'NAME')); while ($arSect = $rsSect->GetNext()) { $field['VARIANTS'][] = array('ID' => $arSect['ID'], 'NAME' => $arSect['NAME']); } $obCache->EndDataCache($field['VARIANTS']); } foreach ($field['VARIANTS'] as &$section) { if ($_REQUEST[$field['NAME']] == $section['ID']) { $section['SELECTED'] = 'Y'; $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $params["LINK_IBLOCK_ID"], "SECTION_ID" => $section['ID']), false, false, array("ID", "IBLOCK_ID")); $arr = array(); while ($el = $res->GetNext()) { $arr[] = $el['ID']; } $this->filter['PROPERTY_' . $field['PROPERTY']] = $arr; break; } } }
public static function getSefviceMediaspect($service_id, $section_id = false) { $result = false; if (!$section_id) { $res = CIBlockElement::GetByID($service_id); if ($element = $res->GetNext()) { $section_id = $element["IBLOCK_SECTION_ID"]; } } if ($section_id) { $section = DrclinicsHelper::getMediaspects($section_id); $section = end($section); if ($section) { $result = $section; } else { $nav = CIBlockSection::GetNavChain(false, $section_id, array("ID", "CODE", "SECTION_PAGE_URL", "DEPTH_LEVEL")); while (($arSectionPath = $nav->GetNext()) && $arSectionPath["DEPTH_LEVEL"] != 2) { } if ($arSectionPath) { $result = $arSectionPath; } } } return $result; }
public function GetSections($ib, $subsection = false) { CModule::IncludeModule("iblock"); if (!is_array($ib) || empty($ib)) { return array(); } $arFilter = array("IBLOCK_ID" => $ib); if (!$subsection) { $arFilter["DEPTH_LEVEL"] = 1; } $dbSection = CIBlockSection::GetList(array("NAME" => "ASC"), $arFilter); $sections = array(); while ($arSection = $dbSection->Fetch()) { $sections[$arSection["DEPTH_LEVEL"]][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => "{$arSection["NAME"]} [{$arSection["ID"]}]", "LEVEL" => $arSection["DEPTH_LEVEL"], "PARENT" => $arSection["IBLOCK_SECTION_ID"], "PARENT_1" => $arSection["ID"]); } unset($dbSection); ksort($sections); foreach ($sections as $depth => &$depthSections) { if ($depth == 1) { continue; } foreach ($depthSections as $id => &$current) { $current["NAME"] = implode(" / ", array($sections[$depth - 1][$current["PARENT"]]["NAME"], $current["NAME"])); $current["PARENT_1"] = $sections[$depth - 1][$current["PARENT"]]["PARENT_1"]; } } return $sections; }
function _getIBlockMode($ib, $object = false, $object_id = false) { if ($object === false) { $arIBlock = CIBlock::GetArrayByID($ib); if ($arIBlock["WORKFLOW"] == "Y") { return "WF"; } elseif ($arIBlock["BIZPROC"] == "Y") { return "BP"; } else { return ""; } } else { $arFilter = array("IBLOCK_ID" => $ib, "SOCNET_GROUP_ID" => false, "CHECK_PERMISSIONS" => "N", "SECTION_ID" => 0); if ($object == "user") { $arFilter["CREATED_BY"] = $object_id; } else { $arFilter["SOCNET_GROUP_ID"] = $object_id; } $arLibrary = array(); $db_res = CIBlockSection::GetList(array(), $arFilter, false, array("ID", "UF_USE_BP")); if ($db_res && ($arLibrary = $db_res->GetNext())) { return $arLibrary["UF_USE_BP"] == "N" ? "" : "BP"; } else { return ""; } } }
public function testAdd() { /** @var $dbList \CDBResult */ $dbList = \CIBlock::GetList(); $ibCountBefore = $dbList->SelectedRowsCount(); $beforeIds = array(); while ($arIblock = $dbList->Fetch()) { $beforeIds[] = $arIblock['ID']; } $this->_applyFixtures(self::FIXTURE_TYPE_ADD); $dbList = \CIBlock::GetList(); $ibCountAfter = $dbList->SelectedRowsCount(); $afterIds = array(); while ($arIblock = $dbList->Fetch()) { $afterIds[] = $arIblock['ID']; } $aAddedId = array_diff($afterIds, $beforeIds); $this->_processIblockId = array_shift($aAddedId); $this->assertNotEmpty($ibCountAfter, $this->errorMessage('record IB must be present')); $this->assertNotEquals($ibCountAfter, $ibCountBefore, $this->errorMessage('not also recording information block')); $this->assertNotEmpty($this->_processIblockId, $this->errorMessage('unavailable identifier of the new information block')); $rsProps = \CIBlockProperty::GetList(null, array('IBLOCK_ID' => $this->_processIblockId)); $this->assertNotEmpty($rsProps->AffectedRowsCount(), $this->errorMessage('added properties not available information block', array(':iblockId' => $this->_processIblockId))); $rsSections = \CIBlockSection::getList(null, array('IBLOCK_ID' => $this->_processIblockId), false, array('ID')); $this->assertNotEmpty($rsSections->AffectedRowsCount(), $this->errorMessage('added sections not available information block')); $registerRef = (bool) DbVersionReferencesTable::getList(array('filter' => array('=DB_VERSION' => Module::getInstance()->getDbVersion(), '=GROUP' => ReferenceController::GROUP_IBLOCK, '=ITEM_ID' => $this->_processIblockId)))->fetch(); $this->assertTrue($registerRef, $this->errorMessage('In added apply not created iblock reference ' . $this->_processIblockId)); }
/** * Геттер * @param $var * @return int */ public function __get($var) { if (strpos($var, 'printable_') === 0) { $varName = substr($var, strlen('printable_')); $param = $this->getParam($varName); if (!is_array($param) || !isset($param['PROPERTY_TYPE'])) { return $param; } switch ($param['PROPERTY_TYPE']) { case 'G': $printable = \CIBlockSection::GetList(array(), array('ID' => $param['VALUE']), false, array("NAME"))->GetNext(); return $printable['NAME']; default: $printable = \CIBlockFormatProperties::GetDisplayValue(array('NAME' => ''), $param, ""); return $printable['DISPLAY_VALUE']; } } else { switch ($var) { case 'id': case 'ID': return $this->id; case 'IBLOCK_ID': case 'iblockId': return $this->iblockId; default: return $this->getParam($var); } } }
function _ShowGroupPropertyField($name, $property_fields, $values) { if (!is_array($values)) { $values = array(); } foreach ($values as $key => $value) { if (is_array($value) && array_key_exists("VALUE", $value)) { $values[$key] = $value["VALUE"]; } } $res = ""; $bWas = false; $sections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $property_fields["LINK_IBLOCK_ID"]), false, array("ID", "DEPTH_LEVEL", "NAME")); while ($ar = $sections->GetNext()) { $res .= '<option value="' . $ar["ID"] . '"'; if (in_array($ar["ID"], $values)) { $bWas = true; $res .= ' selected'; } $res .= '>' . str_repeat(" . ", $ar["DEPTH_LEVEL"] - 1) . $ar["NAME"] . '</option>'; } echo '<select name="' . $name . '[]" size="' . $property_fields["MULTIPLE_CNT"] . '" ' . ($property_fields["MULTIPLE"] == "Y" ? "multiple" : "") . '>'; echo '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("IBLOCK_AT_NOT_SET") . '</option>'; echo $res; echo '</select>'; }
function getSectionId($code) { $uf_arresult = CIBlockSection::GetList(array(), array('CODE' => $code), false, array('ID')); if ($uf_value = $uf_arresult->GetNext()) { $id = $uf_value['ID']; } return $id; }
function get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL, $SECTION_ID) { $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")); while ($arSection = $rsSections->Fetch()) { $arSections[] = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => "cat_section_admin.php?lang=" . LANGUAGE_ID . "&type=" . $IBLOCK_TYPE_ID . "&IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"], "more_url" => array("cat_section_admin.php?IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"], "cat_section_edit.php?IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"]), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "items" => $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1 ? CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"]) : array()); } return $arSections; }
public static function getSectionNameById($SECTION_ID) { $ret = NULL; $res = CIBlockSection::GetByID($SECTION_ID); if ($ar_res = $res->GetNext()) { $ret = $ar_res["NAME"]; } return $ret; }
function get_sections_by_iblock_id($id) { $arSections = array(); $result = CIBlockSection::GetList(array('CREATED' => 'DESC'), array('ACTIVE' => 'Y', 'IBLOCK_ID' => $id)); while ($section = $result->GetNext()) { $arSections[] = $section; } return $arSections; }
function getBreadcrumbs() { $sections = array(); $getResult = CIBlockSection::GetNavChain((int) $GLOBALS['AQW_STORE']['IBLOCK_ID'], $this->getSectionID()); while ($section = $getResult->GetNext()) { $sections[] = $section; } return $sections; }
protected static function getCategoriesPath($categoryId) { $result = array($categoryId); $nav = \CIBlockSection::GetNavChain(false, $categoryId); while ($arSectionPath = $nav->GetNext()) { if (!in_array($arSectionPath['ID'], $result)) { $result[] = $arSectionPath['ID']; } } return $result; }
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; }
function getSections($id){ $arFilter = Array('IBLOCK_ID'=>$IBLOCK_ID, 'GLOBAL_ACTIVE'=>'Y', "SECTION_ID" => $id); $db_list = CIBlockSection::GetList(Array("SORT" => "ASC"), $arFilter, true); while($ar_result = $db_list->GetNext()) { if (($ar_result["RIGHT_MARGIN"] - $ar_result["LEFT_MARGIN"]) > 1): $ar_result["SECTIONS"] = getSections($ar_result["ID"]); endif; $arSections[] = $ar_result; } return $arSections; }