예제 #1
1
파일: class.php 프로젝트: Satariall/izurit
 public static function getPropertyFieldSections($linkIblockId)
 {
     $linkIblockId = (int) $linkIblockId;
     if ($linkIblockId <= 0) {
         return false;
     }
     $ttl = 10000;
     $cache_id = 'catalog_store_sections';
     $cache_dir = '/bx/catalog_store_sections';
     $obCache = new CPHPCache();
     if ($obCache->InitCache($ttl, $cache_id, $cache_dir)) {
         $res = $obCache->GetVars();
     } else {
         $res = array();
     }
     if (!isset($res[$linkIblockId])) {
         $res[$linkIblockId] = array();
         $sectionsIterator = Iblock\SectionTable::getList(array('select' => array('*'), 'filter' => array('=IBLOCK_ID' => $linkIblockId), 'order' => array('LEFT_MARGIN' => 'ASC')));
         while ($section = $sectionsIterator->fetch()) {
             $res[$linkIblockId][] = $section;
         }
         unset($section, $sectionsIterator);
         if ($obCache->StartDataCache()) {
             $obCache->EndDataCache($res);
         }
     }
     return $res[$linkIblockId];
 }
예제 #2
1
 /**
  * Loads values from database.
  * Returns true on success.
  *
  * @return boolean
  */
 public function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         //From down to up
         $select = array_values($this->fieldMap);
         $this->dbPath = array();
         $id = $this->id;
         while ($id > 0) {
             $sectionList = \Bitrix\Iblock\SectionTable::getList(array("select" => $select, "filter" => array("=ID" => $id)));
             $section = $sectionList->fetch();
             if ($section) {
                 $this->dbPath[] = $section;
             } else {
                 break;
             }
             $id = $section["IBLOCK_SECTION_ID"];
         }
         //Reversed from up to down
         //and laid by fields
         $this->fields = array();
         for ($i = count($this->dbPath) - 1; $i >= 0; $i--) {
             foreach ($this->dbPath[$i] as $fieldName => $fieldValue) {
                 $this->fields[$fieldName][] = $fieldValue;
             }
         }
         $this->loadProperty();
     }
     return is_array($this->fields);
 }
 /**
  * Save filter, requirement fields: IBLOCK_ID, FILTER
  *
  * @param array $fields
  * @return \Bitrix\Main\Entity\AddResult
  * @throws \InvalidArgumentException
  */
 public function addFilter(array $fields)
 {
     $filter = $fields['FILTER'];
     if (!is_array($filter) || sizeof($filter) <= 0) {
         throw new \InvalidArgumentException('Filter can not be empty');
     }
     $filter = $this->normalizeFilter($filter);
     $iblockId = (int) $fields['IBLOCK_ID'];
     $sectionId = (int) $fields['SECTION_ID'];
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockDataResult = $queryBuilder->setSelect(array('ID'))->setFilter(array('ID' => $iblockId))->exec()->fetch();
     if ($this->isEmptyResult($iblockDataResult)) {
         throw new \InvalidArgumentException('Invalid IBLOCK_ID');
     }
     if ($sectionId > 0) {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionDataResult = $queryBuilder->setSelect(array('ID'))->setFilter(array('IBLOCK_ID' => $iblockDataResult['ID'], 'ID' => $sectionId))->exec()->fetch();
         if ($this->isEmptyResult($sectionDataResult)) {
             throw new \InvalidArgumentException('Invalid SECTION_ID');
         }
     }
     $queryBuilder = new Entity\Query(Model\SubscribeTable::getEntity());
     $subscribe = $queryBuilder->setSelect(array('ID'))->setFilter(array('FILTER' => $filter, 'IBLOCK_ID' => $iblockDataResult['ID'], 'SECTION_ID' => isset($sectionDataResult) ? $sectionDataResult['ID'] : ''))->exec()->fetch();
     if (!empty($subscribe)) {
         $addResult = new \Bitrix\Main\Entity\AddResult();
         $addResult->setId($subscribe['ID']);
         return $addResult;
     }
     $subscribeResult = Model\SubscribeTable::add(array('FILTER' => $filter, 'IBLOCK_ID' => $iblockDataResult['ID'], 'SECTION_ID' => isset($sectionDataResult) ? $sectionDataResult['ID'] : ''));
     return $subscribeResult;
 }
