本文整理汇总了PHP中CIBlockSection::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSection::getList方法的具体用法?PHP CIBlockSection::getList怎么用?PHP CIBlockSection::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSection
的用法示例。
在下文中一共展示了CIBlockSection::getList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAdd
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));
}
示例2: actionAdd
protected static function actionAdd($name, $arFields)
{
if ($name == 'ADDELEMENT') {
if (!self::checkElement($arFields)) {
return;
}
// we don't have the GLOBAL_ACTIVE flag in $arFields so we should check it manually
if (is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) {
$arNewSections = array();
$arFilter = array('ID' => $arFields['IBLOCK_SECTION'], 'IBLOCK_ID' => $arFields['IBLOCK_ID'], 'GLOBAL_ACTIVE' => 'Y');
$dbRes = \CIBlockSection::getList(array(), $arFilter, false, array('ID'));
while ($ar = $dbRes->fetch()) {
$arNewSections[] = $ar['ID'];
}
if (count($arNewSections) <= 0) {
// element is added to inactive sections
return;
}
$arFields['IBLOCK_SECTION'] = $arNewSections;
}
} elseif ($name == 'ADDSECTION') {
$dbRes = \CIBlockSection::getList(array(), array('ID' => $arFields['ID'], 'GLOBAL_ACTIVE' => 'Y'), false, array('ID'));
if (!$dbRes->fetch()) {
// section is added to inactive branch
return;
}
}
$arSitemaps = SitemapIblockTable::getByIblock($arFields, $name == 'ADDSECTION' ? SitemapIblockTable::TYPE_SECTION : SitemapIblockTable::TYPE_ELEMENT);
$arFields['TIMESTAMP_X'] = ConvertTimeStamp(false, "FULL");
if (isset($arFields['IBLOCK_SECTION']) && is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) {
$arFields['IBLOCK_SECTION_ID'] = min($arFields['IBLOCK_SECTION']);
}
if (count($arSitemaps) > 0) {
$arSiteDirs = array();
$dbSite = SiteTable::getList(array('select' => array('LID', 'DIR')));
while ($arSite = $dbSite->fetch()) {
$arSiteDirs[$arSite['LID']] = $arSite['DIR'];
}
foreach ($arSitemaps as $arSitemap) {
$arFields['LANG_DIR'] = $arSiteDirs[$arSitemap['SITE_ID']];
$rule = array('url' => $name == 'ADDSECTION' ? \CIBlock::replaceDetailUrl($arSitemaps[0]['SECTION_PAGE_URL'], $arFields, false, "S") : \CIBlock::replaceDetailUrl($arSitemaps[0]['DETAIL_PAGE_URL'], $arFields, false, "E"), 'lastmod' => MakeTimeStamp($arFields['TIMESTAMP_X']));
$fileName = str_replace(array('#IBLOCK_ID#', '#IBLOCK_CODE#', '#IBLOCK_XML_ID#'), array($arFields['IBLOCK_ID'], $arSitemap['IBLOCK_CODE'], $arSitemap['IBLOCK_XML_ID']), $arSitemap['SITEMAP_FILE_IBLOCK']);
$sitemapFile = new SitemapFile($fileName, $arSitemap);
$sitemapFile->appendIblockEntry($rule['url'], $rule['lastmod']);
$sitemapIndex = new SitemapIndex($arSitemap['SITEMAP_FILE'], $arSitemap);
$sitemapIndex->appendIndexEntry($sitemapFile);
if ($arSitemap['ROBOTS'] == 'Y') {
$robotsFile = new RobotsFile($arSitemap['SITE_ID']);
$robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapIndex->getUrl()));
}
}
}
}
示例3: getSectionIdByCode
protected function getSectionIdByCode($sectionCode = "")
{
$sectionId = 0;
if ($sectionCode !== '') {
return $sectionId;
}
$sectionFilter = array("IBLOCK_ID" => $this->arParams['IBLOCK_ID'], "IBLOCK_ACTIVE" => "Y");
$sectionFilter["=CODE"] = $sectionCode;
$sectionIt = CIBlockSection::getList(array(), $sectionFilter, false, array("ID"));
if ($section = $sectionIt->Fetch()) {
$sectionId = $section['ID'];
}
return $sectionId;
}
示例4: getNotEmptySections
public static function getNotEmptySections($filter = array('sections' => array(), 'elements' => array()), $sort = array())
{
CModule::includeModule('iblock');
$sections = array();
$rsSections = CIBlockSection::getList($sort, $filter['sections']);
while ($section = $rsSections->getNext()) {
$sections[$section['ID']] = $section;
}
$tmpSections = $sections;
$sections = array();
$rsElements = CIBlockElement::getList(array('SORT'), $filter['elements'], array('IBLOCK_SECTION_ID'));
while ($element = $rsElements->getNext()) {
if ($element['CNT'] > 0) {
$sections[$element['IBLOCK_SECTION_ID']] = $tmpSections[$element['IBLOCK_SECTION_ID']];
}
}
return $sections;
}
示例5: getSectionDataByAttachObject
private function getSectionDataByAttachObject(array $attachObject)
{
if (empty($attachObject['type'])) {
throw new \Bitrix\Main\ArgumentException('type', 'attachObject');
}
if (!isset($attachObject['id'])) {
throw new \Bitrix\Main\ArgumentException('id', 'attachObject');
}
if ($attachObject['type'] == \CWebDavSymlinkHelper::ENTITY_TYPE_GROUP) {
$data = \CWebDavIblock::getRootSectionDataForGroup((int) $attachObject['id']);
$data['SOCNET_GROUP_ID'] = $attachObject['id'];
return $data;
}
if ($attachObject['type'] == \CWebDavSymlinkHelper::ENTITY_TYPE_USER) {
$sectionId = (int) $attachObject['id'];
$sectionData = \CIBlockSection::getList(array(), array('ID' => $sectionId, 'CHECK_PERMISSIONS' => 'Y'), false, array('SOCNET_GROUP_ID', 'IBLOCK_ID', 'CREATED_BY', 'NAME'));
if (!$sectionData || !($sectionData = $sectionData->fetch())) {
return array();
}
$allowableIblock = false;
$iblockType = false;
foreach (array('user_files', 'group_files', 'shared_files') as $type) {
$wdIblockOptions = \CWebDavIblock::libOptions($type, false, SITE_ID);
if (is_set($wdIblockOptions, 'id') && intval($wdIblockOptions['id']) > 0) {
if ($sectionData['IBLOCK_ID'] == $wdIblockOptions['id']) {
$allowableIblock = true;
$iblockType = $type;
}
}
}
if (!$allowableIblock) {
return array();
}
\CWebDavSymlinkHelper::setIblockIdForSectionId($sectionId, $sectionData['IBLOCK_ID']);
return array('NAME' => $sectionData['NAME'], 'IBLOCK_ID' => $sectionData['IBLOCK_ID'], 'IBLOCK_TYPE' => $iblockType, 'SECTION_ID' => $sectionId, 'CREATED_BY' => $sectionData['CREATED_BY'], 'SOCNET_GROUP_ID' => isset($sectionData['SOCNET_GROUP_ID']) ? $sectionData['SOCNET_GROUP_ID'] : null);
}
throw new \Bitrix\Main\ArgumentException('Wrong type', 'attachObject');
}
示例6: checkSection
protected function checkSection($sectionId = -1, $sectionCode = "")
{
if ($this->arParams['IBLOCK_ID'] <= 0) {
return 0;
}
$bSectionFound = false;
$sectionFilter = array("IBLOCK_ID" => $this->arParams['IBLOCK_ID'], "IBLOCK_ACTIVE" => "Y");
$id = 0;
if ($sectionId > 0) {
$sectionFilter["ID"] = $sectionId;
$sectionIt = CIBlockSection::GetList(array(), $sectionFilter, false, array("ID"));
if ($section = $sectionIt->Fetch()) {
$id = $section['ID'];
$bSectionFound = true;
}
}
if (!$bSectionFound && $sectionCode !== '') {
$sectionFilter["=CODE"] = $sectionCode;
$sectionIt = CIBlockSection::getList(array(), $sectionFilter, false, array("ID"));
if ($section = $sectionIt->Fetch()) {
$id = $section['ID'];
}
}
return $id;
}
示例7: onBeforeConfirmNotify
public static function onBeforeConfirmNotify($module, $tag, $value, $arNotify)
{
global $USER;
$userId = $USER->getId();
if ($module == 'webdav' && $userId) {
$tagData = explode('|', $tag);
$folderInviteId = intval($tagData[2]);
if ($tagData[0] == "WEBDAV" && $tagData[1] == "INVITE" && $folderInviteId > 0 && $userId == $tagData[3]) {
if (\Bitrix\Main\Loader::includeModule('im')) {
CIMNotify::DeleteByTag(\Bitrix\Webdav\FolderInviteTable::getNotifyTag(array('ID' => $folderInviteId, 'INVITE_USER_ID' => $userId)));
}
//decline
if ($value === 'N') {
\Bitrix\Webdav\FolderInviteTable::delete($folderInviteId);
return false;
}
$targetSectionData = CWebDavIblock::getRootSectionDataForUser($userId);
if (!$targetSectionData) {
return false;
}
$folderInviteData = \Bitrix\Webdav\FolderInviteTable::getRowById($folderInviteId);
if (!$folderInviteData) {
return false;
}
$sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInviteData['SECTION_ID'], 'IBLOCK_ID' => $folderInviteData['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME', 'SOCNET_GROUP_ID'))->fetch();
if (empty($sectionToShare['NAME']) || empty($sectionToShare['SOCNET_GROUP_ID'])) {
return false;
}
if (\Bitrix\Main\Loader::includeModule('socialnetwork')) {
$group = CSocNetGroup::GetList(array(), array('ID' => $sectionToShare['SOCNET_GROUP_ID']), false, false, array('NAME'))->fetch();
}
if (empty($group)) {
return false;
}
$groupId = $sectionToShare['SOCNET_GROUP_ID'];
$dispatcher = new \Bitrix\Webdav\InviteDispatcher();
$attachObjectType = CWebDavSymlinkHelper::ENTITY_TYPE_GROUP;
$attachObjectId = (int) $groupId;
$inviteComponentParams = array('attachObject' => array('id' => $attachObjectId, 'type' => $attachObjectType), 'attachToUserId' => $folderInviteData['INVITE_USER_ID'], 'inviteFromUserId' => $folderInviteData['USER_ID'], 'canEdit' => $folderInviteData['CAN_EDIT']);
$response = $dispatcher->processActionConnect($inviteComponentParams);
if ($response['status'] == $dispatcher::STATUS_SUCCESS) {
\Bitrix\Webdav\FolderInviteTable::update($folderInviteId, array('IS_APPROVED' => true, 'LINK_SECTION_ID' => $response['sectionId']));
}
return $response['status'] == $dispatcher::STATUS_SUCCESS;
}
}
}
示例8: createDataExcel
//.........这里部分代码省略.........
foreach ($listValue as $idAttached) {
$number++;
list($type, $realId) = Bitrix\Disk\Uf\FileUserType::detectType($idAttached);
if ($type == Bitrix\Disk\Uf\FileUserType::TYPE_ALREADY_ATTACHED) {
$attachedModel = Bitrix\Disk\AttachedObject::loadById($realId);
if (!$attachedModel) {
continue;
}
$fileModel = Bitrix\Disk\File::loadById($attachedModel->getObjectId(), array('STORAGE'));
if (!$fileModel) {
continue;
}
$data[$fieldId] .= $fileModel->getName();
$data[$fieldId] .= $countFiles != $number ? ', ' : '';
}
}
}
continue;
}
if (is_array($arProp["~VALUE"])) {
foreach ($arProp["~VALUE"] as $propValue) {
$data[$fieldId][] = call_user_func_array($arField["PROPERTY_USER_TYPE"]["GetPublicViewHTML"], array($arField, array("VALUE" => $propValue), array()));
}
} else {
$data[$fieldId] = call_user_func_array($arField["PROPERTY_USER_TYPE"]["GetPublicViewHTML"], array($arField, array("VALUE" => $arProp["~VALUE"]), array()));
}
} elseif ($arField["PROPERTY_TYPE"] == "E") {
if (empty($arProp['VALUE'])) {
continue;
}
if (!is_array($arProp['VALUE'])) {
$arProp['VALUE'] = array($arProp['VALUE']);
}
$elementQuery = CIBlockElement::getList(array(), array("=ID" => $arProp['VALUE']), false, false, array("NAME"));
while ($element = $elementQuery->fetch()) {
$data[$fieldId][] = $element['NAME'];
}
} elseif ($arField["PROPERTY_TYPE"] == "G") {
if (empty($arProp['VALUE'])) {
continue;
}
if (!is_array($arProp['VALUE'])) {
$arProp['VALUE'] = array($arProp['VALUE']);
}
$sectionQuery = CIBlockSection::getList(array(), array("=ID" => $arProp['VALUE']));
while ($section = $sectionQuery->fetch()) {
$data[$fieldId][] = $section['NAME'];
}
} elseif ($arField["PROPERTY_TYPE"] == "L") {
$data[$fieldId] = htmlspecialcharsex($arProp["VALUE_ENUM"]);
} elseif ($arField["PROPERTY_TYPE"] == "F") {
$files = is_array($arProp["VALUE"]) ? $arProp["VALUE"] : array($arProp["VALUE"]);
$number = 1;
$countFiles = count($files);
foreach ($files as $file) {
$value = CFile::MakeFileArray($file);
$data[$fieldId] .= $value["name"];
$data[$fieldId] .= $countFiles != $number ? ', ' : '';
$number++;
}
} else {
$data[$fieldId] = htmlspecialcharsex($arProp["VALUE"]);
}
}
}
if (!empty($data["IBLOCK_SECTION_ID"])) {
示例9: migrateExternalLinks
protected function migrateExternalLinks()
{
$this->abortIfNeeded();
if ($this->isStepFinished(__METHOD__)) {
return array(0, 0);
}
$successCount = $failedCount = 0;
$this->log(array('Start migrate external links'));
$lastCreationDate = $this->getLastConvertedExtLinkCreationDate();
$connection = Application::getInstance()->getConnection();
$query = $connection->query("\n\t\t\tSELECT * from b_webdav_ext_links ext\n\t\t\tWHERE ext.LINK_TYPE = 'M' AND ext.RESOURCE_TYPE = 'IBLOCK' AND ext.CREATION_DATE > {$lastCreationDate} AND (ext.ELEMENT_ID IS NULL OR ext.ELEMENT_ID = 0)\n\t\t\tORDER BY ext.CREATION_DATE\n\t\t");
while ($query && ($extLinkRow = $query->fetch())) {
$this->abortIfNeeded();
$extLinkData = $this->prepareDataFromOldExtLink($extLinkRow);
if (empty($extLinkRow['ROOT_SECTION_ID']) && !empty($extLinkRow['URL'])) {
$this->log(array('Migrate simple ext.link from common storage (without symbolic link)'));
$success = true;
$pathItems = explode('/', ltrim($extLinkRow['URL'], '/'));
$nameOfElement = array_pop($pathItems);
$prevSectionId = 0;
$prevIblockId = $extLinkRow['IBLOCK_ID'];
foreach ($pathItems as $path) {
$pathFilter = array('=NAME' => $path, 'IBLOCK_ID' => $prevIblockId, 'SECTION_ID' => $prevSectionId);
$section = CIBlockSection::getList(array(), $pathFilter, false, array('ID', 'IBLOCK_ID'))->fetch();
if (!$section) {
$success = false;
break;
}
$prevSectionId = $section['ID'];
$prevIblockId = $section['IBLOCK_ID'];
}
unset($path);
if (!$success) {
$this->log(array('Could not migrate ext.link (resolve path)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$targetElement = CIBlockElement::getList(array(), array('=NAME' => $nameOfElement, 'IBLOCK_ID' => $prevIblockId, 'SECTION_ID' => $prevSectionId), false, false, array('ID'))->fetch();
if (!$targetElement || empty($targetElement['ID'])) {
$this->log(array('Could not migrate ext.link (find iblockElement)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$targetElement['ID'] = (int) $targetElement['ID'];
$result = $this->connection->query("SELECT ID FROM b_disk_object WHERE WEBDAV_ELEMENT_ID = {$targetElement['ID']}")->fetch();
if (!$result || empty($result['ID'])) {
$this->log(array('Could not migrate ext.link (find b_disk_object)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$extLinkData['OBJECT_ID'] = $result['ID'];
} elseif (!empty($extLinkRow['ROOT_SECTION_ID']) && !empty($extLinkRow['URL'])) {
$this->log(array('Migrate ext.link from user storage (may contains symbolic link)'));
$success = true;
$pathItems = explode('/', ltrim($extLinkRow['URL'], '/'));
$nameOfElement = array_pop($pathItems);
$prevSectionId = $extLinkRow['ROOT_SECTION_ID'];
$prevIblockId = $extLinkRow['IBLOCK_ID'];
foreach ($pathItems as $path) {
$pathFilter = array('=NAME' => $path, 'IBLOCK_ID' => $prevIblockId, 'SECTION_ID' => $prevSectionId);
$section = CIBlockSection::getList(array(), $pathFilter, false, array('ID', 'IBLOCK_ID', 'UF_LINK_IBLOCK_ID', 'UF_LINK_SECTION_ID'))->fetch();
if (!$section) {
$success = false;
break;
}
$prevSectionId = empty($section['UF_LINK_SECTION_ID']) ? $section['ID'] : $section['UF_LINK_SECTION_ID'];
$prevIblockId = empty($section['UF_LINK_IBLOCK_ID']) ? $section['IBLOCK_ID'] : $section['UF_LINK_IBLOCK_ID'];
}
unset($path);
if (!$success) {
$this->log(array('Could not migrate ext.link (resolve symbolic path)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$targetElement = CIBlockElement::getList(array(), array('=NAME' => $nameOfElement, 'IBLOCK_ID' => $prevIblockId, 'SECTION_ID' => $prevSectionId), false, false, array('ID'))->fetch();
if (!$targetElement || empty($targetElement['ID'])) {
$this->log(array('Could not migrate ext.link (find iblockElement)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$targetElement['ID'] = (int) $targetElement['ID'];
$result = $this->connection->query("SELECT ID FROM b_disk_object WHERE WEBDAV_ELEMENT_ID = {$targetElement['ID']}")->fetch();
if (!$result || empty($result['ID'])) {
$this->log(array('Could not migrate ext.link (find b_disk_object)', $extLinkRow));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$extLinkData['OBJECT_ID'] = $result['ID'];
}
$result = ExternalLinkTable::add($extLinkData);
if (!$result->isSuccess()) {
$this->log(array('Could not add new ext.link', $extLinkData, $result->getErrors()));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
continue;
}
$this->log(array('Success attempt', $result->getId()));
$this->storeConvertedExtLinkCreationDate($extLinkRow['CREATION_DATE']);
}
$this->setStepFinished(__METHOD__);
$this->log(array('Finish migrate external links'));
//.........这里部分代码省略.........