本文整理汇总了PHP中CIBlock::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::GetByID方法的具体用法?PHP CIBlock::GetByID怎么用?PHP CIBlock::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::GetByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getElementLink
public function getElementLink($aElement)
{
static $aIBTypeCache = array();
if (!isset($aIBTypeCache[$aElement['IBLOCK_ID']])) {
$aIBTypeCache[$aElement['IBLOCK_ID']] = CIBlock::GetByID($aElement['IBLOCK_ID'])->Fetch();
$aIBTypeCache[$aElement['IBLOCK_ID']] = $aIBTypeCache[$aElement['IBLOCK_ID']]['IBLOCK_TYPE_ID'];
}
return '<a href="/bitrix/admin/iblock_element_edit.php?WF=Y&ID=' . $aElement['ID'] . '&type=' . $aIBTypeCache[$aElement['IBLOCK_ID']] . '&lang=ru&IBLOCK_ID=' . $aElement['IBLOCK_ID'] . '&find_section_section=-1">' . @$aElement['NAME'] . ' </a>';
}
示例2: AttachUsersToIBlock
function AttachUsersToIBlock($iblockID)
{
$iblockID = intval($iblockID);
if (CModule::IncludeModule("iblock") && $iblockID > 0) {
$dbIblock = CIBlock::GetByID($iblockID);
if ($dbIblock->Fetch()) {
$this->attachIBlockID = $iblockID;
}
}
}
示例3: getOffers
protected function getOffers()
{
$arPropertyMap = array();
$arSelectedPropTypes = array('S', 'N', 'L', 'E', 'G');
$this->arSelectOfferProps = array();
$arOffers = \CCatalogSKU::GetInfoByProductIBlock($this->iBlockId);
if (empty($arOffers['IBLOCK_ID'])) {
return array();
}
$this->intOfferIBlockID = $arOffers['IBLOCK_ID'];
$rsOfferIBlocks = \CIBlock::GetByID($this->intOfferIBlockID);
if (!($this->arOfferIBlock = $rsOfferIBlocks->Fetch())) {
throw new SystemException("Bad offers iBlock ID (" . __CLASS__ . "::" . __METHOD__ . ")");
}
$rsProps = \CIBlockProperty::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('IBLOCK_ID' => $this->intOfferIBlockID, 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'));
while ($arProp = $rsProps->Fetch()) {
$arProp['ID'] = (int) $arProp['ID'];
if ($arOffers['SKU_PROPERTY_ID'] != $arProp['ID']) {
$arProp['USER_TYPE'] = (string) $arProp['USER_TYPE'];
$arProp['CODE'] = (string) $arProp['CODE'];
$this->arIblock['OFFERS_PROPERTY'][$arProp['ID']] = $arProp;
$this->arProperties[$arProp['ID']] = $arProp;
if (in_array($arProp['PROPERTY_TYPE'], $arSelectedPropTypes)) {
$this->arSelectOfferProps[] = $arProp['ID'];
}
if ($arProp['CODE'] !== '') {
foreach ($this->arIblock['PROPERTY'] as &$arMainProp) {
if ($arMainProp['CODE'] == $arProp['CODE']) {
$arPropertyMap[$arProp['ID']] = $arMainProp['CODE'];
break;
}
}
if (isset($arMainProp)) {
unset($arMainProp);
}
}
}
}
$this->arOfferIBlock['LID'] = $this->arIblock['LID'];
$this->arOfferIBlock['PROPERTY'] = array();
$rsProps = \CIBlockProperty::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('IBLOCK_ID' => $this->intOfferIBlockID, 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'));
while ($arProp = $rsProps->Fetch()) {
$arProp['ID'] = (int) $arProp['ID'];
$arProp['USER_TYPE'] = (string) $arProp['USER_TYPE'];
$arProp['CODE'] = (string) $arProp['CODE'];
$this->arOfferIBlock['PROPERTY'][$arProp['ID']] = $arProp;
}
return $arOffers;
}
示例4: __call
function __call($name, $arguments)
{
if (isset($this->events[$name])) {
$eventParams =& $arguments['0'];
$arEvent = $this->events[$name];
$description['ID'] = $eventParams['ELEMENT']['id'];
if ($name == "OnFileRename" || $name == "OnFolderRename") {
$description["NAME_BEFORE"] = $eventParams['ELEMENT']['name'];
$description['NAME'] = $eventParams['OPERATION']['TO'];
} else {
$description['NAME'] = $eventParams['ELEMENT']['name'];
}
$description['URL'] = $eventParams['ELEMENT']['url'];
$res = CIBlock::GetByID($this->iblock_id);
if ($arEvent['object'] == 'ELEMENT') {
if ($ar_res = $res->GetNext()) {
$description['ELEMENT_NAME'] = $ar_res['ELEMENT_NAME'];
}
$rsIBlock = CIBlockElement::GetList(array(), array("=ID" => $description['ID']), false, false, array("LIST_PAGE_URL"));
$arIBlock = $rsIBlock->GetNext();
} else {
if ($ar_res = $res->GetNext()) {
$description['SECTION_NAME'] = $ar_res['SECTION_NAME'];
}
$rsIBlock = CIBlockSection::GetList(array(), array("=ID" => $description['ID']), false, array("LIST_PAGE_URL"));
$arIBlock = $rsIBlock->GetNext();
}
$description["IBLOCK_PAGE_URL"] = $arIBlock["LIST_PAGE_URL"];
$description['IBLOCK_NAME'] = $ar_res['NAME'];
if ($name == "OnFolderMove" || $name == "OnFileMove") {
$this->SectionURL = "";
$this->MakeSectionURL($eventParams['OPERATION']['TO']);
$description['MOVE_TO'] = $this->SectionURL;
if ($description['MOVE_TO'] == "") {
$description['MOVE_TO'] = $description['IBLOCK_NAME'];
}
}
$this->Log($arEvent['object'], $arEvent['action'], $this->iblock_id, serialize($description));
}
}
示例5: array
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
if (0 < $arResult['SECTIONS_COUNT'] && \Bitrix\Main\Loader::includeModule('iblock') && ($arResult['IBLOCK'] = CIBlock::GetByID($arParams['IBLOCK_ID'])->Fetch())) {
$arResult['IBLOCK']['LIST_PAGE_URL'] = str_replace('//', '/', CComponentEngine::MakePathFromTemplate($arResult['IBLOCK']['LIST_PAGE_URL'], array('IBLOCK_CODE' => $arResult['IBLOCK']['CODE'])));
}
示例6: array
if(in_array($item['offer']['externalId'], $bItms)){
if ((int) $item['quantity'] != (int) $bItms[$item['offer']['externalId']]['QUANTITY']) {
$arProduct['QUANTITY'] = $item['quantity'];
$g = CSaleBasket::Update($bItms[$item['offer']['externalId']]['ID'], $arProduct);
//резерв
$ar_res = CCatalogProduct::GetByID($item['offer']['externalId']);
$arFields = array(
'QUANTITY' => (int)$ar_res['QUANTITY'] + (int)$bItms[$item['offer']['externalId']]['QUANTITY'] - (int) $item['quantity'],
'QUANTITY_RESERVED' => (int)$ar_res['QUANTITY_RESERVED'] - (int)$bItms[$item['offer']['externalId']]['QUANTITY'] + (int) $item['quantity'],
);
$d = CCatalogProduct::Update($item['offer']['externalId'], $arFields);
}
}//если нет, добавляем
else{
$p = CIBlockElement::GetByID($item['offer']['externalId'])->Fetch();
$iblock = CIBlock::GetByID($p['IBLOCK_ID'])->Fetch();
$p['CATALOG_XML_ID'] = $iblock['XML_ID'];
$p['PRODUCT_XML_ID'] = $p['XML_ID'];
$arProduct = array(
'FUSER_ID' => $userId,
'ORDER_ID' => $order['externalId'],
'QUANTITY' => $item['quantity'],
'CURRENCY' => CCurrency::GetBaseCurrency(),
'LID' => $LID,
'PRODUCT_ID' => $item['offer']['externalId'],
'PRODUCT_PRICE_ID' => $p['PRODUCT_PRICE_ID'],
'WEIGHT' => $p['WEIGHT'],
'DELAY' => $p['DELAY'],
'CAN_BUY' => $p['CAN_BUY'],
'MODULE' => $p['MODULE'],
'NOTES' => $item['comment'] ?: $p['NOTES'],
示例7: ShowError
echo ShowError(str_replace('#ID#', $intIBlockID, GetMessage("YANDEX_ERR_NO_IBLOCK_FOUND_EXT")));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
$boolOffers = false;
$arOffers = false;
$arOfferIBlock = false;
$intOfferIBlockID = 0;
$arSelectOfferProps = array();
$arSelectedPropTypes = array('S', 'N', 'L', 'E', 'G');
$arOffersSelectKeys = array(YANDEX_SKU_EXPORT_ALL, YANDEX_SKU_EXPORT_MIN_PRICE, YANDEX_SKU_EXPORT_PROP);
$arOffers = CCatalogSKU::GetInfoByProductIBlock($intIBlockID);
if (!empty($arOffers['IBLOCK_ID'])) {
$intOfferIBlockID = $arOffers['IBLOCK_ID'];
$strPerm = 'D';
$rsOfferIBlocks = CIBlock::GetByID($intOfferIBlockID);
if ($arOfferIBlock = $rsOfferIBlocks->Fetch()) {
$bBadBlock = !CIBlockRights::UserHasRightTo($intOfferIBlockID, $intOfferIBlockID, "iblock_admin_display");
if ($bBadBlock) {
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
echo ShowError(GetMessage('YANDEX_ERR_NO_ACCESS_IBLOCK_SKU'));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
} else {
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
echo ShowError(str_replace('#ID#', $intIBlockID, GetMessage("YANDEX_ERR_NO_IBLOCK_SKU_FOUND")));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
$boolOffers = true;
示例8: array
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php";
if (CModule::IncludeModule("iblock")) {
$res = CIBlock::GetByID($_GET["BID"]);
if ($ar_res = $res->GetNext()) {
$APPLICATION->SetTitle($ar_res['NAME']);
?>
<?php
$APPLICATION->IncludeComponent("bitrix:news.list", "geekcon", array("DISPLAY_DATE" => "Y", "DISPLAY_NAME" => "Y", "DISPLAY_PICTURE" => "Y", "DISPLAY_PREVIEW_TEXT" => "Y", "AJAX_MODE" => "Y", "IBLOCK_TYPE" => "news", "IBLOCK_ID" => $_GET["ID"], "NEWS_COUNT" => "", "SORT_BY1" => "ACTIVE_FROM", "SORT_ORDER1" => "DESC", "SORT_BY2" => "SORT", "SORT_ORDER2" => "ASC", "FILTER_NAME" => "", "FIELD_CODE" => array("ID"), "PROPERTY_CODE" => array("DESCRIPTION"), "CHECK_DATES" => "Y", "DETAIL_URL" => "", "PREVIEW_TRUNCATE_LEN" => "", "ACTIVE_DATE_FORMAT" => "d.m.Y", "SET_TITLE" => "Y", "SET_BROWSER_TITLE" => "Y", "SET_META_KEYWORDS" => "Y", "SET_META_DESCRIPTION" => "Y", "SET_LAST_MODIFIED" => "Y", "INCLUDE_IBLOCK_INTO_CHAIN" => "Y", "ADD_SECTIONS_CHAIN" => "Y", "HIDE_LINK_WHEN_NO_DETAIL" => "Y", "PARENT_SECTION" => "", "PARENT_SECTION_CODE" => "", "INCLUDE_SUBSECTIONS" => "Y", "CACHE_TYPE" => "A", "CACHE_TIME" => "3600", "CACHE_FILTER" => "Y", "CACHE_GROUPS" => "Y", "DISPLAY_TOP_PAGER" => "Y", "DISPLAY_BOTTOM_PAGER" => "Y", "PAGER_TITLE" => $ar_res['NAME'], "PAGER_SHOW_ALWAYS" => "Y", "PAGER_TEMPLATE" => "", "PAGER_DESC_NUMBERING" => "Y", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "Y", "PAGER_BASE_LINK_ENABLE" => "Y", "SET_STATUS_404" => "Y", "SHOW_404" => "Y", "MESSAGE_404" => "", "PAGER_BASE_LINK" => "", "PAGER_PARAMS_NAME" => "arrPager", "AJAX_OPTION_JUMP" => "N", "AJAX_OPTION_STYLE" => "Y", "AJAX_OPTION_HISTORY" => "N", "AJAX_OPTION_ADDITIONAL" => ""));
?>
<?php
}
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php";
示例9: intval
$buyerId = intval($USER->GetID());
$sTableID = "tbl_product_search";
if ($caller) {
if (!isset($_REQUEST["set_filter"])) {
$addURLParam = "&set_filter=Y";
if (!isset($_REQUEST["IBLOCK_ID"])) {
$addURLParam .= CUserOptions::getOption("catalog", "product_search_" . $caller, "", $buyerId);
LocalRedirect($GLOBALS['APPLICATION']->GetCurPageParam() . $addURLParam);
}
}
$addURLParam = CUserOptions::getOption("catalog", "product_search_storeDocs", "", $userId);
$sTableID .= '_' . $caller;
}
$oSort = new CAdminSorting($sTableID, "ID", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$dbIBlock = CIBlock::GetByID($iblockId);
if (!($arIBlock = $dbIBlock->Fetch())) {
$arFilterTmp = array("MIN_PERMISSION" => "R");
if (strlen($lid) > 0) {
$arFilterTmp["LID"] = $lid;
}
$arCatalogFilter = array();
if ($boolSubscribe) {
$arCatalogFilter['SUBSCRIPTION'] = 'Y';
}
$dbItem = CCatalog::GetList(array(), $arCatalogFilter, false, false, array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID', 'SKU_PROPERTY_ID'));
while ($arItems = $dbItem->Fetch()) {
$arFilterTmp["ID"][] = $arItems["IBLOCK_ID"];
}
foreach (GetModuleEvents("sale", "OnProductSearchFormIBlock", true) as $arEvent) {
$arFilterTmp = ExecuteModuleEventEx($arEvent, array($arFilterTmp));
示例10:
<?if(CModule::IncludeModule("iblock"))
{
$res = CIBlock::GetByID($arParams["IBLOCK_ID"]);
if($ar_res = $res->GetNext())
$arResult["IBLOCK_NAME"] = $ar_res['NAME'];
}
?>
示例11: __GetParam
public static function __GetParam($lang, $site_id, $module_id = false, $param1 = false, $param2 = false, $item_id = false)
{
$name = "";
if ($module_id == "iblock" && CModule::IncludeModule("iblock")) {
if ($item_id !== false) {
$rs = CIBlockElement::GetByID($item_id);
if ($ar = $rs->GetNext()) {
$name = $ar["NAME"];
}
} elseif ($param2 !== false) {
$rs = CIBlock::GetByID($param2);
if ($ar = $rs->GetNext()) {
$name = $ar["NAME"];
}
} elseif ($param1 !== false) {
$rs = CIBlockType::GetByIDLang($param1, $lang);
if (is_array($rs)) {
$name = $rs["NAME"];
}
} else {
$name = GetMessage("customrank_iblocks");
}
} elseif ($module_id == "forum" && CModule::IncludeModule("forum")) {
if ($item_id !== false) {
$name = "";
} elseif ($param2 !== false) {
$rs = CForumTopic::GetByID($param2);
if (is_array($rs)) {
$name = htmlspecialcharsex($rs["TITLE"]);
}
} elseif ($param1 !== false) {
$rs = CForumNew::GetByID($param1);
if (is_array($rs)) {
$name = htmlspecialcharsex($rs["NAME"]);
}
} else {
$name = GetMessage("customrank_forum");
}
} elseif ($module_id == "main") {
if ($item_id !== false) {
$name = "";
} else {
$name = GetMessage("customrank_files");
}
} elseif ($module_id === false) {
$rs = CSite::GetByID($site_id);
if ($ar = $rs->GetNext()) {
$name = $ar["NAME"];
}
} else {
$name = false;
}
return $name;
}
示例12: OnAfterPhotoCommentAddBlog
public function OnAfterPhotoCommentAddBlog($ID, $arFields)
{
if (!CModule::IncludeModule('iblock')) {
return;
}
if (!$this->IsSocnet) {
return;
}
if (intval($this->PhotoElementID) > 0) {
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "photo_photo", "SOURCE_ID" => $this->PhotoElementID), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "TITLE", "URL", "USER_ID", "PARAMS"));
$bSocNetLogRecordExists = false;
if ($arRes = $dbRes->Fetch()) {
$log_id = $arRes["ID"];
$entity_type = $arRes["ENTITY_TYPE"];
$entity_id = $arRes["ENTITY_ID"];
$log_title = $arRes["TITLE"];
$log_url = $arRes["URL"];
$log_user_id = $arRes["USER_ID"];
$bSocNetLogRecordExists = true;
if (strlen($arRes["PARAMS"]) > 0) {
$arTmp = unserialize($arRes["PARAMS"]);
if ($arTmp) {
if (array_key_exists("SECTION_NAME", $arTmp) && strlen($arTmp["SECTION_NAME"]) > 0) {
$log_section_name = $arTmp["SECTION_NAME"];
}
if (array_key_exists("SECTION_URL", $arTmp) && strlen($arTmp["SECTION_URL"]) > 0) {
$log_section_url = $arTmp["SECTION_URL"];
}
}
}
} else {
$rsElement = CIBlockElement::GetByID($this->PhotoElementID);
if ($arElement = $rsElement->Fetch()) {
$url = $this->arPath["DETAIL_URL"];
$sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
if (intval($arElement["CREATED_BY"]) > 0) {
$rsUser = CUser::GetByID($arElement["CREATED_BY"]);
if ($arUser = $rsUser->Fetch()) {
$sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
}
}
if (in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0) {
$entity_type = $this->entity_type;
$entity_id = $this->entity_id;
$alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user") . "_" . $this->entity_id;
}
$arLogParams = array("BLOG_ID" => intval($this->BlogID));
$rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]);
if ($arIBlock = $rsIBlock->Fetch()) {
$arLogParams["IBLOCK_ID"] = $arIBlock["ID"];
$arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"];
}
$rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]);
if ($arSection = $rsSection->Fetch()) {
$arLogParams["SECTION_ID"] = $arSection["ID"];
$arLogParams["SECTION_NAME"] = $arSection["NAME"];
$arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]);
$arSectionPath = array();
$bPassword = false;
$dbSectionPath = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD"));
while ($arPath = $dbSectionPath->Fetch()) {
$arSectionPath[] = $arPath;
if (strlen(trim($arPath["UF_PASSWORD"])) > 0) {
$bPassword = true;
break;
}
}
if (!$alias) {
$entity_type = SONET_ENTITY_USER;
$entity_id = $arSectionPath[0]["CREATED_BY"];
$alias = $arSectionPath[0]["CODE"];
}
}
$arLogParams["ALIAS"] = $alias;
$arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array("ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"])), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID" => $arElement["ID"]);
if (intval($arElement["CREATED_BY"]) > 0) {
$arSonetFields["USER_ID"] = $arElement["CREATED_BY"];
}
$log_id = CSocNetLog::Add($arSonetFields, false);
if (intval($log_id) > 0) {
$log_title = $arSonetFields["TITLE"];
$log_url = $arSonetFields["URL"];
$log_section_name = $arLogParams["SECTION_NAME"];
$log_section_url = $arLogParams["SECTION_URL"];
$log_user_id = $arSonetFields["USER_ID"];
CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
if ($bPassword) {
CSocNetLogRights::DeleteByLogID($log_id);
CSocNetLogRights::Add($log_id, array("U" . $GLOBALS["USER"]->GetID(), "SA"));
} else {
CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true);
}
}
}
}
if (intval($log_id) > 0) {
$parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]);
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
if ($bSocNetLogRecordExists) {
$text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow);
//.........这里部分代码省略.........
示例13: array
<?php
/**
* @author Gennadiy Hatuntsev
* @package catalog.menu
*
* @var array $arParams
* @var array $arResult
* @var CDatabase $DB
*/
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
$arResult = array();
$iblockID = intval($arParams['IBLOCK_ID']);
$iblock = CIBlock::GetByID($iblockID)->Fetch();
if ($iblock) {
$sortField = isset($arParams["SORT_FIELD"]) && in_array($arParams["SORT_FIELD"], array("NAME", "SORT")) ? $arParams["SORT_FIELD"] : "NAME";
$sortOrder = isset($arParams["SORT_ORDER"]) && in_array($arParams["SORT_ORDER"], array("ASC", "DESC")) ? $arParams["SORT_ORDER"] : "ASC";
// Разделы первого уровня
$sort = array($sortField => $sortOrder);
$filter = array('IBLOCK_ID' => $iblockID, 'ACTIVE' => 'Y', 'DEPTH_LEVEL' => 1);
$result = CIBlockSection::GetList($sort, $filter);
while ($section = $result->GetNext()) {
$arResult[1][$section["ID"]] = $section;
}
// Разделы второго уровня
$sql = "\n SELECT T.*\n FROM `b_iblock_section` AS T\n JOIN `b_iblock_section` AS SUB\n ON T.IBLOCK_SECTION_ID = SUB.ID\n WHERE\n T.ACTIVE = 'Y' AND\n T.IBLOCK_ID = " . $iblockID . "\n ORDER BY\n SUB.LEFT_MARGIN, T." . $sortField . " " . $sortOrder . ", T.LEFT_MARGIN\n ";
$result = $DB->Query($sql);
while ($section = $result->GetNext()) {
$replace = array("#SITE_DIR#" => '', "#SECTION_ID#" => $section["ID"], "#SECTION_CODE#" => $section["CODE"]);
示例14: run
/**
* @param $id
* @param bool|false $forCache
* @return bool|string
*/
public static function run($id, $forCache = false)
{
$data = \CIBlock::GetByID($id)->Fetch();
if ($data) {
$code = $data['CODE'];
$name = $data['NAME'];
$isactive = $data['ACTIVE'] == 'Y';
$sort = $data['SORT'];
$description = (string) $data['DESCRIPTION'];
$descriptionType = $data['DESCRIPTION_TYPE'];
$className = $forCache ? \TAO::normalizeMnemocode($code) : \TAO::chunkCap($code);
unset($data['ID']);
unset($data['TIMESTAMP_X']);
unset($data['IBLOCK_TYPE_ID']);
unset($data['CODE']);
unset($data['NAME']);
unset($data['LANG_DIR']);
unset($data['SERVER_NAME']);
unset($data['LID']);
unset($data['ACTIVE']);
unset($data['SORT']);
unset($data['DESCRIPTION']);
unset($data['DESCRIPTION_TYPE']);
$defs = array('RSS_ACTIVE' => 'Y', 'RSS_TTL' => '24', 'RSS_FILE_ACTIVE' => 'N', 'RSS_YANDEX_ACTIVE' => 'N', 'INDEX_ELEMENT' => 'Y', 'INDEX_SECTION' => 'N', 'WORKFLOW' => 'Y', 'VERSION' => '1', 'BIZPROC' => 'N', 'SECTION_CHOOSER' => 'L', 'RIGHTS_MODE' => 'S', 'SECTION_PROPERTY' => 'N', 'PROPERTY_INDEX' => 'N');
foreach (array_keys($data) as $k) {
if (empty($data[$k])) {
unset($data[$k]);
}
if (isset($defs[$k]) && $defs[$k] == $data[$k]) {
unset($data[$k]);
}
}
$sites = '';
$res = \CIBlock::GetSite($id);
while ($row = $res->Fetch()) {
$sites .= $sites != '' ? ',' : '';
$sites .= "'" . $row['SITE_ID'] . "'";
}
unset($data['ELEMENTS_NAME']);
unset($data['ELEMENT_NAME']);
$sData = self::generateArrayExport($data, ' ');
$sDescription = self::generateSimpleStringFunctionText('description', $description, '');
$sDescriptionType = self::generateSimpleStringFunctionText('descriptionType', $descriptionType, 'text');
$sIsActive = self::generateSimpleStringFunctionText('isActive', $isactive, true);
$sSort = self::generateSimpleStringFunctionText('sort', $sort, '500');
$sSites = "\n\n public function sites()\n {\n return array({$sites});\n }";
$properties = array();
$result = \CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $id, 'CHECK_PERMISSIONS' => 'N'));
$defs = array('VERSION' => '1', 'FILTRABLE' => 'N', 'SEARCHABLE' => 'N', 'LIST_TYPE' => 'L', 'COL_COUNT' => '30', 'ROW_COUNT' => '1', 'MULTIPLE' => 'N', 'SORT' => '500', 'IS_REQUIRED' => 'N', 'WITH_DESCRIPTION' => 'N', 'MULTIPLE_CNT' => '5');
while ($row = $result->Fetch()) {
$code = trim($row['CODE']);
if ($code == '') {
$code = 'PROP_' . $row['ID'];
}
$pid = $row['ID'];
unset($row['ID']);
unset($row['TIMESTAMP_X']);
unset($row['IBLOCK_ID']);
unset($row['ACTIVE']);
unset($row['CODE']);
foreach (array_keys($row) as $k) {
if (empty($row[$k])) {
unset($row[$k]);
}
if (isset($defs[$k]) && $defs[$k] == $row[$k]) {
unset($row[$k]);
}
}
if ($row['PROPERTY_TYPE'] == 'L') {
$items = array();
$res = \CIBlockPropertyEnum::GetList(array(), array('PROPERTY_ID' => $pid, 'CHECK_PERMISSIONS' => 'N'));
while ($lrow = $res->Fetch()) {
$iid = $lrow['ID'];
$eid = $lrow['EXTERNAL_ID'];
unset($lrow['ID']);
unset($lrow['EXTERNAL_ID']);
unset($lrow['XML_ID']);
unset($lrow['TMP_ID']);
unset($lrow['PROPERTY_ID']);
unset($lrow['PROPERTY_NAME']);
unset($lrow['PROPERTY_CODE']);
unset($lrow['PROPERTY_SORT']);
if ($lrow['SORT'] == '500') {
unset($lrow['SORT']);
}
if ($lrow['DEF'] == 'N') {
unset($lrow['DEF']);
}
if (count($lrow) == 1 && isset($lrow['VALUE'])) {
$lrow = $lrow['VALUE'];
}
$items[$eid] = $lrow;
}
$row['ITEMS'] = $items;
}
//.........这里部分代码省略.........
示例15: prepareIBlockPropertyValue
default:
$arEventFields["PARAMS"] .= $f["NAME"] . ": " . $_REQUEST[$f['CODE']] . "\n";
$arIBlockFields["PROPERTY_VALUES"][$f['CODE']] = prepareIBlockPropertyValue($_REQUEST[$f["CODE"]], $f);
break;
}
break;
default:
break;
}
}
$el = new CIBlockElement();
if (!($result = $el->Add($arIBlockFields))) {
$arResult["ERROR_MESSAGE"][] = $el->LAST_ERROR;
} else {
if (($rsIBlock = CIBlockElement::GetIBlockByID($result)) !== FALSE) {
$dbIBlock = CIBlock::GetByID($rsIBlock);
if ($arIBlock = $dbIBlock->GetNext()) {
$rsIBlockType = $arIBlock["IBLOCK_TYPE_ID"];
$arEventFields["EDIT_LINK"] = "http://" . $_SERVER["HTTP_HOST"] . "/bitrix/admin/iblock_element_edit.php?IBLOCK_ID=" . $rsIBlock . "&type=" . $rsIBlockType . "&ID=" . $result . "&lang=ru&find_section_section=-1&WF=Y";
}
}
}
if (empty($arResult["ERROR_MESSAGE"])) {
if ($arParams["SEND_EMAIL"] == "Y") {
if (!empty($arParams["EVENT_MESSAGE_ID"])) {
foreach ($arParams["EVENT_MESSAGE_ID"] as $v) {
if (IntVal($v) > 0) {
CEvent::Send($arParams["EVENT_NAME"], SITE_ID, $arEventFields, "N", IntVal($v));
}
}
} else {