예제 #4
0
 function clearValues()
 {
     $connection = \Bitrix\Main\Application::getConnection();
     $sectionList = \Bitrix\Iblock\SectionTable::getList(array("select" => array("LEFT_MARGIN", "RIGHT_MARGIN"), "filter" => array("=ID" => $this->section_id)));
     $section = $sectionList->fetch();
     if ($section) {
         $connection->query("\n\t\t\t\tDELETE FROM b_iblock_element_iprop\n\t\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\tAND ELEMENT_ID in (\n\t\t\t\t\tSELECT BSE.IBLOCK_ELEMENT_ID\n\t\t\t\t\tFROM b_iblock_section_element BSE\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID AND BSE.ADDITIONAL_PROPERTY_ID IS NULL\n\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\t\tAND BS.LEFT_MARGIN <= " . $section["RIGHT_MARGIN"] . "\n\t\t\t\t\tAND BS.RIGHT_MARGIN >= " . $section["LEFT_MARGIN"] . "\n\t\t\t\t)\n\t\t\t");
         $connection->query("\n\t\t\t\tDELETE FROM b_iblock_section_iprop\n\t\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\tAND SECTION_ID in (\n\t\t\t\t\tSELECT BS.ID\n\t\t\t\t\tFROM b_iblock_section BS\n\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\t\tAND BS.LEFT_MARGIN <= " . $section["RIGHT_MARGIN"] . "\n\t\t\t\t\tAND BS.RIGHT_MARGIN >= " . $section["LEFT_MARGIN"] . "\n\t\t\t\t)\n\t\t\t");
     }
 }
예제 #5
0
 public static function getMap()
 {
     if (static::getIblockId() === null) {
         return parent::getMap();
     }
     $map = parent::getMap();
     foreach (self::getAdditionalMap() as $key => $mapItem) {
         $map[] = $mapItem;
     }
     return $map;
 }
예제 #6
0
 protected function findSection()
 {
     $lastSection = false;
     foreach ($this->urlParts as $id => $part) {
         $section = \Bitrix\Iblock\SectionTable::getList(['filter' => ['IBLOCK_ID' => \Bitrix\Main\Config\Option::get('xpage.seofilter', 'IBLOCK', 1), 'IBLOCK_SECTION_ID' => isset($section) ? $section['ID'] : NULL, 'CODE' => $part]])->fetch();
         if ($section) {
             $lastSection = $section;
             unset($this->urlParts[$id]);
         }
     }
     return $lastSection;
 }
 public function testExistsReferencesRegister()
 {
     Module::getInstance()->install();
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK)));
     $dbRsIblock = IblockTable::getList();
     $this->assertEquals($dbRsIblock->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to the information block and the information block entries must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_PROPERTY)));
     $dbRsProp = PropertyTable::getList();
     $this->assertEquals($dbRsProp->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links on the properties of information blocks and records must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_SECTION)));
     $dbRsSection = SectionTable::getList();
     $this->assertEquals($dbRsSection->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to information block sections and records must match'));
 }
예제 #8
0
	public function Import(Connection $connection)
	{
		$rs = \Bitrix\Iblock\SectionTable::getList(array(
			"select" => array(
				"ID", "XML_ID"
			),
			"filter" => array(
				"!XML_ID" => null,
				"ACTIVE" => "Y",
				"IBLOCK_ID" => $this->section->getIBlockID()
			)
		));
		while($ar = $rs->Fetch())
			$this->section->Import($connection, $ar["XML_ID"]);
	}
