public static function GetProductInfo($intOfferID, $intIBlockID = 0) { $intOfferID = (int) $intOfferID; if ($intOfferID <= 0) { return false; } $intIBlockID = (int) $intIBlockID; if ($intIBlockID <= 0) { $intIBlockID = (int) CIBlockElement::GetIBlockByID($intOfferID); } if ($intIBlockID <= 0) { return false; } if (!isset(self::$arOfferCache[$intIBlockID])) { $arSkuInfo = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID); } else { $arSkuInfo = self::$arOfferCache[$intIBlockID]; } if (empty($arSkuInfo) || empty($arSkuInfo['SKU_PROPERTY_ID'])) { return false; } $rsItems = CIBlockElement::GetProperty($intIBlockID, $intOfferID, array(), array('ID' => $arSkuInfo['SKU_PROPERTY_ID'])); if ($arItem = $rsItems->Fetch()) { $arItem['VALUE'] = (int) $arItem['VALUE']; if ($arItem['VALUE'] > 0) { return array('ID' => $arItem['VALUE'], 'IBLOCK_ID' => $arSkuInfo['PRODUCT_IBLOCK_ID'], 'OFFER_IBLOCK_ID' => $intIBlockID, 'SKU_PROPERTY_ID' => $arSkuInfo['SKU_PROPERTY_ID']); } } return false; }
function GetByIDEx($ID, $boolAllValues = false) { global $DB, $USER; $boolAllValues = true == $boolAllValues ? true : false; $ID = intval($ID); if (0 >= $ID) { return false; } $arFilter = array("ID" => $ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y"); $dbIBlockElement = CIBlockElement::GetList(array(), $arFilter); if ($arIBlockElement = $dbIBlockElement->GetNext()) { if ($arIBlock = CIBlock::GetArrayByID($arIBlockElement["IBLOCK_ID"])) { $arIBlockElement["IBLOCK_ID"] = $arIBlock["ID"]; $arIBlockElement["IBLOCK_NAME"] = htmlspecialcharsbx($arIBlock["NAME"]); $arIBlockElement["~IBLOCK_NAME"] = $arIBlock["NAME"]; $arIBlockElement["PROPERTIES"] = false; $dbProps = CIBlockElement::GetProperty($arIBlock["ID"], $ID, "sort", "asc", array("ACTIVE" => "Y", "NON_EMPTY" => "Y")); if ($arProp = $dbProps->Fetch()) { $arAllProps = array(); do { $strID = strlen($arProp["CODE"]) > 0 ? $arProp["CODE"] : $arProp["ID"]; if (is_array($arProp["VALUE"])) { foreach ($arProp["VALUE"] as &$strOneValue) { $strOneValue = htmlspecialcharsbx($strOneValue); } if (isset($strOneValue)) { unset($strOneValue); } } else { $arProp["VALUE"] = htmlspecialcharsbx($arProp["VALUE"]); } if ($boolAllValues && 'Y' == $arProp['MULTIPLE']) { if (!isset($arAllProps[$strID])) { $arAllProps[$strID] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => array($arProp["VALUE"]), "VALUE_ENUM" => array(htmlspecialcharsbx($arProp["VALUE_ENUM"])), "VALUE_XML_ID" => array(htmlspecialcharsbx($arProp["VALUE_XML_ID"])), "DEFAULT_VALUE" => htmlspecialcharsbx($arProp["DEFAULT_VALUE"]), "SORT" => htmlspecialcharsbx($arProp["SORT"]), "MULTIPLE" => $arProp['MULTIPLE']); } else { $arAllProps[$strID]['VALUE'][] = $arProp["VALUE"]; $arAllProps[$strID]['VALUE_ENUM'][] = htmlspecialcharsbx($arProp["VALUE_ENUM"]); $arAllProps[$strID]['VALUE_XML_ID'][] = htmlspecialcharsbx($arProp["VALUE_XML_ID"]); } } else { $arAllProps[$strID] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => $arProp["VALUE"], "VALUE_ENUM" => htmlspecialcharsbx($arProp["VALUE_ENUM"]), "VALUE_XML_ID" => htmlspecialcharsbx($arProp["VALUE_XML_ID"]), "DEFAULT_VALUE" => htmlspecialcharsbx($arProp["DEFAULT_VALUE"]), "SORT" => htmlspecialcharsbx($arProp["SORT"]), "MULTIPLE" => $arProp['MULTIPLE']); } } while ($arProp = $dbProps->Fetch()); $arIBlockElement["PROPERTIES"] = $arAllProps; } // bugfix: 2007-07-31 by Sigurd $arIBlockElement["PRODUCT"] = CCatalogProduct::GetByID(intval($ID)); $dbPrices = CPrice::GetList(array("SORT" => "ASC"), array("PRODUCT_ID" => $ID)); if ($arPrices = $dbPrices->Fetch()) { $arAllPrices = array(); do { $arAllPrices[$arPrices["CATALOG_GROUP_ID"]] = array("EXTRA_ID" => intval($arPrices["EXTRA_ID"]), "PRICE" => doubleval($arPrices["PRICE"]), "CURRENCY" => htmlspecialcharsbx($arPrices["CURRENCY"])); } while ($arPrices = $dbPrices->Fetch()); $arIBlockElement["PRICES"] = $arAllPrices; } return $arIBlockElement; } } return false; }
public function GetProductInfo($intOfferID, $intIBlockID = 0) { $intOfferID = intval($intOfferID); if (0 >= $intOfferID) { return false; } $intIBlockID = intval($intIBlockID); if (0 >= $intIBlockID) { $rsItems = CIBlockElement::GetList(array(), array("ID" => $intOfferID, "SHOW_HISTORY" => "Y"), false, false, array('ID', 'IBLOCK_ID')); if ($arItem = $rsItems->Fetch()) { $intIBlockID = intval($arItem['IBLOCK_ID']); } } if (0 >= $intIBlockID) { return false; } $arSkuInfo = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID); if (empty($arSkuInfo) || empty($arSkuInfo['SKU_PROPERTY_ID'])) { return false; } $rsItems = CIBlockElement::GetProperty($intIBlockID, $intOfferID, array(), array('ID' => $arSkuInfo['SKU_PROPERTY_ID'])); if ($arItem = $rsItems->Fetch()) { $arItem['VALUE'] = intval($arItem['VALUE']); if (0 < $arItem['VALUE']) { return array('ID' => $arItem['VALUE'], 'IBLOCK_ID' => $arSkuInfo['PRODUCT_IBLOCK_ID']); } } return false; }
public static function Add($arFields) { $dbRes = CIBlockElement::GetProperty($arFields['IBLOCK_ID'], $arFields['ID'], array(), array('CODE' => 'OWSHIDDENVERSION')); if ($arRes = $dbRes->Fetch()) { return $GLOBALS['DB']->Insert('b_intranet_sharepoint_log', array('IBLOCK_ID' => "'" . intval($arFields['IBLOCK_ID']) . "'", 'ELEMENT_ID' => "'" . intval($arFields['ID']) . "'", 'VERSION' => "'" . intval($arRes['VALUE']) . "'"), "", false, "", true); } }
public function Execute() { if (!CModule::IncludeModule("forum")) { return CBPActivityExecutionStatus::Closed; } if (!CModule::IncludeModule("iblock")) { return CBPActivityExecutionStatus::Closed; } $forumId = intval($this->ForumId); if ($forumId <= 0) { return CBPActivityExecutionStatus::Closed; } $rootActivity = $this->GetRootActivity(); $documentId = $rootActivity->GetDocumentId(); $iblockId = $this->IBlockId; $dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID")); $arResult = $dbResult->Fetch(); if (!$arResult) { $obProperty = new CIBlockProperty(); $obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum topic", "CODE" => "FORUM_TOPIC_ID")); $obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum message count", "CODE" => "FORUM_MESSAGE_CNT")); $dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID")); $arResult = $dbResult->Fetch(); } $forumTopicId = intval($arResult["VALUE"]); $arForumUserTmp = $this->ForumUser; $arForumUser = CBPHelper::ExtractUsers($arForumUserTmp, $documentId, true); $forumUserId = 1; $forumUserName = "******"; if ($arForumUser != null) { $forumUserId = $arForumUser; $dbResult = CUser::GetByID($forumUserId); if ($arResult = $dbResult->Fetch()) { $forumUserName = CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), $arResult, true); } } $newTopic = "N"; if ($forumTopicId <= 0) { $documentService = $this->workflow->GetService("DocumentService"); $document = $documentService->GetDocument($documentId); $newTopic = "Y"; $arFields = array("TITLE" => $document["NAME"], "FORUM_ID" => $forumId, "USER_START_ID" => $forumUserId, "USER_START_NAME" => $forumUserName, "LAST_POSTER_NAME" => $forumUserName, "APPROVED" => "Y"); $forumTopicId = CForumTopic::Add($arFields); CIBlockElement::SetPropertyValues($documentId[2], $iblockId, $forumTopicId, "FORUM_TOPIC_ID"); } $arFields = array("POST_MESSAGE" => $this->ForumPostMessage, "AUTHOR_ID" => $forumUserId, "AUTHOR_NAME" => $forumUserName, "FORUM_ID" => $forumId, "TOPIC_ID" => $forumTopicId, "APPROVED" => "Y", "NEW_TOPIC" => $newTopic, "PARAM2" => $documentId[2]); $forumMessageId = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N")); return CBPActivityExecutionStatus::Closed; }
public static function BeforeIndexHandler($arFields) { if ($arFields['MODULE_ID'] == 'iblock' && $arFields['PARAM2'] == NEWS_ID && !empty($arFields['ITEM_ID']) && \Bitrix\Main\Loader::includeModule('iblock')) { $db = CIBlockElement::GetProperty($arFields['PARAM2'], $arFields['ITEM_ID'], array(), array('CODE' => 'TAGS')); while ($row = $db->Fetch()) { if (is_array($row['VALUE'])) { foreach ($row['VALUE'] as $val) { $arFields['BODY'] .= 'tag_search_' . $val; } } else { $arFields['BODY'] .= 'tag_search_' . $row['VALUE']; } } } return $arFields; }
static function GetProductSkuProps($ID, $IBLOCK_ID = '') { $arSkuProps = array(); if (CModule::IncludeModule('iblock') && CModule::IncludeModule('catalog')) { $res = CIBlockElement::GetList( array(), array( "ID" => $ID, "ACTIVE" => "Y", ), false, false, array( "ID", "IBLOCK_ID", ) ); $arElement = $res->Fetch(); if ($arElement) { $IBLOCK_ID = $arElement["IBLOCK_ID"]; $arParent = CCatalogSku::GetProductInfo($ID); if ($arParent) { $rsOffers = CIBlockElement::GetProperty( $IBLOCK_ID, $ID ); while ($arOffer = $rsOffers->GetNext()) { if ($arOffer["XML_ID"] != "CML2_LINK") { if ($arOffer["PROPERTY_TYPE"] == "L") $arSkuProps[$arOffer["NAME"]] = $arOffer["VALUE_ENUM"]; else $arSkuProps[$arOffer["NAME"]] = $arOffer["VALUE"]; } } } } } return $arSkuProps; }
function BeforeIndexHandler($arFields) { if (!CModule::IncludeModule("iblock")) { return $arFields; } if ($arFields["MODULE_ID"] == "iblock") { if ($arFields["PARAM2"] == IBLOCK_ID_CATALOG) { $db_props = CIBlockElement::GetProperty($arFields["PARAM2"], $arFields["ITEM_ID"], array("sort" => "asc"), array("CODE" => "CML2_ARTICLE")); if ($ar_props = $db_props->Fetch()) { $arFields["TITLE"] .= " @" . $ar_props["VALUE"]; } $db_props2 = CIBlockElement::GetProperty($arFields["PARAM2"], $arFields["ITEM_ID"], array("sort" => "asc"), array("CODE" => "KOD2")); if ($ar_props2 = $db_props2->Fetch()) { $arFields["TITLE"] .= " @" . $ar_props2["VALUE"]; } } } return $arFields; }
function __construct($id) { $arSelect = array("ID", "NAME", "DATE_ACTIVE_FROM", "DATE_ACTIVE_TO", "PREVIEW_TEXT", "PREVIEW_PICTURE", "PROPERTY_STEP", "PROPERTY_START_RATE", "PROPERTY_RATE_HISTORY", "PROPERTY_WINNER", "DETAIL_PAGE_URL"); $arFilter = array("IBLOCK_TYPE" => self::getIBType(), "IBLOCK_CODE" => self::getIBPointsTable(), "ACTIVE" => "Y", "ID" => $id); $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); if ($arRes = $res->GetNext()) { //print_r($arFilter); $img = CFile::GetFileArray($arRes["PREVIEW_PICTURE"]); $this->id = $arRes["ID"]; $this->name = $arRes["NAME"]; $this->rate_history = array_filter(explode(";", $arRes["PROPERTY_RATE_HISTORY_VALUE"])); $this->start_rate = $arRes["PROPERTY_START_RATE_VALUE"]; $this->step = $arRes["PROPERTY_STEP_VALUE"]; $this->description = $arRes["PREVIEW_TEXT"]; $this->picture = $img["SRC"]; $this->start_time = $arRes["DATE_ACTIVE_FROM"]; $this->finish_time = $arRes["DATE_ACTIVE_TO"]; $this->current_rate = $this->currentRate(); $this->winner = intval($arRes["PROPERTY_WINNER_VALUE"]); $this->detail_page = $arRes["DETAIL_PAGE_URL"]; if ($this->winner <= 0) { $finish = MakeTimeStamp($this->finish_time, "DD.MM.YYYY HH:MI:SS"); $now = time(); if ($now > $finish) { $key = 778; $seg = sem_get($key); sem_acquire($seg); $log = new CLoger("construct"); $ib_code = getIbIDByCode(self::getIBPointsTable()); $win_prop = CIBlockElement::GetProperty($ib_code, $id, array("sort" => "asc"), array("CODE" => "WINNER"))->GetNext(); $log->Add("win_prop", $win_prop); if ($win_prop["VALUE"] <= 0) { //sleep(10); $win_id = $this->winner(); CIBlockElement::SetPropertyValues($id, $ib_code, $win_id, "WINNER"); } sem_release($seg); } } } }
</noindex> <?php if ($arParams["USE_CATEGORIES"] == "Y" && $ElementID) { global $arCategoryFilter; $obCache = new CPHPCache(); $strCacheID = $componentPath . LANG . $arParams["IBLOCK_ID"] . $ElementID . $arParams["CATEGORY_CODE"]; if (($tzOffset = CTimeZone::GetOffset()) != 0) { $strCacheID .= "_" . $tzOffset; } if ($arParams["CACHE_TYPE"] == "N" || $arParams["CACHE_TYPE"] == "A" && COption::GetOptionString("main", "component_cache_on", "Y") == "N") { $CACHE_TIME = 0; } else { $CACHE_TIME = $arParams["CACHE_TIME"]; } if ($obCache->StartDataCache($CACHE_TIME, $strCacheID, $componentPath)) { $rsProperties = CIBlockElement::GetProperty($arParams["IBLOCK_ID"], $ElementID, "sort", "asc", array("ACTIVE" => "Y", "CODE" => $arParams["CATEGORY_CODE"])); $arCategoryFilter = array(); while ($arProperty = $rsProperties->Fetch()) { if (is_array($arProperty["VALUE"]) && count($arProperty["VALUE"]) > 0) { foreach ($arProperty["VALUE"] as $value) { $arCategoryFilter[$value] = true; } } elseif (!is_array($arProperty["VALUE"]) && strlen($arProperty["VALUE"]) > 0) { $arCategoryFilter[$arProperty["VALUE"]] = true; } } $obCache->EndDataCache($arCategoryFilter); } else { $arCategoryFilter = $obCache->GetVars(); } if (count($arCategoryFilter) > 0) {
function UpdateOWSVersion($IBLOCK_ID, $ID, $value = null) { if (!defined('INTR_WS_OUTLOOK_UPDATE')) { if (null === $value) { $dbRes = CIBlockElement::GetProperty($IBLOCK_ID, $ID, 'sort', 'asc', array('CODE' => 'VERSION')); $arProperty = $dbRes->Fetch(); if ($arProperty) { $value = intval($arProperty['VALUE']); if (!$value) { $value = 1; } $value++; } } if (null !== $value) { CIBlockElement::SetPropertyValues($ID, $IBLOCK_ID, $value, 'VERSION'); } } }
/** * @param bool|array $arOrder * @param array $arFilter * @return array */ function GetProperties($arOrder = false, $arFilter = array()) { if ($arOrder === false) { $arOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc"); } if (count($arFilter) == 0 && is_array($this->props)) { $arAllProps = array(); foreach ($this->props as $arProp) { if (strlen(trim($arProp["CODE"])) > 0) { $PIND = $arProp["CODE"]; } else { $PIND = $arProp["ID"]; } $arProp["VALUE"] = $this->fields["PROPERTY_" . $arProp["ID"]]; $arProp["DESCRIPTION"] = $this->fields["DESCRIPTION_" . $arProp["ID"]]; if ($arProp["MULTIPLE"] == "N") { if ($arProp["PROPERTY_TYPE"] == "L") { $arProp["VALUE_ENUM_ID"] = $val = $arProp["VALUE"]; $arEnum = CIBlockPropertyEnum::GetByID($val); if ($arEnum !== false) { $arProp["~VALUE"] = $arEnum["VALUE"]; if (is_array($arProp["VALUE"]) || preg_match("/[;&<>\"]/", $arProp["VALUE"])) { $arProp["VALUE"] = htmlspecialcharsex($arEnum["VALUE"]); } else { $arProp["VALUE"] = $arEnum["VALUE"]; } $arProp["VALUE_ENUM"] = $arProp["VALUE"]; $arProp["VALUE_XML_ID"] = htmlspecialcharsex($arEnum["XML_ID"]); $arProp["VALUE_SORT"] = $arEnum["SORT"]; } else { $arProp["~VALUE"] = ""; $arProp["VALUE"] = ""; } } elseif (is_array($arProp["VALUE"]) || strlen($arProp["VALUE"])) { if ($arProp["PROPERTY_TYPE"] == "N") { $arProp["VALUE"] = htmlspecialcharsex(CIBlock::NumberFormat($arProp["VALUE"])); } $arProp["~VALUE"] = $this->fields["~PROPERTY_" . $arProp["ID"]]; $arProp["~DESCRIPTION"] = $this->fields["~DESCRIPTION_" . $arProp["ID"]]; } else { $arProp["VALUE"] = $arProp["~VALUE"] = ""; $arProp["DESCRIPTION"] = $arProp["~DESCRIPTION"] = ""; } } else { $arList = $arProp["VALUE"]; $arListTilda = $this->fields["~PROPERTY_" . $arProp["ID"]]; if ($arProp["PROPERTY_TYPE"] == "L") { $arProp["~VALUE"] = $arProp["VALUE"] = $arProp["VALUE_ENUM_ID"] = false; $arProp["VALUE_XML_ID"] = false; foreach ($arList as $key => $val) { if (strlen($val) > 0) { $arEnum = CIBlockPropertyEnum::GetByID($key); if ($arEnum !== false) { $xml_id = htmlspecialcharsex($arEnum["XML_ID"]); $sort = $arEnum["SORT"]; } else { $xml_id = false; $sort = false; } if (is_array($arProp["VALUE"])) { $arProp["VALUE_ENUM_ID"][] = $key; $arProp["~VALUE"][] = $val; if (is_array($val) || preg_match("/[;&<>\"]/", $val)) { $arProp["VALUE"][] = htmlspecialcharsex($val); } else { $arProp["VALUE"][] = $val; } $arProp["VALUE_XML_ID"][] = $xml_id; $arProp["VALUE_SORT"][] = $sort; } else { $arProp["VALUE_ENUM_ID"] = array($key); $arProp["~VALUE"] = array($val); if (is_array($val) || preg_match("/[;&<>\"]/", $val)) { $arProp["VALUE"] = array(htmlspecialcharsex($val)); } else { $arProp["VALUE"] = array($val); } $arProp["VALUE_XML_ID"] = array($xml_id); $arProp["VALUE_SORT"] = array($sort); } } } $arProp["VALUE_ENUM"] = $arProp["VALUE"]; } else { $arDesc = $arProp["DESCRIPTION"]; $arDescTilda = $this->fields["~DESCRIPTION_" . $arProp["ID"]]; $arProp["~VALUE"] = $arProp["VALUE"] = false; $arProp["~DESCRIPTION"] = $arProp["DESCRIPTION"] = false; foreach ($arList as $key => $val) { if (is_array($val) || strlen($val) > 0) { if (is_array($arProp["VALUE"])) { $arProp["~VALUE"][] = $arListTilda[$key]; if ($arProp["PROPERTY_TYPE"] == "N") { $val = htmlspecialcharsex(CIBlock::NumberFormat($val)); } $arProp["VALUE"][] = $val; $arProp["~DESCRIPTION"][] = $arDescTilda[$key]; $arProp["DESCRIPTION"][] = $arDesc[$key]; } else { $arProp["~VALUE"] = array($arListTilda[$key]); if ($arProp["PROPERTY_TYPE"] == "N") { $val = htmlspecialcharsex(CIBlock::NumberFormat($val)); } $arProp["VALUE"] = array($val); $arProp["~DESCRIPTION"] = array($arDescTilda[$key]); $arProp["DESCRIPTION"] = array($arDesc[$key]); } } } } } $arAllProps[$PIND] = $arProp; } return $arAllProps; } if (array_key_exists("ID", $arFilter) && !is_numeric(substr($arFilter["ID"], 0, 1))) { $arFilter["CODE"] = $arFilter["ID"]; unset($arFilter["ID"]); } if (!array_key_exists("ACTIVE", $arFilter)) { $arFilter["ACTIVE"] = "Y"; } $props = CIBlockElement::GetProperty($this->fields["IBLOCK_ID"], $this->fields["ID"], $arOrder, $arFilter); $arAllProps = array(); while ($arProp = $props->Fetch()) { if (strlen(trim($arProp["CODE"])) > 0) { $PIND = $arProp["CODE"]; } else { $PIND = $arProp["ID"]; } if ($arProp["PROPERTY_TYPE"] == "L") { $arProp["VALUE_ENUM_ID"] = $arProp["VALUE"]; $arProp["VALUE"] = $arProp["VALUE_ENUM"]; } if (is_array($arProp["VALUE"]) || strlen($arProp["VALUE"]) > 0) { $arProp["~VALUE"] = $arProp["VALUE"]; if (is_array($arProp["VALUE"]) || preg_match("/[;&<>\"]/", $arProp["VALUE"])) { $arProp["VALUE"] = htmlspecialcharsex($arProp["VALUE"]); } $arProp["~DESCRIPTION"] = $arProp["DESCRIPTION"]; if (preg_match("/[;&<>\"]/", $arProp["DESCRIPTION"])) { $arProp["DESCRIPTION"] = htmlspecialcharsex($arProp["DESCRIPTION"]); } } else { $arProp["VALUE"] = $arProp["~VALUE"] = ""; $arProp["DESCRIPTION"] = $arProp["~DESCRIPTION"] = ""; } if ($arProp["MULTIPLE"] == "Y") { if (array_key_exists($PIND, $arAllProps)) { $arTemp =& $arAllProps[$PIND]; if ($arProp["VALUE"] !== "") { if (is_array($arTemp["VALUE"])) { $arTemp["VALUE"][] = $arProp["VALUE"]; $arTemp["~VALUE"][] = $arProp["~VALUE"]; $arTemp["DESCRIPTION"][] = $arProp["DESCRIPTION"]; $arTemp["~DESCRIPTION"][] = $arProp["~DESCRIPTION"]; $arTemp["PROPERTY_VALUE_ID"][] = $arProp["PROPERTY_VALUE_ID"]; if ($arProp["PROPERTY_TYPE"] == "L") { $arTemp["VALUE_ENUM_ID"][] = $arProp["VALUE_ENUM_ID"]; $arTemp["VALUE_ENUM"][] = $arProp["VALUE_ENUM"]; $arTemp["VALUE_XML_ID"][] = $arProp["VALUE_XML_ID"]; //$arTemp["VALUE_SORT"][] = $arProp["VALUE_SORT"]; } } else { $arTemp["VALUE"] = array($arProp["VALUE"]); $arTemp["~VALUE"] = array($arProp["~VALUE"]); $arTemp["DESCRIPTION"] = array($arProp["DESCRIPTION"]); $arTemp["~DESCRIPTION"] = array($arProp["~DESCRIPTION"]); $arTemp["PROPERTY_VALUE_ID"] = array($arProp["PROPERTY_VALUE_ID"]); if ($arProp["PROPERTY_TYPE"] == "L") { $arTemp["VALUE_ENUM_ID"] = array($arProp["VALUE_ENUM_ID"]); $arTemp["VALUE_ENUM"] = array($arProp["VALUE_ENUM"]); $arTemp["VALUE_XML_ID"] = array($arProp["VALUE_XML_ID"]); $arTemp["VALUE_SORT"] = array($arProp["VALUE_SORT"]); } } } } else { $arProp["~NAME"] = $arProp["NAME"]; if (preg_match("/[;&<>\"]/", $arProp["NAME"])) { $arProp["NAME"] = htmlspecialcharsex($arProp["NAME"]); } $arProp["~DEFAULT_VALUE"] = $arProp["DEFAULT_VALUE"]; if (is_array($arProp["DEFAULT_VALUE"]) || preg_match("/[;&<>\"]/", $arProp["DEFAULT_VALUE"])) { $arProp["DEFAULT_VALUE"] = htmlspecialcharsex($arProp["DEFAULT_VALUE"]); } if ($arProp["VALUE"] !== "") { $arProp["VALUE"] = array($arProp["VALUE"]); $arProp["~VALUE"] = array($arProp["~VALUE"]); $arProp["DESCRIPTION"] = array($arProp["DESCRIPTION"]); $arProp["~DESCRIPTION"] = array($arProp["~DESCRIPTION"]); $arProp["PROPERTY_VALUE_ID"] = array($arProp["PROPERTY_VALUE_ID"]); if ($arProp["PROPERTY_TYPE"] == "L") { $arProp["VALUE_ENUM_ID"] = array($arProp["VALUE_ENUM_ID"]); $arProp["VALUE_ENUM"] = array($arProp["VALUE_ENUM"]); $arProp["VALUE_XML_ID"] = array($arProp["VALUE_XML_ID"]); $arProp["VALUE_SORT"] = array($arProp["VALUE_SORT"]); } } else { $arProp["VALUE"] = false; $arProp["~VALUE"] = false; $arProp["DESCRIPTION"] = false; $arProp["~DESCRIPTION"] = false; $arProp["PROPERTY_VALUE_ID"] = false; if ($arProp["PROPERTY_TYPE"] == "L") { $arProp["VALUE_ENUM_ID"] = false; $arProp["VALUE_ENUM"] = false; $arProp["VALUE_XML_ID"] = false; $arProp["VALUE_SORT"] = false; } } $arAllProps[$PIND] = $arProp; } } else { $arProp["~NAME"] = $arProp["NAME"]; if (preg_match("/[;&<>\"]/", $arProp["NAME"])) { $arProp["NAME"] = htmlspecialcharsex($arProp["NAME"]); } $arProp["~DEFAULT_VALUE"] = $arProp["DEFAULT_VALUE"]; if (is_array($arProp["DEFAULT_VALUE"]) || preg_match("/[;&<>\"]/", $arProp["DEFAULT_VALUE"])) { $arProp["DEFAULT_VALUE"] = htmlspecialcharsex($arProp["DEFAULT_VALUE"]); } $arAllProps[$PIND] = $arProp; } } return $arAllProps; }
else { $row->AddCalendarField("DATE_ACTIVE_FROM", false); $row->AddCalendarField("DATE_ACTIVE_TO", false); $row->AddViewField("WF_STATUS_ID", htmlspecialcharsex($arWFStatusAll[$arRes['WF_STATUS_ID']])); if (array_key_exists("TAGS", $arVisibleColumnsMap)) $row->AddViewField("TAGS", $f_TAGS); } } $row->AddViewField("ID", '<a href="'.($f_TYPE=="S"?$sec_edit_url:$el_edit_url).'" title="'.GetMessage("IBLIST_A_EDIT").'">'.$f_ID.'</a>'); $arProperties = array(); if($f_TYPE=="E" && count($arSelectedProps)>0) { $rsProperties = CIBlockElement::GetProperty($IBLOCK_ID, $arRes["ID"]); while($ar = $rsProperties->GetNext()) { if(!array_key_exists($ar["ID"], $arProperties)) $arProperties[$ar["ID"]] = array(); $arProperties[$ar["ID"]][$ar["PROPERTY_VALUE_ID"]] = $ar; } foreach($arSelectedProps as $aProp) { $arViewHTML = array(); $arEditHTML = array(); if(strlen($aProp["USER_TYPE"])>0) $arUserType = CIBlockProperty::GetUserType($aProp["USER_TYPE"]); else $arUserType = array();
function Update($ID, $arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false, $bCheckDiskQuota = true) { global $DB, $USER; $ID = intval($ID); $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID")); if (!($ar_element = $db_element->Fetch())) { return false; } $arIBlock = CIBlock::GetArrayByID($ar_element["IBLOCK_ID"]); $bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow"); $ar_wf_element = $ar_element; $LAST_ID = 0; if ($bWorkFlow) { $LAST_ID = CIBlockElement::WF_GetLast($ID); if ($LAST_ID != $ID) { $db_element = CIBlockElement::GetByID($LAST_ID); if (!($ar_wf_element = $db_element->Fetch())) { return false; } } $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (!array_key_exists("PROPERTY_VALUES", $arFields) || !is_array($arFields["PROPERTY_VALUES"])) { $arFields["PROPERTY_VALUES"] = array(); } $bFieldProps = array(); foreach ($arFields["PROPERTY_VALUES"] as $k => $v) { $bFieldProps[$k] = true; } $arFieldProps =& $arFields['PROPERTY_VALUES']; $props = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_wf_element["ID"]); while ($arProp = $props->Fetch()) { $pr_val_id = $arProp['PROPERTY_VALUE_ID']; if ($arProp['PROPERTY_TYPE'] == 'F' && strlen($pr_val_id) > 0) { if (strlen($arProp["CODE"]) > 0 && is_set($arFieldProps, $arProp["CODE"])) { $pr_id = $arProp["CODE"]; } else { $pr_id = $arProp['ID']; } if (array_key_exists($pr_id, $arFieldProps) && array_key_exists($pr_val_id, $arFieldProps[$pr_id]) && is_array($arFieldProps[$pr_id][$pr_val_id])) { $new_value = $arFieldProps[$pr_id][$pr_val_id]; if (strlen($new_value['name']) <= 0 && $new_value['del'] != "Y" && strlen($new_value['VALUE']['name']) <= 0 && $new_value['VALUE']['del'] != "Y") { if (array_key_exists('DESCRIPTION', $new_value) && $new_value['DESCRIPTION'] != $arProp['DESCRIPTION']) { $p = array("VALUE" => CFile::MakeFileArray($arProp['VALUE'])); $p["DESCRIPTION"] = $new_value["DESCRIPTION"]; $p["MODULE_ID"] = "iblock"; $arFieldProps[$pr_id][$pr_val_id] = $p; } elseif ($arProp['VALUE'] > 0) { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } else { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } continue; } if (strlen($pr_val_id) <= 0 || array_key_exists($arProp["ID"], $bFieldProps) || strlen($arProp["CODE"]) > 0 && array_key_exists($arProp["CODE"], $bFieldProps)) { continue; } $arFieldProps[$arProp["ID"]][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } if ($ar_wf_element["IN_SECTIONS"] == "Y") { $ar_wf_element["IBLOCK_SECTION"] = array(); $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $ar_wf_element["IBLOCK_SECTION"][] = $arSection["ID"]; } } unset($ar_wf_element["DATE_ACTIVE_FROM"]); unset($ar_wf_element["DATE_ACTIVE_TO"]); unset($ar_wf_element["EXTERNAL_ID"]); unset($ar_wf_element["TIMESTAMP_X"]); unset($ar_wf_element["ID"]); $arFields = $arFields + $ar_wf_element; } $arFields["WF"] = $bWorkFlow ? "Y" : "N"; $bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc"); if (array_key_exists("BP_PUBLISHED", $arFields)) { if ($bBizProc) { if ($arFields["BP_PUBLISHED"] == "Y") { $arFields["WF_STATUS_ID"] = 1; $arFields["WF_NEW"] = false; } else { $arFields["WF_STATUS_ID"] = 2; $arFields["WF_NEW"] = "Y"; $arFields["BP_PUBLISHED"] = "N"; } } else { $arFields["WF_NEW"] = false; unset($arFields["BP_PUBLISHED"]); } } else { $arFields["WF_NEW"] = false; } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") { $arFields["PREVIEW_TEXT_TYPE"] = "text"; } if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") { $arFields["DETAIL_TEXT_TYPE"] = "text"; } $strWarning = ""; if ($bResizePictures) { $arDef = $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]; if ($arDef["DELETE_WITH_DETAIL"] === "Y" && $arFields["DETAIL_PICTURE"]["del"] === "Y") { $arFields["PREVIEW_PICTURE"]["del"] = "Y"; } if ($arDef["FROM_DETAIL"] === "Y" && ($arFields["PREVIEW_PICTURE"]["size"] <= 0 || $arDef["UPDATE_WITH_DETAIL"] === "Y") && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0) { if ($arFields["PREVIEW_PICTURE"]["del"] !== "Y" && $arDef["UPDATE_WITH_DETAIL"] !== "Y") { $rsElement = CIBlockElement::GetList(array("ID" => "DESC"), array("ID" => $ar_wf_element["ID"], "IBLOCK_ID" => $ar_wf_element["IBLOCK_ID"], "SHOW_HISTORY" => "Y"), false, false, array("ID", "PREVIEW_PICTURE")); $arOldElement = $rsElement->Fetch(); } else { $arOldElement = false; } if (!$arOldElement || !$arOldElement["PREVIEW_PICTURE"]) { $arNewPreview = $arFields["DETAIL_PICTURE"]; $arNewPreview["COPY_FILE"] = "Y"; $arNewPreview["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPreview; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["size"] > 0 && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["PREVIEW_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["PREVIEW_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } $arDef = $arIBlock["FIELDS"]["DETAIL_PICTURE"]["DEFAULT_VALUE"]; if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arFields["DETAIL_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["DETAIL_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } } $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($ar_element["IBLOCK_ID"], $ar_element["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0 && !is_set($arFields["PREVIEW_PICTURE"], "description")) { unset($arFields["PREVIEW_PICTURE"]); } else { $arFields["PREVIEW_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"]["old_file"] = $ar_wf_element["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_PREVIEW_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["PREVIEW_PICTURE"]); } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0 && !is_set($arFields["DETAIL_PICTURE"], "description")) { unset($arFields["DETAIL_PICTURE"]); } else { $arFields["DETAIL_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"]["old_file"] = $ar_wf_element["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_DETAIL_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["DETAIL_PICTURE"]); } } if (is_set($arFields, "DATE_ACTIVE_FROM")) { $arFields["ACTIVE_FROM"] = $arFields["DATE_ACTIVE_FROM"]; } if (is_set($arFields, "DATE_ACTIVE_TO")) { $arFields["ACTIVE_TO"] = $arFields["DATE_ACTIVE_TO"]; } if (is_set($arFields, "EXTERNAL_ID")) { $arFields["XML_ID"] = $arFields["EXTERNAL_ID"]; } $PREVIEW_tmp = is_set($arFields, "PREVIEW_TEXT") ? $arFields["PREVIEW_TEXT"] : $ar_wf_element["PREVIEW_TEXT"]; $PREVIEW_TYPE_tmp = is_set($arFields, "PREVIEW_TEXT_TYPE") ? $arFields["PREVIEW_TEXT_TYPE"] : $ar_wf_element["PREVIEW_TEXT_TYPE"]; $DETAIL_tmp = is_set($arFields, "DETAIL_TEXT") ? $arFields["DETAIL_TEXT"] : $ar_wf_element["DETAIL_TEXT"]; $DETAIL_TYPE_tmp = is_set($arFields, "DETAIL_TEXT_TYPE") ? $arFields["DETAIL_TEXT_TYPE"] : $ar_wf_element["DETAIL_TEXT_TYPE"]; $arFields["SEARCHABLE_CONTENT"] = ToUpper((is_set($arFields, "NAME") ? $arFields["NAME"] : $ar_wf_element["NAME"]) . "\r\n" . ($PREVIEW_TYPE_tmp == "html" ? HTMLToTxt($PREVIEW_tmp) : $PREVIEW_tmp) . "\r\n" . ($DETAIL_TYPE_tmp == "html" ? HTMLToTxt($DETAIL_tmp) : $DETAIL_tmp)); if (is_set($arFields["IBLOCK_SECTION_ID"]) && !is_set($arFields, "IBLOCK_SECTION")) { $arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]); } $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; if (!$this->CheckFields($arFields, $ID, $bCheckDiskQuota) || strlen($strWarning)) { $this->LAST_ERROR .= $strWarning; $Result = false; $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } else { unset($arFields["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields)) { $SAVED_PREVIEW_PICTURE = $arFields["PREVIEW_PICTURE"]; } else { $SAVED_PREVIEW_PICTURE = false; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $SAVED_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; } else { $SAVED_DETAIL_PICTURE = false; } // edit was done in workflow mode if ($bWorkFlow) { $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (array_key_exists("PREVIEW_PICTURE", $arFields)) { if (is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["PREVIEW_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["PREVIEW_PICTURE"]); if ($arFields["PREVIEW_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["PREVIEW_PICTURE"]); $arNewFile["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"] = $arNewFile; } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { //File was not changed at all $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { unset($arFields["PREVIEW_PICTURE"]["old_file"]); } } } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { if (is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["DETAIL_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["DETAIL_PICTURE"]); if ($arFields["DETAIL_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["DETAIL_PICTURE"]); $arNewFile["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"] = $arNewFile; } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { //File was not changed at all $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { unset($arFields["DETAIL_PICTURE"]["old_file"]); } } } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } $NID = $this->Add($arFields); if ($NID > 0) { if ($arFields["WF_STATUS_ID"] == 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE ID=" . $ID); $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE WF_PARENT_ELEMENT_ID=" . $ID); $ar_wf_element["WF_NEW"] = false; } if ($this->bWF_SetMove) { CIBlockElement::WF_SetMove($NID, $LAST_ID); } if ($ar_element["WF_STATUS_ID"] != 1 && $ar_wf_element["WF_STATUS_ID"] != $arFields["WF_STATUS_ID"] && $arFields["WF_STATUS_ID"] != 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_STATUS_ID=" . $arFields["WF_STATUS_ID"] . " WHERE ID=" . $ID); } } //element was not published, so keep original if (is_set($arFields, "WF_STATUS_ID") && $arFields["WF_STATUS_ID"] != 1 && $ar_element["WF_STATUS_ID"] == 1 || !is_set($arFields, "WF_STATUS_ID") && $ar_wf_element["WF_STATUS_ID"] != 1) { CIBlockElement::WF_CleanUpHistoryCopies($ID); return true; } $arFields['WF_PARENT_ELEMENT_ID'] = false; $rs = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = " . $NID); $ar_new_element = $rs->Fetch(); } else { $ar_new_element = false; } if ($ar_new_element) { if (!intval($ar_new_element["PREVIEW_PICTURE"])) { $arFields["PREVIEW_PICTURE"] = false; } else { $arFields["PREVIEW_PICTURE"] = $ar_new_element["PREVIEW_PICTURE"]; } if (!intval($ar_new_element["DETAIL_PICTURE"])) { $arFields["DETAIL_PICTURE"] = false; } else { $arFields["DETAIL_PICTURE"] = $ar_new_element["DETAIL_PICTURE"]; } if (is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { $i = 0; $db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F")); while ($arProp = $db_prop->Fetch()) { $i++; unset($arFields["PROPERTY_VALUES"][$arProp["CODE"]]); unset($arFields["PROPERTY_VALUES"][$arProp["ID"]]); $arFields["PROPERTY_VALUES"][$arProp["ID"]] = array(); } if ($i > 0) { //Delete previous files $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $ID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => array("del" => "Y"), "DESCRIPTION" => false); } //Add copy from history $arDup = array(); //This is cure for files duplication bug (just save element one more time) $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $NID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { if (!array_key_exists($arProp["VALUE"], $arDup)) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); $arDup[$arProp["VALUE"]] = true; //This is cure for files duplication bug } } } } } else { if (array_key_exists("PREVIEW_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "PREVIEW_PICTURE", "iblock"); } if (array_key_exists("DETAIL_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock"); } } unset($arFields["IBLOCK_ID"]); unset($arFields["WF_NEW"]); unset($arFields["IBLOCK_SECTION_ID"]); $bTimeStampNA = false; if (is_set($arFields, "TIMESTAMP_X") && ($arFields["TIMESTAMP_X"] === NULL || $arFields["TIMESTAMP_X"] === false)) { $bTimeStampNA = true; unset($arFields["TIMESTAMP_X"]); } $strUpdate = $DB->PrepareUpdate("b_iblock_element", $arFields, "iblock"); if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strSql = "UPDATE b_iblock_element SET " . $strUpdate . ($bTimeStampNA ? "TIMESTAMP_X=TIMESTAMP_X" : "TIMESTAMP_X=now()") . " WHERE ID=" . $ID; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); if (array_key_exists("PROPERTY_VALUES", $arFields) && is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { CIBlockElement::SetPropertyValues($ID, $ar_element["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]); } if (is_set($arFields, "IBLOCK_SECTION")) { CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], false, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0); } if ($arIBlock["RIGHTS_MODE"] === "E") { $obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID); if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) { $obElementRights->SetRights($arFields["RIGHTS"]); } } if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) { $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID); $ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]); } if ($bUpdateSearch) { CIBlockElement::UpdateSearch($ID, true); } if ($bWorkFlow) { CIBlockElement::WF_CleanUpHistoryCopies($ID); } //Restore saved values if ($SAVED_PREVIEW_PICTURE !== false) { $arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE; } else { unset($arFields["PREVIEW_PICTURE"]); } if ($SAVED_DETAIL_PICTURE !== false) { $arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE; } else { unset($arFields["DETAIL_PICTURE"]); } if ($arIBlock["FIELDS"]["LOG_ELEMENT_EDIT"]["IS_REQUIRED"] == "Y") { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $arEvents = GetModuleEvents("main", "OnBeforeEventLog", true); if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) { $rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => "N", "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "LIST_PAGE_URL", "CODE")); $arElement = $rsElement->GetNext(); $res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]); CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_EDIT", "iblock", $arIBlock["ID"], serialize($res)); } } $Result = true; /************* QUOTA *************/ $_SESSION["SESS_RECOUNT_DB"] = "Y"; /************* QUOTA *************/ } $arFields["ID"] = $ID; $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; $arFields["RESULT"] =& $Result; if (isset($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && $arFields["PREVIEW_PICTURE"]["copy"]) { @unlink($arFields["PREVIEW_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["PREVIEW_PICTURE"]["tmp_name"])); } if (isset($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && $arFields["DETAIL_PICTURE"]["copy"]) { @unlink($arFields["DETAIL_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["DETAIL_PICTURE"]["tmp_name"])); } foreach (GetModuleEvents("iblock", "OnAfterIBlockElementUpdate", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]); } return $Result; }
/** * ћетод восстанавливает указанный документ из массива. ћассив создаетс¤ методом RecoverDocumentFromHistory. * * @param string $documentId - код документа. * @param array $arDocument - массив. */ public function RecoverDocumentFromHistory($documentId, $arDocument) { $documentId = intval($documentId); if ($documentId <= 0) { throw new CBPArgumentNullException("documentId"); } $arFields = $arDocument["FIELDS"]; if (strlen($arFields["PREVIEW_PICTURE"]) > 0) { $arFields["PREVIEW_PICTURE"] = CFile::MakeFileArray($arFields["PREVIEW_PICTURE"]); } if (strlen($arFields["DETAIL_PICTURE"]) > 0) { $arFields["DETAIL_PICTURE"] = CFile::MakeFileArray($arFields["DETAIL_PICTURE"]); } $arFields["PROPERTY_VALUES"] = array(); $dbProperties = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("IBLOCK_ID" => $arFields["IBLOCK_ID"])); while ($arProperty = $dbProperties->Fetch()) { if (strlen(trim($arProperty["CODE"])) > 0) { $key = $arProperty["CODE"]; } else { $key = $arProperty["ID"]; } if (!array_key_exists($key, $arDocument["PROPERTIES"])) { continue; } $documentValue = $arDocument["PROPERTIES"][$key]["VALUE"]; if (strlen($arProperty["USER_TYPE"]) <= 0 && $arProperty["PROPERTY_TYPE"] == "F") { $arFields["PROPERTY_VALUES"][$key] = array(); //Mark files to be deleted $rsFiles = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $documentId, array("ID" => $arProperty["ID"], "EMPTY" => "N")); while ($arFile = $rsFiles->Fetch()) { if ($arFile["PROPERTY_VALUE_ID"] > 0) { $arFields["PROPERTY_VALUES"][$key][$arFile["PROPERTY_VALUE_ID"]] = array("VALUE" => array("del" => "Y"), "DESCRIPTION" => ""); } } //Restore from history $io = CBXVirtualIo::GetInstance(); if (is_array($documentValue)) { $n = 0; foreach ($documentValue as $i => $v) { if (strlen($v) > 0) { $arFields["PROPERTY_VALUES"][$key]["n" . $n++] = array("VALUE" => CFile::MakeFileArray($io->GetPhysicalName($v)), "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"][$i]); } } } else { if (strlen($documentValue) > 0) { $arFields["PROPERTY_VALUES"][$key]["n0"] = array("VALUE" => CFile::MakeFileArray($io->GetPhysicalName($documentValue)), "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"]); } } } else { if (is_array($documentValue)) { $n = 0; foreach ($documentValue as $i => $v) { if (strlen($v) > 0) { $arFields["PROPERTY_VALUES"][$key]["n" . $n++] = array("VALUE" => $v, "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"][$i]); } } } else { if (strlen($documentValue) > 0) { $arFields["PROPERTY_VALUES"][$key]["n0"] = array("VALUE" => $documentValue, "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"]); } } } } $iblockElement = new CIBlockElement(); $res = $iblockElement->Update($documentId, $arFields); if (intVal($arFields["WF_STATUS_ID"]) > 1 && intVal($arFields["WF_PARENT_ELEMENT_ID"]) <= 0) { self::UnpublishDocument($documentId); } if (!$res) { throw new Exception($iblockElement->LAST_ERROR); } return true; }
$arParams = ExecuteModuleEventEx($arEvent, array($arItems["ID"], $arParams)); } $arParams = "var el" . $arItems["ID"] . " = " . $arParams; $act = '<script type="text/javascript">' . $arParams . '</script><input class="addBtn" type="button" onClick="SelEl(el' . $arItems["ID"] . ', ' . $arItems["ID"] . ')" name="btn_select_' . $arItems["ID"] . '" id="btn_select_' . $arItems["ID"] . '" value="' . GetMessage("SPS_SELECT") . '">'; $countField = '<input type="text" name="quantity_' . $arItems["ID"] . '" id="quantity_' . $arItems["ID"] . '" value="1" size="3">'; } else { $act = GetMessage("SPS_CAN_BUY_NOT_PRODUCT"); $countField = " "; } $active = $arItems["ACTIVE"] == 'Y' ? GetMEssage('SPS_PRODUCT_ACTIVE') : GetMEssage('SPS_PRODUCT_NO_ACTIVE'); $row->AddField("ACT", $act); $row->AddField("QUANTITY", $countField); $row->AddField("ACTIVE", $active); $arProperties = array(); if (!empty($arSelectedProps)) { $rsProperties = CIBlockElement::GetProperty($iblockId, $arItems["ID"]); while ($ar = $rsProperties->Fetch()) { if (!array_key_exists($ar["ID"], $arProperties)) { $arProperties[$ar["ID"]] = array(); } if ($ar["PROPERTY_TYPE"] === "L") { $arProperties[$ar["ID"]][$ar["PROPERTY_VALUE_ID"]] = $ar["VALUE_ENUM"]; } else { $arProperties[$ar["ID"]][$ar["PROPERTY_VALUE_ID"]] = $ar["VALUE"]; } } } foreach ($arSelectedProps as $aProp) { $v = ''; foreach ($arProperties[$aProp['ID']] as $property_value_id => $property_value) { $res = '';
$arUserGroupsForBP = CUser::GetUserGroup($USER->GetID()); $arDocumentStatesForBP = CBPWorkflowTemplateLoader::GetDocumentTypeStates(BizProcDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arIBlock["ID"])); } else { $arUserGroupsForBP = array(); $arDocumentStatesForBP = array(); } $arResult["ELEMENTS_CAN_DELETE"] = array(); $arResult["ELEMENTS_CAN_MOVE"] = array(); $arResult["ELEMENTS_ROWS"] = array(); $check = false; while ($obElement = $rsElements->GetNextElement()) { $check = true; $data = $obElement->GetFields(); $aCols = array(); if (!empty($arProperties)) { $rsProp = CIBlockElement::GetProperty($arIBlock["ID"], $data["ID"]); while ($arProp = $rsProp->Fetch()) { $FIELD_ID = "PROPERTY_" . $arProp["ID"]; if (in_array($FIELD_ID, $arProperties)) { $arField = $arResult["FIELDS"][$FIELD_ID]; if (!isset($data[$FIELD_ID])) { $data[$FIELD_ID] = array(); } if (is_array($arField["PROPERTY_USER_TYPE"]) && is_array($arField["PROPERTY_USER_TYPE"]["GetPublicViewHTML"])) { $strHTMLControlName = array(); if ($arField["PROPERTY_USER_TYPE"]["USER_TYPE"] == "EList") { $strHTMLControlName["MODE"] = "CSV_EXPORT"; } $data[$FIELD_ID][] = call_user_func_array($arField["PROPERTY_USER_TYPE"]["GetPublicViewHTML"], array($arField, array("VALUE" => $arProp["VALUE"]), $strHTMLControlName)); } elseif ($arField["PROPERTY_TYPE"] == "L") { $data[$FIELD_ID][] = htmlspecialcharsex($arProp["VALUE_ENUM"]);
function CheckFields(&$arFields, $ID = false, $bCheckDiskQuota = true) { global $DB, $APPLICATION, $USER; $this->LAST_ERROR = ""; $APPLICATION->ResetException(); if ($ID === false) { $db_events = GetModuleEvents("iblock", "OnStartIBlockElementAdd", true); } else { $arFields["ID"] = $ID; $db_events = GetModuleEvents("iblock", "OnStartIBlockElementUpdate", true); } foreach ($db_events as $arEvent) { $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields)); if ($bEventRes === false) { break; } } if (($ID === false || is_set($arFields, "NAME")) && strlen($arFields["NAME"]) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ELEMENT_NAME") . "<br>"; } if (isset($arFields["ACTIVE_FROM"]) && $arFields["ACTIVE_FROM"] != '' && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANG, "FULL")) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ACTIVE_FROM") . "<br>"; } if (isset($arFields["ACTIVE_TO"]) && $arFields["ACTIVE_TO"] != '' && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANG, "FULL")) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ACTIVE_TO") . "<br>"; } if (is_set($arFields, "PREVIEW_PICTURE")) { if (is_array($arFields["PREVIEW_PICTURE"]) && array_key_exists("bucket", $arFields["PREVIEW_PICTURE"]) && is_object($arFields["PREVIEW_PICTURE"]["bucket"])) { //This is trusted image from xml import } elseif (is_array($arFields["PREVIEW_PICTURE"])) { $error = CFile::CheckImageFile($arFields["PREVIEW_PICTURE"]); if (strlen($error) > 0) { $this->LAST_ERROR .= $error . "<br>"; } elseif (($error = CFile::checkForDb($arFields, "PREVIEW_PICTURE")) !== "") { $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_PREVIEW_PICTURE") . "<br>" . $error . "<br>"; } } elseif (intval($arFields["PREVIEW_PICTURE"]) > 0) { if (intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0 || CIBlockElement::DeleteFile($arFields["PREVIEW_PICTURE"], $ID, "PREVIEW", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_PREVIEW_PICTURE") . "<br>"; } } } if (is_set($arFields, "DETAIL_PICTURE")) { if (is_array($arFields["DETAIL_PICTURE"]) && array_key_exists("bucket", $arFields["DETAIL_PICTURE"]) && is_object($arFields["DETAIL_PICTURE"]["bucket"])) { //This is trusted image from xml import } elseif (is_array($arFields["DETAIL_PICTURE"])) { $error = CFile::CheckImageFile($arFields["DETAIL_PICTURE"]); if (strlen($error) > 0) { $this->LAST_ERROR .= $error . "<br>"; } elseif (($error = CFile::checkForDb($arFields, "DETAIL_PICTURE")) !== "") { $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_DETAIL_PICTURE") . "<br>" . $error . "<br>"; } } elseif (intval($arFields["DETAIL_PICTURE"]) > 0) { if (intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0 || CIBlockElement::DeleteFile($arFields["DETAIL_PICTURE"], $ID, "DETAIL", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_DETAIL_PICTURE") . "<br>"; } } } if (array_key_exists("TAGS", $arFields) && CModule::IncludeModule('search')) { $arFields["TAGS"] = implode(", ", tags_prepare($arFields["TAGS"])); } if ($ID === false && !is_set($arFields, "IBLOCK_ID")) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID") . "<br>"; } if ($ID !== false && is_set($arFields, "XML_ID") && strlen($arFields["XML_ID"]) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_EXTERNAL_CODE") . "<br>"; } //Find out IBLOCK_ID from fields or from element $IBLOCK_ID = intval($arFields["IBLOCK_ID"]); if ($IBLOCK_ID <= 0) { $IBLOCK_ID = 0; $res = $DB->Query("SELECT IBLOCK_ID FROM b_iblock_element WHERE ID=" . IntVal($ID)); if ($ar = $res->Fetch()) { $IBLOCK_ID = (int) $ar["IBLOCK_ID"]; } } //Read iblock metadata static $IBLOCK_CACHE = array(); if (!isset($IBLOCK_CACHE[$IBLOCK_ID])) { if ($IBLOCK_ID > 0) { $IBLOCK_CACHE[$IBLOCK_ID] = CIBlock::GetArrayByID($IBLOCK_ID); } else { $IBLOCK_CACHE[$IBLOCK_ID] = false; } } if ($IBLOCK_CACHE[$IBLOCK_ID]) { $arFields["IBLOCK_ID"] = $IBLOCK_ID; } else { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID") . "<br>"; } if (is_set($arFields, 'IBLOCK_SECTION') && !empty($arFields['IBLOCK_SECTION'])) { if (!is_array($arFields['IBLOCK_SECTION'])) { $arFields['IBLOCK_SECTION'] = array($arFields['IBLOCK_SECTION']); } $arFields['IBLOCK_SECTION'] = array_filter($arFields['IBLOCK_SECTION']); } if ($IBLOCK_CACHE[$IBLOCK_ID]) { $ar = $IBLOCK_CACHE[$IBLOCK_ID]["FIELDS"]; if (is_array($ar)) { $WF_PARENT_ELEMENT_ID = isset($arFields["WF_PARENT_ELEMENT_ID"]) ? intval($arFields["WF_PARENT_ELEMENT_ID"]) : 0; if (($WF_PARENT_ELEMENT_ID == 0 || $WF_PARENT_ELEMENT_ID == intval($ID)) && array_key_exists("CODE", $arFields) && strlen($arFields["CODE"]) > 0 && is_array($ar["CODE"]["DEFAULT_VALUE"]) && $ar["CODE"]["DEFAULT_VALUE"]["UNIQUE"] == "Y") { $res = $DB->Query("\n\t\t\t\t\t\tSELECT ID\n\t\t\t\t\t\tFROM b_iblock_element\n\t\t\t\t\t\tWHERE IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\t\t\tAND CODE = '" . $DB->ForSQL($arFields["CODE"]) . "'\n\t\t\t\t\t\tAND WF_PARENT_ELEMENT_ID IS NULL\n\t\t\t\t\t\tAND ID <> " . intval($ID)); if ($res->Fetch()) { $this->LAST_ERROR .= GetMessage("IBLOCK_DUP_ELEMENT_CODE") . "<br>"; } } $arOldElement = false; foreach ($ar as $FIELD_ID => $field) { if (preg_match("/^(SECTION_|LOG_)/", $FIELD_ID)) { continue; } if ($field["IS_REQUIRED"] === "Y") { switch ($FIELD_ID) { case "NAME": case "ACTIVE": case "PREVIEW_TEXT_TYPE": case "DETAIL_TEXT_TYPE": case "SORT": //We should never check for this fields break; case "IBLOCK_SECTION": if ($ID === false || array_key_exists($FIELD_ID, $arFields)) { $sum = 0; if (is_array($arFields[$FIELD_ID])) { foreach ($arFields[$FIELD_ID] as $k => $v) { if (intval($v) > 0) { $sum += intval($v); } } } else { $sum = intval($arFields[$FIELD_ID]); } if ($sum <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } } break; case "PREVIEW_PICTURE": case "DETAIL_PICTURE": if ($ID !== false && !$arOldElement) { $rs = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = " . intval($ID)); $arOldElement = $rs->Fetch(); } if ($arOldElement && $arOldElement[$FIELD_ID] > 0) { //There was an picture so just check that it is not deleted if (array_key_exists($FIELD_ID, $arFields) && is_array($arFields[$FIELD_ID]) && $arFields[$FIELD_ID]["del"] === "Y") { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } } else { //There was NO picture so it MUST be present if (!array_key_exists($FIELD_ID, $arFields)) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } elseif (is_array($arFields[$FIELD_ID])) { if ($arFields[$FIELD_ID]["del"] === "Y" || array_key_exists("error", $arFields[$FIELD_ID]) && $arFields[$FIELD_ID]["error"] !== 0 || $arFields[$FIELD_ID]["size"] <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } } else { if (intval($arFields[$FIELD_ID]) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } } } break; default: if ($ID === false || array_key_exists($FIELD_ID, $arFields)) { if (is_array($arFields[$FIELD_ID])) { $val = implode("", $arFields[$FIELD_ID]); } else { $val = $arFields[$FIELD_ID]; } if (strlen($val) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_FIELD", array("#FIELD_NAME#" => $field["NAME"])) . "<br>"; } } break; } } } } } if (array_key_exists("PROPERTY_VALUES", $arFields) && is_array($arFields["PROPERTY_VALUES"])) { //First "normalize" properties to form: //$arFields["PROPERTY_VALUES"][<PROPERTY_ID>][<PROPERTY_VALUE_ID>] => $value $arProperties = array(); foreach ($arFields["PROPERTY_VALUES"] as $key => $property_values) { $arProperties[$key] = array(); if (is_array($property_values)) { if (array_key_exists("VALUE", $property_values)) { $arProperties[$key][] = $property_values["VALUE"]; } elseif (array_key_exists("tmp_name", $property_values)) { $arProperties[$key][] = $property_values; } else { foreach ($property_values as $key2 => $property_value) { if (is_array($property_value) && array_key_exists("VALUE", $property_value)) { //each of these may be "complex" $arProperties[$key][] = $property_value["VALUE"]; } else { //or simple $arProperties[$key][] = $property_value; } } } } else { $arProperties[$key][] = $property_values; } } foreach ($arProperties as $key => $property_values) { $arProperty = CIBlockProperty::GetPropertyArray($key, $IBLOCK_ID); if ($arProperty["USER_TYPE"] != "") { $arUserType = CIBlockProperty::GetUserType($arProperty["USER_TYPE"]); } else { $arUserType = array(); } if (array_key_exists("CheckFields", $arUserType)) { foreach ($property_values as $key2 => $property_value) { $arError = call_user_func_array($arUserType["CheckFields"], array($arProperty, array("VALUE" => $property_value))); if (is_array($arError)) { foreach ($arError as $err_mess) { $this->LAST_ERROR .= $err_mess . "<br>"; } } } } //Files check $bError = false; if ($arProperty["IS_REQUIRED"] == "Y" && $arProperty['PROPERTY_TYPE'] == 'F') { //New element if ($ID === false) { $bError = true; foreach ($property_values as $key2 => $property_value) { if (is_array($property_value) && array_key_exists("tmp_name", $property_value) && array_key_exists("size", $property_value)) { if ($property_value['size'] > 0) { $bError = false; break; } } elseif (intval($property_value) > 0) { //This is history copy of the file $bError = false; break; } } } else { $dbProperty = CIBlockElement::GetProperty($arProperty["IBLOCK_ID"], $ID, "sort", "asc", array("ID" => $arProperty["ORIG_ID"], "EMPTY" => "N")); $bCount = 0; while ($a = $dbProperty->Fetch()) { if ($a["VALUE"] > 0) { $bCount++; } } foreach ($property_values as $key2 => $property_value) { if (is_array($property_value)) { if ($property_value['size'] > 0) { $bCount++; break; } elseif ($property_value['del'] == 'Y') { $bCount--; } } elseif (intval($property_value) > 0) { //This is history copy of the file $bCount++; break; } } $bError = $bCount <= 0; } } if ($arProperty["IS_REQUIRED"] == "Y" && $arProperty['PROPERTY_TYPE'] != 'F') { $len = 0; foreach ($property_values as $key2 => $property_value) { if (array_key_exists("GetLength", $arUserType)) { $len += call_user_func_array($arUserType["GetLength"], array($arProperty, array("VALUE" => $property_value))); } else { $len += strlen($property_value); } if ($len > 0) { break; } } $bError = $len <= 0; } if ($bError) { $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_PROPERTY", array("#PROPERTY#" => $arProperty["NAME"])) . "<br>"; } // check file properties for correctness if ($arProperty['PROPERTY_TYPE'] == 'F') { $bImageOnly = False; $arImageExtentions = explode(",", strtoupper(CFile::GetImageExtensions())); if (strlen($arProperty["FILE_TYPE"])) { $bImageOnly = True; $arAvailTypes = explode(",", strtoupper($arProperty["FILE_TYPE"])); foreach ($arAvailTypes as $avail_type) { if (!in_array(trim($avail_type), $arImageExtentions)) { $bImageOnly = False; break; } } } foreach ($property_values as $key2 => $property_value) { if (!is_array($property_value) && intval($property_value) > 0 && intval($arFields["WF_PARENT_ELEMENT_ID"]) > 0) { if (CIBlockElement::DeleteFile($property_value, $ID, "PROPERTY", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) { $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_FILE_PROPERTY") . "<br>"; } } elseif (is_array($property_value)) { if (is_object($property_value["bucket"])) { //This is trusted image from xml import $error = ""; } else { if ($bImageOnly) { $error = CFile::CheckImageFile($property_value); } else { $error = CFile::CheckFile($property_value, 0, false, $arProperty["FILE_TYPE"]); } } //For user without edit php permissions //we allow only pictures upload if (!is_object($USER) || !$USER->IsAdmin()) { if (HasScriptExtension($property_value["name"])) { $error = GetMessage("FILE_BAD_TYPE") . " (" . $property_value["name"] . ")."; } } if (strlen($error) > 0) { $this->LAST_ERROR .= $error . "<br>"; } } } } } } $APPLICATION->ResetException(); if ($ID === false) { $db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementAdd", true); } else { $arFields["ID"] = $ID; $db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementUpdate", true); } foreach ($db_events as $arEvent) { $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields)); if ($bEventRes === false) { if ($err = $APPLICATION->GetException()) { $this->LAST_ERROR .= $err->GetString() . "<br>"; } else { $APPLICATION->ThrowException("Unknown error"); $this->LAST_ERROR .= "Unknown error.<br>"; } break; } } /****************************** QUOTA ******************************/ if ($bCheckDiskQuota && empty($this->LAST_ERROR) && COption::GetOptionInt("main", "disk_space") > 0) { $quota = new CDiskQuota(); if (!$quota->checkDiskQuota($arFields)) { $this->LAST_ERROR = $quota->LAST_ERROR; } } /****************************** QUOTA ******************************/ if (!empty($this->LAST_ERROR)) { return false; } return true; }
protected function getItemProperies($id) { $arProperties = array(); $propIds = $this->getVisibleProperties(); if ($propIds) { $rsProperties = \CIBlockElement::GetProperty($this->getIblockId(), $id, 'sort', 'asc', array('ID' => $propIds)); while ($ar = $rsProperties->Fetch()) { if (!array_key_exists($ar["ID"], $arProperties)) { $arProperties[$ar["ID"]] = array(); } if ($ar["PROPERTY_TYPE"] === "L") { $arProperties[$ar["ID"]][$ar["PROPERTY_VALUE_ID"]] = $ar["VALUE_ENUM"]; } else { $arProperties[$ar["ID"]][$ar["PROPERTY_VALUE_ID"]] = $ar["VALUE"]; } } } return $arProperties; }
public function get() { // >>определяем количество элементов и страниц $CIBlockElement = CIBlockElement::GetList( $arOrder = array(), $arFilter = $this->arr_filter, $arGroupBy = false, $arNavStartParams = false, $arSelectFields = Array('ID') ); $all_items_count = $CIBlockElement->SelectedRowsCount(); $this->w['count_all_items'] = $all_items_count; $count_all_page = ceil($all_items_count / $this->w['item_count_per_page']); $this->w['count_all_page'] = $count_all_page; // << $start_elem = $this->w['item_count_per_page'] * ($this->w['page_number'] - 1); //echo "$start_elem"; if ($start_elem >= $all_items_count) { // если запрашивается страница которой нет(т.е. элементы закончились - возвращаем пустой массив $items) } else { // >>получаем товары $items = array(); $_arNavStartParams = Array( //@del //"nPageSize"=>$this->item_count_per_page, 'iNumPage'=>$this->page_number "nPageSize" => $this->w['item_count_per_page'], 'iNumPage' => $this->w['page_number'] ); if ($this->all_items == true) { $_arNavStartParams = false; // получить все элементы без пагинации } $CIBlockElement = CIBlockElement::GetList( $arOrder = $this->arr_sort, $arFilter = $this->arr_filter, $arGroupBy = false, $arNavStartParams = $_arNavStartParams, $arSelectFields = $this->arr_select ); while ($ar_result = $CIBlockElement->GetNext()) { // получаем множественные свойства if (!empty($this->arr_filter['IBLOCK_ID']) && !empty($ar_result['ID']) && count($this->arr_select_prop)) { $arr_res_prop = array(); foreach ($this->arr_select_prop as $code_prop) { // получим множ свойство (связанные товары ) $arr_val_prop = array(); $db_props = CIBlockElement::GetProperty( $IBLOCK_ID = $this->arr_filter['IBLOCK_ID'], $PROD_ID = $ar_result['ID'], array("sort" => "asc"), Array("CODE" => $code_prop) ); $arr_val_prop = array(); while ($prop = $db_props->GetNext()) { if (!empty($prop['VALUE'])) { $arr_val_prop[] = $prop['VALUE']; } } $arr_res_prop[$code_prop] = $arr_val_prop; // пополняем результат } $ar_result['_prop'] = $arr_res_prop; } $items[] = $ar_result; } $this->w['items'] = $items; } // <<получаем товары return $this->w; }
foreach ($arPostFields as $FIELD_NAME => $arPostField) { if (!in_array($FIELD_NAME, $arParams["POST_PROPERTY"])) { continue; } elseif ($FIELD_NAME == "UF_GRATITUDE" && array_key_exists("VALUE", $arPostField) && intval($arPostField["VALUE"]) > 0) { $bHasProps = true; $gratValue = $arPostField["VALUE"]; if (CModule::IncludeModule("iblock")) { if (!is_array($GLOBALS["CACHE_HONOUR"]) || !array_key_exists("honour_iblock_id", $GLOBALS["CACHE_HONOUR"]) || intval($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"]) <= 0) { $rsIBlock = CIBlock::GetList(array(), array("=CODE" => "honour", "=TYPE" => "structure")); if ($arIBlock = $rsIBlock->Fetch()) { $GLOBALS["CACHE_HONOUR"]["honour_iblock_id"] = $arIBlock["ID"]; } } if (intval($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"]) > 0) { $arGrat = array("USERS" => array(), "USERS_FULL" => array(), "TYPE" => false); $rsElementProperty = CIBlockElement::GetProperty($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"], $gratValue); while ($arElementProperty = $rsElementProperty->GetNext()) { if ($arElementProperty["CODE"] == "USERS" && intval($arElementProperty["VALUE"]) > 0) { $arGrat["USERS"][] = $arElementProperty["VALUE"]; } elseif ($arElementProperty["CODE"] == "GRATITUDE") { $arGrat["TYPE"] = array("VALUE_ENUM" => $arElementProperty["VALUE_ENUM"], "XML_ID" => $arElementProperty["VALUE_XML_ID"]); } } if (count($arGrat["USERS"]) > 0) { if ($arParams["CACHE_TIME"] > 0 && defined("BX_COMP_MANAGED_CACHE")) { foreach ($arGrat["USERS"] as $i => $grat_user_id) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($grat_user_id)); } } $arGratUsers = array(); $rsUser = CUser::GetList($by = "", $ord = "", array("ID" => implode("|", $arGrat["USERS"])), array("FIELDS" => array("ID", "PERSONAL_GENDER", "PERSONAL_PHOTO", "LOGIN", "NAME", "LAST_NAME", "SECOND_NAME", "EMAIL", "WORK_POSITION")));
$arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "DETAIL_PAGE_URL"); //WHERE $arFilter = array("ID" => $id, "IBLOCK_LID" => SITE_ID, "IBLOCK_ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"); $arOffers = CIBlockPriceTools::GetOffersIBlock($arParams["IBLOCK_ID"]); $OFFERS_IBLOCK_ID = $arOffers ? $arOffers["OFFERS_IBLOCK_ID"] : 0; if ($arOffers) { $arFilter["IBLOCK_ID"] = array($arParams["IBLOCK_ID"], $arOffers["OFFERS_IBLOCK_ID"]); } else { $arFilter["IBLOCK_ID"] = $arParams["IBLOCK_ID"]; } $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); $rsElement->SetUrlTemplates($arParams["DETAIL_URL"]); $arElement = $rsElement->GetNext(); $arMaster = false; if ($arElement && $arElement["IBLOCK_ID"] == $OFFERS_IBLOCK_ID) { $rsMasterProperty = CIBlockElement::GetProperty($arElement["IBLOCK_ID"], $arElement["ID"], array(), array("ID" => $arOffers["OFFERS_PROPERTY_ID"], "EMPTY" => "N")); if ($arMasterProperty = $rsMasterProperty->Fetch()) { $rsMaster = CIBlockElement::GetList(array(), array("ID" => $arMasterProperty["VALUE"], "IBLOCK_ID" => $arMasterProperty["LINK_IBLOCK_ID"], "ACTIVE" => "Y"), false, false, $arSelect); $rsMaster->SetUrlTemplates($arParams["DETAIL_URL"]); $arMaster = $rsMaster->GetNext(); } } if ($arMaster) { $arMaster["NAME"] = $arElement["NAME"]; $_SESSION[$arParams["NAME"]][$arParams["IBLOCK_ID"]]["ITEMS"][$id] = $arMaster; } elseif ($arElement) { $_SESSION[$arParams["NAME"]][$arParams["IBLOCK_ID"]]["ITEMS"][$id] = $arElement; } } } /*************************************************************************
{ $section = CIBlockSection::GetByID($arElement['IBLOCK_SECTION_ID']); if ($arSection = $section->GetNext()) $detailURL = str_replace('#SECTION_CODE#', $arSection['CODE'], $detailURL); } if ($arParams['IMAGE'] == 'NOT_SHOW') $image = ''; elseif ($arParams['IMAGE'] == 'PREVIEW_PICTURE') $image = CFile::GetPath($arElement['PREVIEW_PICTURE']); elseif ($arParams['IMAGE'] == 'DETAIL_PICTURE') $image = CFile::GetPath($arElement['DETAIL_PICTURE']); else { $db_props = CIBlockElement::GetProperty($arElement['IBLOCK_ID'], $arElement['ID'], array("sort" => "asc"), Array("CODE" => $arParams['IMAGE'])); if ($arProps = $db_props->Fetch()) $image = CFile::GetPath($arProps["VALUE"]); else $image = ''; } $arResult['ITEMS'][] = array( 'ELEMENT_ID' => $arElement['ID'], 'ELEMENT_NAME' => $arElement['NAME'], 'DETAIL_PAGE_URL' => $detailURL, 'IMAGE' => $image, 'COMMENTS_COUNT' => $arRes['COMMENTS_COUNT'] ); } }
$strOrderList = ""; $arBasketList = array(); $dbBasketItems = CSaleBasket::GetList(array("ID" => "ASC"), array("ORDER_ID" => $arResult["ORDER_ID"]), false, false, array("ID", "PRODUCT_ID", "NAME", "QUANTITY", "PRICE", "CURRENCY", "TYPE", "SET_PARENT_ID")); while ($arItem = $dbBasketItems->Fetch()) { if (CSaleBasketHelper::isSetItem($arItem)) { continue; } $arFilter = array("ID" => IntVal($arItem['PRODUCT_ID'])); $res = CIBlockElement::GetList(array(), $arFilter, false, false, array("ID", "IBLOCK_ID", "PREVIEW_PICTURE", 'DETAIL_PICTURE')); while ($ar_fields = $res->GetNext()) { if ($ar_fields['PREVIEW_PICTURE']) { $file = CFile::ResizeImageGet($ar_fields['PREVIEW_PICTURE'], array('width' => 30, 'height' => 18), BX_RESIZE_IMAGE_PROPORTIONAL, true); } elseif ($ar_fields['DETAIL_PICTURE']) { $file = CFile::ResizeImageGet($ar_fields['DETAIL_PICTURE'], array('width' => 30, 'height' => 18), BX_RESIZE_IMAGE_PROPORTIONAL, true); } else { $res = CIBlockElement::GetProperty($ar_fields['IBLOCK_ID'], $ar_fields['ID'], "sort", "asc", array("CODE" => "MORE_PHOTO")); while ($ob = $res->GetNext()) { if ($ob['VALUE']) { $file = CFile::ResizeImageGet($ob['VALUE'], array('width' => 30, 'height' => 18), BX_RESIZE_IMAGE_PROPORTIONAL, true); continue; } } } } $arBasketList[$i] = $arItem; $arBasketList[$i]['PICTURE'] = $file['src']; $i++; } $arBasketList = getMeasures($arBasketList); $strOrderList = ' <table border="1" bordercolor="#f1f1f1" cellpadding="20" cellspacing="0" width="100%" style="border-collapse: collapse; background; font: 18px/20px Arial, Helvetica, sans-serif;"> <tr>
function IBlockElementUpdate(&$arFields) { //Do not index workflow history $WF_PARENT_ELEMENT_ID = intval($arFields["WF_PARENT_ELEMENT_ID"]); if ($WF_PARENT_ELEMENT_ID > 0 && $WF_PARENT_ELEMENT_ID != intval($arFields["ID"])) { return; } if (!CModule::IncludeModule('search')) { return; } //And do not index wf drafts $rsElement = CIBlockElement::GetList(array(), array("=ID" => $arFields["ID"]), false, false, array("ID", "NAME", "IBLOCK_SECTION_ID", "WF_PARENT_ELEMENT_ID", "WF_STATUS_ID")); $dbElement = $rsElement->Fetch(); if (!$dbElement) { return; } if (!isset($arFields["NAME"])) { $arFields["NAME"] = $dbElement["NAME"]; } if (!isset($arFields["IBLOCK_SECTION"])) { $arFields["IBLOCK_SECTION"] = $dbElement["IBLOCK_SECTION_ID"]; } elseif (is_array($arFields["IBLOCK_SECTION"]) && isset($arFields["IBLOCK_SECTION"][0])) { $arFields["IBLOCK_SECTION"] = $arFields["IBLOCK_SECTION"][0]; } switch (intval($arFields["IBLOCK_ID"])) { case intval($this->_params["PHOTO_GROUP_IBLOCK_ID"]): $path_template = trim($this->_params["PATH_TO_GROUP_PHOTO_ELEMENT"]); if (strlen($path_template)) { $this->IndexIBlockElement($arFields, $this->_group_id, "G", "photo", "view", $path_template, array("PREVIEW_TEXT")); } break; case intval($this->_params["PHOTO_USER_IBLOCK_ID"]): $path_template = trim($this->_params["PATH_TO_USER_PHOTO_ELEMENT"]); if (strlen($path_template)) { $this->IndexIBlockElement($arFields, $this->_user_id, "U", "photo", "view", $path_template, array("PREVIEW_TEXT")); } break; case intval($this->_params["CALENDAR_GROUP_IBLOCK_ID"]): $path_template = trim($this->_params["PATH_TO_GROUP_CALENDAR_ELEMENT"]); if (strlen($path_template)) { $this->IndexIBlockElement($arFields, $this->_group_id, "G", "calendar", "view", $path_template, array("DETAIL_TEXT")); } break; case intval($this->_params["TASK_IBLOCK_ID"]): if (is_array($arFields["IBLOCK_SECTION"])) { foreach ($arFields["IBLOCK_SECTION"] as $section_id) { break; } } else { $section_id = $arFields["IBLOCK_SECTION"]; } $section_id = intval($section_id); if ($section_id) { $rsPath = CIBlockSection::GetNavChain($arFields["IBLOCK_ID"], $section_id); $arSection = $rsPath->Fetch(); if ($arSection) { if ($arSection["EXTERNAL_ID"] == "users_tasks") { $rsAssigned = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => "TASKASSIGNEDTO", "EMPTY" => "N")); $arAssigned = $rsAssigned->Fetch(); $path_template = trim($this->_params["PATH_TO_USER_TASK_ELEMENT"]); if ($arAssigned && strlen($path_template)) { $this->IndexIBlockElement($arFields, $arAssigned["VALUE"], "U", "tasks", "view_all", $path_template, array("DETAIL_TEXT")); } } elseif (intval($arSection["EXTERNAL_ID"]) > 0) { $path_template = trim($this->_params["PATH_TO_GROUP_TASK_ELEMENT"]); if (strlen($path_template)) { $this->IndexIBlockElement($arFields, intval($arSection["EXTERNAL_ID"]), "G", "tasks", "view", $path_template, array("DETAIL_TEXT")); } } } } break; case intval($this->_params["FILES_GROUP_IBLOCK_ID"]): $path_template = trim($this->_params["PATH_TO_GROUP_FILES_ELEMENT"]); if (strlen($path_template)) { $property = strtoupper(trim($this->_params["FILES_PROPERTY_CODE"])); if (strlen($property) <= 0) { $property = "FILE"; } $rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N")); $arFile = $rsFile->Fetch(); if ($arFile) { $arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]); if (is_array($arFile)) { $arFields["FILE_CONTENT"] = $arFile["CONTENT"]; if (strlen($arFields["TAGS"])) { $arFields["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")]; } else { $arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")]; } } } $this->IndexIBlockElement($arFields, $this->_group_id, "G", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT")); } break; case intval($this->_params["FILES_USER_IBLOCK_ID"]): $path_template = trim($this->_params["PATH_TO_USER_FILES_ELEMENT"]); if (strlen($path_template)) { $property = strtoupper(trim($this->_params["FILES_PROPERTY_CODE"])); if (strlen($property) <= 0) { $property = "FILE"; } $rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N")); $arFile = $rsFile->Fetch(); if ($arFile) { $arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]); if (is_array($arFile)) { $arFields["FILE_CONTENT"] = $arFile["CONTENT"]; if (strlen($arFields["TAGS"])) { $arFields["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")]; } else { $arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")]; } } } $this->IndexIBlockElement($arFields, $this->_user_id, "U", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT")); } break; case intval(COption::GetOptionInt("wiki", "socnet_iblock_id")): if (CModule::IncludeModule("wiki")) { $this->IndexIBlockElement($arFields, $this->_group_id, "G", "wiki", "view", $this->_params["PATH_TO_GROUP"] . "wiki/#name#/", array("DETAIL_TEXT")); } break; } }
} return; } // Product properties $arPropUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'view'); $arResult['PROP_USER_TYPES'] = $arPropUserTypeList; $arProps = CCrmProductPropsHelper::GetProps($catalogID, $arPropUserTypeList); $arResult['PROPS'] = $arProps; $arResult['PRODUCT'] = $product; $arResult['FORM_ID'] = 'CRM_PRODUCT_SHOW'; $arResult['GRID_ID'] = 'CRM_PRODUCT_LIST'; // Product properties values /*$arResult['PRODUCT_PROPS'] = array();*/ $arPropertyValues = array(); if ($productID > 0) { $rsProperties = CIBlockElement::GetProperty($catalogID, $productID, array('sort' => 'asc', 'id' => 'asc', 'enum_sort' => 'asc', 'value_id' => 'asc'), array('ACTIVE' => 'Y', 'EMPTY' => 'N', 'CHECK_PERMISSIONS' => 'N')); while ($arProperty = $rsProperties->Fetch()) { if (isset($arProperty['USER_TYPE']) && !empty($arProperty['USER_TYPE']) && !array_key_exists($arProperty['USER_TYPE'], $arPropUserTypeList)) { continue; } $propID = 'PROPERTY_' . $arProperty['ID']; if (!isset($arPropertyValues[$propID])) { $arPropertyValues[$propID] = array(); } if (isset($arProperty['USER_TYPE']) && !empty($arProperty['USER_TYPE']) && is_array($arPropUserTypeList[$arProperty['USER_TYPE']]) && array_key_exists('GetPublicViewHTML', $arPropUserTypeList[$arProperty['USER_TYPE']])) { $arPropertyValues[$propID][] = call_user_func_array($arPropUserTypeList[$arProperty['USER_TYPE']]["GetPublicViewHTML"], array($arProps[$propID], array("VALUE" => $arProperty["VALUE"]), array())); } elseif ($arProperty["PROPERTY_TYPE"] == "L") { $arPropertyValues[$propID][] = htmlspecialcharsex($arProperty["VALUE_ENUM"]); } else { $arPropertyValues[$propID][] = nl2br(htmlspecialcharsex($arProperty["VALUE"])); }
function GetRSSText($arIBLOCK, $LIMIT_NUM = false, $LIMIT_DAY = false, $yandex = false) { global $DB; $strRes = ""; $serverName = ""; if (isset($arIBLOCK["SERVER_NAME"]) && strlen($arIBLOCK["SERVER_NAME"]) > 0) { $serverName = $arIBLOCK["SERVER_NAME"]; } if (strlen($serverName) <= 0 && !isset($arIBLOCK["SERVER_NAME"])) { $dbSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => $arIBLOCK["LID"])); if ($arSite = $dbSite->Fetch()) { $serverName = $arSite["SERVER_NAME"]; } } if (strlen($serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com"); } } $strRes .= "<channel>\n"; $strRes .= "<title>" . htmlspecialcharsbx($arIBLOCK["NAME"]) . "</title>\n"; $strRes .= "<link>http://" . $serverName . "</link>\n"; $strRes .= "<description>" . htmlspecialcharsbx($arIBLOCK["DESCRIPTION"]) . "</description>\n"; $strRes .= "<lastBuildDate>" . date("r") . "</lastBuildDate>\n"; $strRes .= "<ttl>" . $arIBLOCK["RSS_TTL"] . "</ttl>\n"; $db_img_arr = CFile::GetFileArray($arIBLOCK["PICTURE"]); if ($db_img_arr) { if (substr($db_img_arr["SRC"], 0, 1) == "/") { $strImage = "http://" . $serverName . $db_img_arr["SRC"]; } else { $strImage = $db_img_arr["SRC"]; } $strRes .= "<image>\n"; $strRes .= "<title>" . htmlspecialcharsbx($arIBLOCK["NAME"]) . "</title>\n"; $strRes .= "<url>" . $strImage . "</url>\n"; $strRes .= "<link>http://" . $serverName . "</link>\n"; $strRes .= "<width>" . $db_img_arr["WIDTH"] . "</width>\n"; $strRes .= "<height>" . $db_img_arr["HEIGHT"] . "</height>\n"; $strRes .= "</image>\n"; } $arNodes = array(); $db_res = $DB->Query("SELECT NODE, NODE_VALUE FROM b_iblock_rss WHERE IBLOCK_ID = " . IntVal($arIBLOCK["ID"])); while ($db_res_arr = $db_res->Fetch()) { $arNodes[$db_res_arr["NODE"]] = $db_res_arr["NODE_VALUE"]; } CTimeZone::Disable(); $strSql = "SELECT DISTINCT BE.*, " . "\t" . $DB->DateToCharFunction("BE.TIMESTAMP_X") . " as TIMESTAMP_X, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_FROM", "FULL") . " as ACTIVE_FROM, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_TO", "FULL") . " as ACTIVE_TO, " . "\tL.DIR as LANG_DIR, B.DETAIL_PAGE_URL, B.LIST_PAGE_URL, B.LID, L.SERVER_NAME " . "FROM b_iblock_element BE, b_lang L, b_iblock B " . "\tLEFT JOIN b_iblock_group IBG ON IBG.IBLOCK_ID=B.ID " . "WHERE BE.IBLOCK_ID = B.ID " . "\tAND B.LID = L.LID " . "\tAND IBG.GROUP_ID IN (2) " . "\tAND BE.WF_STATUS_ID = 1 AND BE.WF_PARENT_ELEMENT_ID is null " . "\tAND IBG.PERMISSION>='R' " . "\tAND (IBG.PERMISSION='X' OR B.ACTIVE='Y') " . "\tAND (BE.IBLOCK_ID = " . IntVal($arIBLOCK["ID"]) . ") " . "\tAND ((BE.ACTIVE_TO >= " . $DB->GetNowFunction() . " OR BE.ACTIVE_TO IS NULL) AND (BE.ACTIVE_FROM <= " . $DB->GetNowFunction() . " OR BE.ACTIVE_FROM IS NULL)) " . "\tAND (BE.ACTIVE = 'Y') "; if ($LIMIT_DAY !== false) { $strSql .= " AND (BE.ACTIVE_FROM>=" . $DB->CharToDateFunction($DB->ForSql(date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), mktime(date("H"), date("i"), date("s"), date("m"), date("d") - IntVal($LIMIT_DAY), date("Y")))), "FULL") . " OR BE.ACTIVE_FROM IS NULL) "; } $strSql .= "ORDER BY BE.ACTIVE_FROM DESC, BE.SORT ASC "; $res = $DB->Query($strSql); CTimeZone::Enable(); $items = new CIBlockResult($res->result); if ($LIMIT_NUM !== False && IntVal($LIMIT_NUM) > 0) { $items->NavStart($LIMIT_NUM); } while ($arItem = $items->GetNext()) { $props = CIBlockElement::GetProperty($arIBLOCK["ID"], $arItem["ID"], "sort", "asc", array("ACTIVE" => "Y", "NON_EMPTY" => "Y")); $arProps = array(); while ($arProp = $props->Fetch()) { if (strlen($arProp["CODE"]) > 0) { $arProps[$arProp["CODE"]] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => htmlspecialcharsex($arProp["VALUE"])); } else { $arProps[$arProp["ID"]] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => htmlspecialcharsex($arProp["VALUE"])); } } $arLinkProp = $arProps["DOC_LINK"]; $strRes .= "<item>\n"; if (strlen($arNodes["title"]) > 0) { $strRes .= "<title>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["title"], $arProps, $arItem)) . "</title>\n"; } else { $strRes .= "<title>" . htmlspecialcharsbx($arItem["~NAME"]) . "</title>\n"; } if (strlen($arNodes["link"]) > 0) { $strRes .= "<link>" . CIBlockRSS::ExtractProperties($arNodes["link"], $arProps, $arItem) . "</link>\n"; } else { $strRes .= "<link>http://" . $serverName . ($arLinkProp["VALUE"] ? $arLinkProp["VALUE"] : $arItem["DETAIL_PAGE_URL"]) . "</link>\n"; } if (strlen($arNodes["description"]) > 0) { $strRes .= "<description>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["description"], $arProps, $arItem)) . "</description>\n"; } else { $strRes .= "<description>" . ($arItem["PREVIEW_TEXT"] || $yandex ? htmlspecialcharsbx($arItem["PREVIEW_TEXT"]) : htmlspecialcharsbx($arItem["DETAIL_TEXT"])) . "</description>\n"; } if (strlen($arNodes["enclosure"]) > 0) { $strRes .= "<enclosure url=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure"], $arProps, $arItem)) . "\" length=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure_length"], $arProps, $arItem)) . "\" type=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure_type"], $arProps, $arItem)) . "\"/>\n"; } else { $db_img_arr = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]); if ($db_img_arr) { if (substr($db_img_arr["SRC"], 0, 1) == "/") { $strImage = "http://" . $serverName . $db_img_arr["SRC"]; } else { $strImage = $db_img_arr["SRC"]; } $strRes .= "<enclosure url=\"" . $strImage . "\" length=\"" . $db_img_arr["FILE_SIZE"] . "\" type=\"" . $db_img_arr["CONTENT_TYPE"] . "\" width=\"" . $db_img_arr["WIDTH"] . "\" height=\"" . $db_img_arr["HEIGHT"] . "\"/>\n"; } } if (strlen($arNodes["category"]) > 0) { $strRes .= "<category>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["category"], $arProps, $arItem)) . "</category>\n"; } else { $strPath = ""; $nav = CIBlockSection::GetNavChain($arIBLOCK["ID"], $arItem["IBLOCK_SECTION_ID"]); while ($ar_nav = $nav->GetNext()) { $strPath .= $ar_nav["NAME"] . "/"; } if (strlen($strPath) > 0) { $strRes .= "<category>" . htmlspecialcharsbx($strPath) . "</category>\n"; } } if ($yandex) { $strRes .= "<yandex:full-text>" . htmlspecialcharsbx($arItem["DETAIL_TEXT"]) . "</yandex:full-text>\n"; } if (strlen($arNodes["pubDate"]) > 0) { $strRes .= "<pubDate>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["pubDate"], $arProps, $arItem)) . "</pubDate>\n"; } else { if (strlen($arItem["ACTIVE_FROM"]) > 0) { $strRes .= "<pubDate>" . date("r", MkDateTime($DB->FormatDate($arItem["ACTIVE_FROM"], Clang::GetDateFormat("FULL"), "DD.MM.YYYY H:I:S"), "d.m.Y H:i:s")) . "</pubDate>\n"; } else { $strRes .= "<pubDate>" . date("r") . "</pubDate>\n"; } } $strRes .= "</item>\n"; } $strRes .= "</channel>\n"; return $strRes; }
public static function GetMentionedUserID($arFields) { $arMentionedUserID = array(); if (isset($arFields["DETAIL_TEXT"])) { preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/is" . BX_UTF_PCRE_MODIFIER, $arFields["DETAIL_TEXT"], $arMention); if (!empty($arMention)) { $arMentionedUserID = array_merge($arMentionedUserID, $arMention[1]); } } $arPostUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_POST", $arFields["ID"], LANGUAGE_ID); if (is_array($arPostUF) && isset($arPostUF["UF_GRATITUDE"]) && is_array($arPostUF["UF_GRATITUDE"]) && isset($arPostUF["UF_GRATITUDE"]["VALUE"]) && intval($arPostUF["UF_GRATITUDE"]["VALUE"]) > 0 && CModule::IncludeModule("iblock")) { if (!is_array($GLOBALS["CACHE_HONOUR"]) || !array_key_exists("honour_iblock_id", $GLOBALS["CACHE_HONOUR"]) || intval($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"]) <= 0) { $rsIBlock = CIBlock::GetList(array(), array("=CODE" => "honour", "=TYPE" => "structure")); if ($arIBlock = $rsIBlock->Fetch()) { $GLOBALS["CACHE_HONOUR"]["honour_iblock_id"] = $arIBlock["ID"]; } } if (intval($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"]) > 0) { $rsElementProperty = CIBlockElement::GetProperty($GLOBALS["CACHE_HONOUR"]["honour_iblock_id"], $arPostUF["UF_GRATITUDE"]["VALUE"]); while ($arElementProperty = $rsElementProperty->GetNext()) { if ($arElementProperty["CODE"] == "USERS" && intval($arElementProperty["VALUE"]) > 0) { $arMentionedUserID[] = $arElementProperty["VALUE"]; } } } } return $arMentionedUserID; }
} $CWikiParser = new CWikiParser(); $CWiki->Update($arParams['ELEMENT_ID'], $arFields); //we should not post content of wiki page to feed if it redirects to another page if (preg_match("/^\\#(REDIRECT|" . GetMessage('WIKI_REDIRECT') . ")\\s*\\[\\[(.*)\\]\\]/iU" . BX_UTF_PCRE_MODIFIER, $arFields['DETAIL_TEXT'])) { $bPageRedirect = true; } else { $bPageRedirect = false; } if (CWikiSocnet::IsSocNet() && $arResult['POST_TO_FEED'] == "Y" && !$bPageRedirect) { if (strlen($arParams['SOCNET_GROUP_ID']) > 0) { CSocNetGroup::SetLastActivity(intval($arParams['SOCNET_GROUP_ID'])); } $postUrl = str_replace(array('#group_id#', '#wiki_name#'), array(intval($arParams['SOCNET_GROUP_ID']), urlencode($arFields['NAME'])), $arParams['~PATH_TO_POST']); $arCurImages = array(); $rsProperties = CIBlockElement::GetProperty($arParams['IBLOCK_ID'], $arParams['ELEMENT_ID'], 'value_id', 'asc', array('ACTIVE' => 'Y', 'CODE' => 'IMAGES')); while ($arProperty = $rsProperties->Fetch()) { if ($arProperty['CODE'] == 'IMAGES') { $arCurImages[] = $arProperty['VALUE']; } } $text4message = $CWikiParser->Parse($arFields['DETAIL_TEXT'], $arFields['DETAIL_TEXT_TYPE'], $arCurImages); $text4message = CWikiSocnet::PrepareTextForFeed($text4message); $text4message = $CWikiParser->Clear($text4message); //while CSocNetTextParser::closetags closes <br> by </br> must be corrected soon. Then remove this. $text4message = preg_replace("/<\\s*br\\s*>/ismU", "<br />", $text4message); $bNew = true; $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arFields["NAME"]); $notify_title = TruncateText($notify_title_tmp, 100); $notify_title_out = TruncateText($notify_title_tmp, 255); if ($arResult['WIKI_oper'] == 'edit') {
function exportElement($arElement, $SECTION_MAP, $PROPERTY_MAP) { if (strlen($arElement["XML_ID"]) > 0) { $xml_id = $arElement["XML_ID"]; } else { $xml_id = $arElement["ID"]; } if ($this->PRODUCT_IBLOCK_ID > 0) { $arPropOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc"); $rsLink = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE" => "Y", "CODE" => "CML2_LINK")); $arLink = $rsLink->Fetch(); if (is_array($arLink) && !is_array($arLink["VALUE"]) && $arLink["VALUE"] > 0) { $xml_id = $this->GetElementXML_ID($this->PRODUCT_IBLOCK_ID, $arLink["VALUE"]) . "#" . $xml_id; } } fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_ID") . ">" . htmlspecialcharsbx($xml_id) . "</" . GetMessage("IBLOCK_XML2_ID") . ">\n"); if (!$this->only_price) { $this->exportElementFields($arElement, $SECTION_MAP); if ($this->next_step["catalog"] && !$this->bExtended) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES") . ">\n"); } else { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTIES_VALUES") . ">\n"); } $this->exportElementProperties($arElement, $PROPERTY_MAP); if ($this->next_step["catalog"] && !$this->bExtended) { fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES") . ">\n"); } else { fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTIES_VALUES") . ">\n"); } if ($this->bExtended) { $elementTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($this->arIBlock["ID"], $arElement["ID"]); $this->exportInheritedTemplates(4, $elementTemplates); } } if ($this->next_step["catalog"]) { $rsProduct = CCatalogProduct::GetList(array(), array("ID" => $arElement["ID"])); $arProduct = $rsProduct->Fetch(); static $measure = null; if (!isset($measure)) { $measure = array(); $rsBaseUnit = CCatalogMeasure::GetList(array(), array()); while ($arIDUnit = $rsBaseUnit->Fetch()) { $measure[$arIDUnit["ID"]] = $arIDUnit["CODE"]; } } $xmlMeasure = GetMessage("IBLOCK_XML2_PCS"); if ($arProduct["MEASURE"] > 0 && isset($measure[$arProduct["MEASURE"]])) { $xmlMeasure = $measure[$arProduct["MEASURE"]]; } $arPrices = array(); $rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arElement["ID"])); while ($arPrice = $rsPrices->Fetch()) { if (!$arPrice["QUANTITY_FROM"] && !$arPrice["QUANTITY_TO"]) { $arPrices[] = array(GetMessage("IBLOCK_XML2_PRICE_TYPE_ID") => $this->prices[$arPrice["CATALOG_GROUP_ID"]], GetMessage("IBLOCK_XML2_PRICE_FOR_ONE") => $arPrice["PRICE"], GetMessage("IBLOCK_XML2_CURRENCY") => $arPrice["CURRENCY"], GetMessage("IBLOCK_XML2_MEASURE") => $xmlMeasure); } } if (count($arPrices) > 0) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_PRICES") . ">\n"); foreach ($arPrices as $arPrice) { fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PRICE") . ">\n"); foreach ($arPrice as $key => $value) { fwrite($this->fp, "\t\t\t\t\t\t<" . $key . ">" . htmlspecialcharsbx($value) . "</" . $key . ">\n"); } fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PRICE") . ">\n"); } fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_PRICES") . ">\n"); $arCatalogProduct = CCatalogProduct::GetByID($arElement["ID"]); if ($arCatalogProduct) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_AMOUNT") . ">" . htmlspecialcharsbx($arCatalogProduct["QUANTITY"]) . "</" . GetMessage("IBLOCK_XML2_AMOUNT") . ">\n"); } } } }