예제 #9
0
 private static function compileTemplate($template, $sectionId, $propertyValues)
 {
     $section = SectionTable::getList(['filter' => ['ID' => $sectionId]])->fetch();
     $search = ['#SECTION_NAME#'];
     $replace = [strtolower($section['NAME'])];
     $obPropertiesValues = PropertyEnumerationTable::getList(['order' => ['SEOFILTER_PROPERTY_TABLE.SORT' => 'ASC'], 'select' => ['ID', 'VALUE', 'VALUE_ALT' => 'VALUE_ALT_TABLE.VALUE'], 'filter' => ['ID' => array_values($propertyValues)], 'runtime' => [new \Bitrix\Main\Entity\ReferenceField('VALUE_ALT_TABLE', '\\Xpage\\Seofilter\\PropertyValueAlt', ['this.ID' => 'ref.ENUM_ID']), new \Bitrix\Main\Entity\ReferenceField('SEOFILTER_PROPERTY_TABLE', '\\Xpage\\Seofilter\\Property', ['this.PROPERTY_ID' => 'ref.PROPERTY_ID'])]]);
     $arPropertyValues = [];
     while ($arPropertyValue = $obPropertiesValues->fetch()) {
         $arPropertyValue['VALUE'] = $arPropertyValue['VALUE_ALT'] ?: strtolower($arPropertyValue['VALUE']);
         $arPropertyValues[] = $arPropertyValue;
     }
     $strPropertyValues = implode(" ", \Xpage\Helper::array_pluck($arPropertyValues, 'VALUE'));
     $search[] = "#PROPERTY_VALUES#";
     $replace[] = $strPropertyValues;
     $compiledTemplate = preg_replace('/#.+#/', '', str_replace($search, $replace, $template));
     return \Xpage\Helper::ucfirst($compiledTemplate);
 }
 public function testDelete()
 {
     $this->_applyFixtures(self::FIXTURE_TYPE_SECTION_DELETE);
     $rsSection = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEmpty($rsSection->getSelectedRowsCount(), $this->errorMessage('section should not be'));
     $this->_applyFixtures(self::FIXTURE_TYPE_PROPERTY_DELETE);
     $rsProps = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEquals($rsProps->getSelectedRowsCount(), 1, $this->errorMessage('in the information block is only one property'));
     $dbList = \CIBlock::GetList();
     $ibCountBefore = $dbList->SelectedRowsCount();
     $this->_applyFixtures(self::FIXTURE_TYPE_IBLOCK_DELETE);
     $dbList = \CIBlock::GetList();
     $ibCountAfter = $dbList->SelectedRowsCount();
     $this->assertNotEquals($ibCountBefore, $ibCountAfter, $this->errorMessage('iblock not been deleted'));
     $arIblock = IblockTable::getList(array('filter' => array('=ID' => $this->_processIblockId)))->fetch();
     $this->assertEmpty($arIblock, $this->errorMessage('iblock exists'));
 }
 public function testReinitIblockReference()
 {
     $beforeApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $collector = Collector::createByFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'add_collection.json');
     $this->assertNotEmpty($collector->getFixes());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->rollbackLastChanges();
     $afterRollback = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterRollbackApply = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $this->assertEquals($beforeApplyFix['iblocks'], $afterApplyFix['iblocks'] - 1, $this->errorMessage('iblock not created after apply fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterApplyFix['properties'] - 2, $this->errorMessage('properties not created after apply fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterApplyFix['sections'] - 1, $this->errorMessage('sections not created after apply fix'));
     $this->assertEquals($beforeApplyFix['iblocks'], $afterRollback['iblocks'], $this->errorMessage('iblock not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterRollback['properties'], $this->errorMessage('properties not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterRollback['sections'], $this->errorMessage('sections not removed after rollback fix'));
     $this->assertEquals($afterRollback['iblocks'] + 1, $afterRollbackApply['iblocks'], $this->errorMessage('iblock not created after apply rollback fix'));
     $this->assertEquals($afterRollback['properties'] + 2, $afterRollbackApply['properties'], $this->errorMessage('properties not created after apply rollback fix'));
     $this->assertEquals($afterRollback['sections'] + 1, $afterRollbackApply['sections'], $this->errorMessage('sections not created after apply rollback fix'));
 }
예제 #12
0
 /**
  * Set values for property with type G(link to section).
  */
 protected function setSectionValue()
 {
     $iblockList = $this->getListByType('G');
     $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
     $queryBuilder->setSelect(array('ID', 'NAME', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'XML_ID'))->setFilter(array('IBLOCK_ID' => $iblockList))->setOrder(array());
     $sectionResult = $queryBuilder->exec();
     while ($section = $sectionResult->fetch()) {
         foreach ($this->iblockProperty as &$field) {
             if ($field['PROPERTY_TYPE'] != 'G') {
                 continue;
             }
             if ($field['LINK_IBLOCK_ID'] == $section['IBLOCK_ID']) {
                 $field['VALUE_LIST'][] = $section;
             }
         }
     }
 }
예제 #13
0
 //*****************************************//
 $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_PAGE_URL", 'CATALOG_AVAILABLE');
 $db_res = CCatalogGroup::GetGroupsList(array("GROUP_ID" => 2));
 $arPTypes = array();
 while ($ar_res = $db_res->Fetch()) {
     if (!in_array($ar_res["CATALOG_GROUP_ID"], $arPTypes)) {
         $arPTypes[] = $ar_res["CATALOG_GROUP_ID"];
         $arSelect[] = "CATALOG_GROUP_" . $ar_res["CATALOG_GROUP_ID"];
     }
 }
 $strTmpCat = "";
 $strTmpOff = "";
 if (is_array($YANDEX_EXPORT)) {
     $arSiteServers = array();
     $intMaxSectionID = 0;
     $sectionIterator = Iblock\SectionTable::getList(array('select' => array(new Main\Entity\ExpressionField('MAX_ID', 'MAX(%s)', array('ID')))));
     if ($section = $sectionIterator->fetch()) {
         $intMaxSectionID = (int) $section['MAX_ID'];
     }
     unset($section, $sectionIterator);
     $intMaxSectionID += 100000000;
     $maxSections = array();
     foreach ($YANDEX_EXPORT as $ykey => $yvalue) {
         $boolNeedRootSection = false;
         $yvalue = (int) $yvalue;
         if ($yvalue <= 0) {
             continue;
         }
         $filter = array("IBLOCK_ID" => $yvalue, "ACTIVE" => "Y", "IBLOCK_ACTIVE" => "Y", "GLOBAL_ACTIVE" => "Y");
         $db_acc = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), $filter, false, array('ID', 'IBLOCK_SECTION_ID', 'NAME'));
         $arAvailGroups = array();
예제 #14
0
CJSCore::init('jquery');
// подключим языковой файл
Loc::loadMessages(__FILE__);
$aTabs = [["DIV" => "edit1", "TAB" => "Основное", "ICON" => "main_user_edit", "TITLE" => "Настройки"]];
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$ID = intval($ID);
// идентификатор редактируемой записи
$message = null;
// сообщение об ошибке
$bVarsFromForm = false;
// флаг "Данные получены с формы", обозначающий, что выводимые данные получены с формы, а не из БД.
$iblockID = COption::GetOptionInt(ADMIN_MODULE_NAME, 'IBLOCK_ID');
if ($iblockID) {
    $arSections = [];
    $arTransaction = LotinfoTypeToIBlockTable::$TRANSACTIONS;
    $sectionOb = \Bitrix\Iblock\SectionTable::getList(['filter' => ['IBLOCK_ID' => $iblockID, 'ACTIVE' => 'Y'], 'select' => ['NAME', 'CODE', 'ID']]);
    while ($section = $sectionOb->fetch()) {
        $arSections[$section['ID']] = $section['NAME'];
    }
    // ******************************************************************** //
    //                ОБРАБОТКА ИЗМЕНЕНИЙ ФОРМЫ                             //
    // ******************************************************************** //
    if ($arSections) {
        if ($REQUEST_METHOD == "POST" && ($save != "" || $apply != "") && check_bitrix_sessid()) {
            // обработка данных формы
            $arFields = ["TRANSACTION" => $TRANSACTION, "LOTINFO_TYPE" => $LOTINFO_TYPE, "SECTION_ID" => $SECTION_ID];
            // сохранение данных
            if ($ID > 0) {
                $res = LotinfoTypeToIBlockTable::update($ID, $arFields);
            } else {
                $res = LotinfoTypeToIBlockTable::add($arFields);
 /**
  * @after testDelete
  */
 public function testRollbackDelete()
 {
     /** @var $list AppliedChangesLogModel[] */
     $list = AppliedChangesLogModel::find(array('limit' => 3, 'order' => array('id' => 'DESC')));
     $this->assertCount($list, 3, $this->errorMessage('should be in an amount of writable', array(':count' => 3)));
     foreach ($list as $lItem) {
         $this->assertTrue($lItem->processName == DeleteProcess::className(), $this->errorMessage('logging process should be - Disposal'));
     }
     $rsIblock = \CIBlock::getList();
     $countIbBefore = $rsIblock->SelectedRowsCount();
     $iblocksBefore = array();
     while ($arIb = $rsIblock->Fetch()) {
         $iblocksBefore[] = $arIb['ID'];
     }
     Module::getInstance()->rollbackByLogs($list ?: array());
     $rsIblock = \CIBlock::getList();
     $countIbAfter = $rsIblock->SelectedRowsCount();
     $iblocksAfter = array();
     while ($arIb = $rsIblock->Fetch()) {
         $iblocksAfter[] = $arIb['ID'];
     }
     $rebuildIblockId = array_diff($iblocksAfter, $iblocksBefore);
     $rebuildIblockId = array_shift($rebuildIblockId);
     $this->assertEquals($countIbAfter, $countIbBefore + 1, $this->errorMessage('information block data to be restored'));
     $this->assertEquals($rebuildIblockId, $this->_iblockId, $this->errorMessage('iblock restored identifier changed'));
     $rsProp = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId)));
     $this->assertTrue($rsProp->getSelectedRowsCount() > 0, $this->errorMessage('must present properties of reduced information iblock'), array(':iblockId' => $rebuildIblockId));
     $rsSections = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId)));
     $this->assertTrue($rsSections->getSelectedRowsCount() > 0, $this->errorMessage('must present sections of reduced information iblock', array(':iblockId' => $rebuildIblockId)));
 }
예제 #16
0
 protected static function getCategoriesList($ids)
 {
     if (!\Bitrix\Main\Loader::includeModule('iblock')) {
         return array();
     }
     $result = array();
     $res = \Bitrix\Iblock\SectionTable::getList(array('filter' => array('ID' => $ids), 'select' => array('ID', 'NAME')));
     while ($section = $res->fetch()) {
         $result[$section['ID']] = $section['NAME'];
     }
     return $result;
 }
예제 #17
0
    }
}
if (array_key_exists('ITEMS', $arResult)) {
    $filterLexer = new \Citfact\FilterSubscribe\FilterLexer();
    foreach ($arResult['ITEMS'] as $key => $filter) {
        $arResult['ITEMS'][$key]['FILTER_LINK'] = $filterLexer->getFilterUniqId(unserialize($filter['FILTER']));
        $filterLexer->addFilter($filter['FILTER'], true);
    }
    $filterLexer->parse();
    $arResult['FILTER'] = $filterLexer->getFilter();
    $arResult['FILTER_PROPERTY'] = $filterLexer->getProperty();
    $arResult['FILTER_PRICE_TYPE'] = $filterLexer->getPriceType();
    $arResult['FILTER_VALUE'] = $filterLexer->getValue();
}
if (array_key_exists('SECTION_ID', $arResult)) {
    $queryBuilder = new Entity\Query(IBlock\SectionTable::getEntity());
    $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $arResult['SECTION_ID']));
    $sectionResult = $queryBuilder->exec();
    while ($section = $sectionResult->fetch()) {
        $arResult['SECTIONS'][$section['ID']] = $section;
    }
}
if (array_key_exists('IBLOCKS_ID', $arResult)) {
    $queryBuilder = new Entity\Query(IBlock\IblockTable::getEntity());
    $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $arResult['IBLOCKS_ID']));
    $iblockResult = $queryBuilder->exec();
    while ($iblock = $iblockResult->fetch()) {
        $arResult['IBLOCKS'][$iblock['ID']] = $iblock;
    }
}
if ($request->isPost() && $arResult['COMPONENT_ID'] == $request->getPost('COMPONENT_ID')) {
예제 #18
0
 protected function getSectionIdByCode($sectionCode = "")
 {
     $sectionId = 0;
     $sectionCode = (string) $sectionCode;
     if ($sectionCode === '') {
         return $sectionId;
     }
     $sectionFilter = array('@IBLOCK_ID' => $this->arParams['IBLOCK_ID'], '=IBLOCK.ACTIVE' => 'Y', '=CODE' => $sectionCode);
     $section = Iblock\SectionTable::getList(array('select' => array('ID'), 'filter' => $sectionFilter))->fetch();
     if (!empty($section)) {
         $sectionId = (int) $section['ID'];
     }
     unset($section, $sectionFilter);
     return $sectionId;
 }
예제 #19
0
 protected function load()
 {
     $sectionList = \Bitrix\Iblock\SectionTable::getList(array("select" => array("NAME"), "filter" => array("=ID" => $this->key)));
     $section = $sectionList->fetch();
     if ($section) {
         return $section["NAME"];
     } else {
         return "";
     }
 }
예제 #20
0
 private function getSectionID($sectionID, $sectionName, $iblockID)
 {
     $obSection = \Bitrix\Iblock\SectionTable::getList(['filter' => ['IBLOCK_SECTION_ID' => $sectionID, 'IBLOCK_ID' => $iblockID, 'NAME' => $sectionName], 'select' => ['ID', 'NAME']]);
     if ($resSec = $obSection->Fetch()) {
         return $resSec['ID'];
     } else {
         return $this->addNewSection($sectionID, $sectionName, $iblockID);
     }
 }
 protected function getExistsSubjectIds()
 {
     $rs = SectionTable::getList(array('select' => array('ID')));
     $res = array();
     while ($arSection = $rs->fetch()) {
         $res[] = $arSection['ID'];
     }
     return $res;
 }
예제 #22
0
 private function deactivateSections($arIDs = array(), $IBLOCK_ID = 0)
 {
     if (!$IBLOCK_ID)
     {
         $IBLOCK_ID = $this->CATALOG_ID;
     }
     $arIDs = array_values($arIDs);
     $params = array(
         'select' => array('ID'),
         'filter' => array(
             '=IBLOCK_ID' => $IBLOCK_ID,
             '!=ID'       => $arIDs,
             '=ACTIVE'    => 'Y'
         )
     );
     $result = SectionTable::getList($params);
     while ($arSect = $result->fetch())
     {
         SectionTable::update($arSect['ID'], array(
             'ACTIVE'      => 'N',
             'TIMESTAMP_X' => new DateTime
         ));
         Report::deactivate('section');
     }
 }
예제 #23
0
 /**
  * Set values for fields type iblock_section.
  */
 protected function setSectionValue()
 {
     $iblockList = $this->getListByType('iblock_section');
     $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
     $queryBuilder->setSelect(array('ID', 'NAME', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'XML_ID'))->setFilter(array('IBLOCK_ID' => $iblockList))->setOrder(array());
     $sectionResult = $queryBuilder->exec();
     while ($section = $sectionResult->fetch()) {
         foreach ($this->highLoadBlockFields as &$field) {
             if ($field['USER_TYPE_ID'] != 'iblock_section') {
                 continue;
             }
             if ($field['SETTINGS']['IBLOCK_ID'] == $section['IBLOCK_ID']) {
                 $field['VALUE_LIST'][] = $section;
             }
         }
     }
 }
예제 #24
0
}
Loc::loadMessages(__FILE__);
try {
    ComponentParameters::includeModules(['iblock']);
    $iblockTypes = CIBlockParameters::GetIBlockTypes([0 => '']);
    $iblocks = [0 => ''];
    $sections = [0 => ''];
    $elementProperties = [];
    if (isset($arCurrentValues['IBLOCK_TYPE']) && strlen($arCurrentValues['IBLOCK_TYPE'])) {
        $rsIblocks = Iblock\IblockTable::getList(['order' => ['SORT' => 'ASC', 'NAME' => 'ASC'], 'filter' => ['IBLOCK_TYPE_ID' => $arCurrentValues['IBLOCK_TYPE'], 'ACTIVE' => 'Y'], 'select' => ['ID', 'NAME']]);
        while ($iblock = $rsIblocks->fetch()) {
            $iblocks[$iblock['ID']] = $iblock['NAME'];
        }
    }
    if (isset($arCurrentValues['IBLOCK_ID']) && strlen($arCurrentValues['IBLOCK_ID'])) {
        $rsSections = Iblock\SectionTable::getList(['order' => ['SORT' => 'ASC', 'NAME' => 'ASC'], 'filter' => ['IBLOCK_ID' => $arCurrentValues['IBLOCK_ID'], 'ACTIVE' => 'Y'], 'select' => ['ID', 'NAME']]);
        while ($arSection = $rsSections->fetch()) {
            $sections[$arSection['ID']] = $arSection['NAME'];
        }
        $rsProperties = CIBlockProperty::GetList(['sort' => 'asc', 'name' => 'asc'], ['ACTIVE' => 'Y', 'IBLOCK_ID' => $arCurrentValues['IBLOCK_ID']]);
        while ($property = $rsProperties->Fetch()) {
            $elementProperties[$property['CODE']] = '[' . $property['CODE'] . '] ' . $property['NAME'];
        }
    }
    $paramElementsFields = CIBlockParameters::GetFieldCode(Loc::getMessage('ELEMENTS_LIST_FIELDS'), 'BASE');
    $sortOrders = ['ASC' => Loc::getMessage('ELEMENTS_LIST_SORT_ORDER_ASC'), 'DESC' => Loc::getMessage('ELEMENTS_LIST_SORT_ORDER_DESC')];
    $arComponentParameters = ['GROUPS' => ['AJAX' => ['NAME' => Loc::getMessage('ELEMENTS_LIST_GROUP_AJAX')], 'SEO' => ['NAME' => Loc::getMessage('ELEMENTS_LIST_GROUP_SEO')], 'OTHERS' => ['NAME' => Loc::getMessage('ELEMENTS_LIST_GROUP_OTHERS')]], 'PARAMETERS' => ['IBLOCK_TYPE' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_IBLOCK_TYPE'), 'TYPE' => 'LIST', 'VALUES' => $iblockTypes, 'DEFAULT' => '', 'REFRESH' => 'Y'], 'IBLOCK_ID' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_IBLOCK_ID'), 'TYPE' => 'LIST', 'VALUES' => $iblocks, 'REFRESH' => 'Y'], 'SECTION_ID' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SECTION_ID'), 'TYPE' => 'LIST', 'VALUES' => $sections], 'SECTION_CODE' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SECTION_CODE'), 'TYPE' => 'STRING'], 'INCLUDE_SUBSECTIONS' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_INCLUDE_SUBSECTIONS'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'], 'SORT_BY_1' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SORT_BY_1'), 'TYPE' => 'LIST', 'VALUES' => CIBlockParameters::GetElementSortFields()], 'SORT_ORDER_1' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SORT_ORDER_1'), 'TYPE' => 'LIST', 'VALUES' => $sortOrders], 'SORT_BY_2' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SORT_BY_2'), 'TYPE' => 'LIST', 'VALUES' => CIBlockParameters::GetElementSortFields()], 'SORT_ORDER_2' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SORT_ORDER_2'), 'TYPE' => 'LIST', 'VALUES' => $sortOrders], 'SELECT_FIELDS' => $paramElementsFields, 'SELECT_PROPS' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_PROPERTIES'), 'TYPE' => 'LIST', 'MULTIPLE' => 'Y', 'VALUES' => $elementProperties, 'ADDITIONAL_VALUES' => 'Y'], 'RESULT_PROCESSING_MODE' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_RESULT_PROCESSING_MODE'), 'TYPE' => 'LIST', 'VALUES' => ['DEFAULT' => Loc::getMessage('ELEMENTS_LIST_RESULT_PROCESSING_MODE_DEFAULT'), 'EXTENDED' => Loc::getMessage('ELEMENTS_LIST_RESULT_PROCESSING_MODE_EXTENDED')]], 'EX_FILTER_NAME' => ['PARENT' => 'BASE', 'NAME' => Loc::getMessage('ELEMENTS_LIST_EX_FILTER_NAME'), 'TYPE' => 'STRING', 'DEFAULT' => ''], 'PAGER_SAVE_SESSION' => ['PARENT' => 'PAGER_SETTINGS', 'NAME' => Loc::getMessage('ELEMENTS_LIST_NAV_SAVE_SESSION'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'], 'ELEMENTS_COUNT' => ['PARENT' => 'PAGER_SETTINGS', 'NAME' => Loc::getMessage('ELEMENTS_LIST_ELEMENTS_COUNT'), 'TYPE' => 'STRING', 'DEFAULT' => '10'], 'USE_AJAX' => ['PARENT' => 'AJAX', 'NAME' => Loc::getMessage('ELEMENTS_LIST_USE_AJAX'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y'], 'AJAX_TYPE' => ['PARENT' => 'AJAX', 'NAME' => Loc::getMessage('ELEMENTS_LIST_AJAX_TYPE'), 'TYPE' => 'LIST', 'VALUES' => ['DEFAULT' => Loc::getMessage('ELEMENTS_LIST_AJAX_TYPE_DEFAULT'), 'JSON' => Loc::getMessage('ELEMENTS_LIST_AJAX_TYPE_JSON')]], 'AJAX_HEAD_RELOAD' => ['PARENT' => 'AJAX', 'NAME' => Loc::getMessage('ELEMENTS_LIST_AJAX_HEAD_RELOAD'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'], 'AJAX_TEMPLATE_PAGE' => ['PARENT' => 'AJAX', 'NAME' => Loc::getMessage('ELEMENTS_LIST_AJAX_TEMPLATE_PAGE'), 'TYPE' => 'STRING', 'DEFAULT' => ''], 'AJAX_COMPONENT_ID' => ['PARENT' => 'AJAX', 'NAME' => Loc::getMessage('ELEMENTS_LIST_AJAX_COMPONENT_ID'), 'TYPE' => 'STRING', 'DEFAULT' => ''], 'SET_SEO_TAGS' => ['PARENT' => 'SEO', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SET_SEO_TAGS'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y'], 'ADD_SECTIONS_CHAIN' => ['PARENT' => 'SEO', 'NAME' => Loc::getMessage('ELEMENTS_LIST_ADD_SECTIONS_CHAIN'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y'], 'SET_404' => ['PARENT' => 'OTHERS', 'NAME' => Loc::getMessage('ELEMENTS_LIST_SET_404'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'], 'CHECK_PERMISSIONS' => ['PARENT' => 'OTHERS', 'NAME' => Loc::getMessage('ELEMENTS_LIST_CHECK_PERMISSIONS'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y'], 'DATE_FORMAT' => CIBlockParameters::GetDateFormat(Loc::getMessage('ELEMENTS_LIST_DATE_FORMAT'), 'OTHERS'), 'CACHE_GROUPS' => ['PARENT' => 'CACHE_SETTINGS', 'NAME' => Loc::getMessage('ELEMENTS_LIST_CACHE_GROUPS'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'], 'CACHE_TIME' => ['DEFAULT' => 360000]]];
    CIBlockParameters::AddPagerSettings($arComponentParameters, Loc::getMessage('ELEMENTS_LIST_NAV_TITLE'), true, true);
} catch (Exception $e) {
    ShowError($e->getMessage());
}
예제 #25
0
 /**
  * Loads values from database.
  * Returns true on success.
  *
  * @return boolean
  */
 protected function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         $sectionList = \Bitrix\Iblock\SectionTable::getList(array("select" => array_values($this->fieldMap), "filter" => array("=ID" => $this->id)));
         $this->fields = $sectionList->fetch();
     }
     return is_array($this->fields);
 }
 /**
  * Gets the value of section
  *
  * @param array $id
  * @return array
  */
 protected function getValueSection($id)
 {
     if (sizeof($id) <= 0) {
         return array();
     }
     $result = array();
     $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
     $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $id));
     $sectionResult = $queryBuilder->exec();
     while ($section = $sectionResult->fetch()) {
         $result[$section['ID']] = $section;
     }
     return $result;
 }