public static function UpdatePropertyList($prop_id, $list) { foreach ($list as $id => $arEnum) { $value = trim($arEnum["VALUE"], " \t\n\r"); if (strlen($value)) { $dbEnum = CIBlockPropertyEnum::GetByID($id); if (is_array($dbEnum)) { $def = isset($arEnum["DEF"]) ? $arEnum["DEF"] : $dbEnum["DEF"]; $sort = intval($arEnum["SORT"]); if ($dbEnum["VALUE"] != $value || $dbEnum["SORT"] != $sort || $dbEnum["DEF"] != $def) { $dbEnum["VALUE"] = $value; $dbEnum["SORT"] = $sort; $dbEnum["DEF"] = $def; unset($dbEnum["ID"]); CIBlockPropertyEnum::Update($id, $dbEnum); } } else { $arEnum["PROPERTY_ID"] = $prop_id; CIBlockPropertyEnum::Add($arEnum); } } else { CIBlockPropertyEnum::Delete($id); } } }
static function onBeforeElementAddHandler($arFields) { $IBLOCK_ID = Config\Option::get("citfact.replaceurl", "IBLOCK_ID", ""); $SECTION_ID = Config\Option::get("citfact.replaceurl", "SECTION_BREND_ID", "BRENDI"); $CODE_PROP = Config\Option::get("citfact.replaceurl", "PROPERTY_CODE_BRENDI", "BRENDI"); if ($IBLOCK_ID == $arFields["IBLOCK_ID"]) { $propertyBrand = \CIBlockProperty::GetByID($CODE_PROP, $arFields["IBLOCK_ID"]); if ($arResultProperty = $propertyBrand->GetNext()) { $propertyBrandValue = \CIBlockPropertyEnum::GetByID($arFields["PROPERTY_VALUES"][$arResultProperty["ID"]][0]["VALUE"]); } $rqParentSection = \CIBlockSection::GetByID($SECTION_ID); if ($arParentSection = $rqParentSection->GetNext()) { $arFilter = array('IBLOCK_ID' => $arParentSection['IBLOCK_ID'], '>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'], '<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']); // выберет потомков без учета активности $rqSectChild = \CIBlockSection::GetList(array('left_margin' => 'asc'), $arFilter); while ($arSectChild = $rqSectChild->GetNext()) { $arSections[$arSectChild["NAME"]] = $arSectChild["ID"]; } } if (array_key_exists($propertyBrandValue["VALUE"], $arSections)) { $arFields["IBLOCK_SECTION"][] = $arSections[$propertyBrandValue["VALUE"]]; } else { $arParams = array("replace_space" => "-", "replace_other" => "-"); $trans = \Cutil::translit($propertyBrandValue["VALUE"], "ru", $arParams); $bs = new \CIBlockSection(); $arFieldsNewSection = array("ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $SECTION_ID, "IBLOCK_ID" => $IBLOCK_ID, "NAME" => $propertyBrandValue["VALUE"], "CODE" => $trans); $resultAdd = $bs->Add($arFieldsNewSection); $arFields["IBLOCK_SECTION"][] = $resultAdd; } } return true; }
case "iblock": if (substr($arItem["ITEM_ID"], 0, 1) === "G") { if (file_exists($abs_path . "socialnetwork_group.gif")) { $file = "socialnetwork_group.gif"; } } elseif (CModule::IncludeModule('iblock')) { if (!array_key_exists($arItem["PARAM2"], $arIBlocks)) { $arIBlocks[$arItem["PARAM2"]] = CIBlock::GetArrayByID($arItem["PARAM2"]); } //section /element if (substr($arItem["ITEM_ID"], 0, 1) !== "S") { //Try to find gif by element proprety value xml id $rsElement = CIBlockElement::GetList(array(), array("=ID" => $arItem["ITEM_ID"], "IBLOCK_ID" => $arItem["PARAM2"]), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "CODE", "XML_ID", "PROPERTY_DOC_TYPE")); $arElement = $rsElement->Fetch(); if ($arElement && strlen($arElement["PROPERTY_DOC_TYPE_ENUM_ID"]) > 0) { $arEnum = CIBlockPropertyEnum::GetByID($arElement["PROPERTY_DOC_TYPE_ENUM_ID"]); if ($arEnum && $arEnum["XML_ID"]) { if (file_exists($abs_path . "iblock_doc_type_" . strtolower($arEnum["XML_ID"]) . ".gif")) { $file = "iblock_doc_type_" . strtolower($arEnum["XML_ID"]) . ".gif"; } } } // add chain items if iblock (task, calendar event, library document) $element_type = false; if ($arElement) { if ($arElement["IBLOCK_ID"] == $arParams["TASKS_USER_IBLOCK_ID"]) { $element_type = "tasks"; } elseif ($arElement["IBLOCK_ID"] == $arParams["CALENDAR_USER_IBLOCK_ID"]) { $element_type = "calendar"; } elseif ($arElement["IBLOCK_ID"] == $arParams["FILES_USER_IBLOCK_ID"]) { $element_type = "files";
/** * @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; }
function exportElementProperties($arElement, $PROPERTY_MAP) { if ($this->bExtended) { $this->ExportPropertyValue("CML2_ACTIVE", $arElement["ACTIVE"] == "Y" ? "true" : "false"); $this->ExportPropertyValue("CML2_CODE", $arElement["CODE"]); $this->ExportPropertyValue("CML2_SORT", intval($arElement["SORT"])); $this->ExportPropertyValue("CML2_ACTIVE_FROM", CDatabase::FormatDate($arElement["ACTIVE_FROM"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_ACTIVE_TO", CDatabase::FormatDate($arElement["ACTIVE_TO"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_PREVIEW_TEXT", $arElement["PREVIEW_TEXT"], $arElement["PREVIEW_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_DETAIL_TEXT", $arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_PREVIEW_PICTURE", $this->ExportFile($arElement["PREVIEW_PICTURE"])); } $arPropOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc"); $rsProps = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE" => "Y")); $arProps = array(); while ($arProp = $rsProps->Fetch()) { $pid = $arProp["ID"]; if (!array_key_exists($pid, $arProps)) { $arProps[$pid] = array("PROPERTY_TYPE" => $arProp["PROPERTY_TYPE"], "LINK_IBLOCK_ID" => $arProp["LINK_IBLOCK_ID"], "VALUES" => array()); } if ($arProp["PROPERTY_TYPE"] == "L") { $arProps[$pid]["VALUES"][] = array("VALUE" => $arProp["VALUE_ENUM"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE"]); } else { $arProps[$pid]["VALUES"][] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE_ENUM_ID"]); } } foreach ($arProps as $pid => $arProp) { $bEmpty = true; if ($this->next_step["catalog"] && !$this->bExtended) { fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTE") . ">\n"); } else { fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY_VALUES") . ">\n"); } if ($this->next_step["catalog"] && !$this->bExtended) { fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_NAME") . ">" . htmlspecialcharsbx($PROPERTY_MAP["~" . $pid]) . "</" . GetMessage("IBLOCK_XML2_NAME") . ">\n"); } else { fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_ID") . ">" . htmlspecialcharsbx($PROPERTY_MAP[$pid]) . "</" . GetMessage("IBLOCK_XML2_ID") . ">\n"); } foreach ($arProp["VALUES"] as $arValue) { $value = $arValue["VALUE"]; if (is_array($value) || strlen($value)) { $bEmpty = false; $bSerialized = false; if ($this->bExtended) { if ($arProp["PROPERTY_TYPE"] == "L") { $value = CIBlockPropertyEnum::GetByID($arValue["VALUE_ENUM_ID"]); $value = $value["XML_ID"]; } elseif ($arProp["PROPERTY_TYPE"] == "F") { $value = $this->ExportFile($value); } elseif ($arProp["PROPERTY_TYPE"] == "G") { $value = $this->GetSectionXML_ID($arProp["LINK_IBLOCK_ID"], $value); } elseif ($arProp["PROPERTY_TYPE"] == "E") { $value = $this->GetElementXML_ID($arProp["LINK_IBLOCK_ID"], $value); } if (is_array($value) && $arProp["PROPERTY_TYPE"] !== "F") { $bSerialized = true; $value = serialize($value); } } fwrite($this->fp, $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $value)); if ($this->bExtended) { fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY_VALUE") . ">\n"); if ($bSerialized) { fwrite($this->fp, "\t\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_SERIALIZED") . ">true</" . GetMessage("IBLOCK_XML2_SERIALIZED") . ">\n"); } fwrite($this->fp, $this->formatXMLNode(7, GetMessage("IBLOCK_XML2_VALUE"), $value)); fwrite($this->fp, "\t\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">" . htmlspecialcharsbx($arValue["DESCRIPTION"]) . "</" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">\n"); fwrite($this->fp, "\t\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY_VALUE") . ">\n"); } } } if ($bEmpty) { fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_VALUE") . "></" . GetMessage("IBLOCK_XML2_VALUE") . ">\n"); } if ($this->next_step["catalog"] && !$this->bExtended) { fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTE") . ">\n"); } else { fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY_VALUES") . ">\n"); } } }
public static function GetProperty($IBLOCK_ID, $ELEMENT_ID, $by = "sort", $order = "asc", $arFilter = array()) { global $DB; if (is_array($by)) { if ($order != "asc") { $arFilter = $order; } $arOrder = $by; } else { $arOrder = false; } $IBLOCK_ID = intval($IBLOCK_ID); $ELEMENT_ID = intval($ELEMENT_ID); $VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID); $strSqlSearch = ""; foreach ($arFilter as $key => $val) { switch (strtoupper($key)) { case "ACTIVE": if ($val == "Y" || $val == "N") { $strSqlSearch .= "AND BP.ACTIVE='" . $val . "'\n"; } break; case "SEARCHABLE": if ($val == "Y" || $val == "N") { $strSqlSearch .= "AND BP.SEARCHABLE='" . $val . "'\n"; } break; case "NAME": if (strlen($val) > 0) { $strSqlSearch .= "AND " . CIBLock::_Upper("BP.NAME") . " LIKE " . CIBlock::_Upper("'" . $DB->ForSql($val) . "'") . "\n"; } break; case "ID": if (is_array($val)) { if (!empty($val)) { $strSqlSearch .= "AND BP.ID in (" . implode(", ", array_map("intval", $val)) . ")\n"; } } elseif (strlen($val) > 0) { $strSqlSearch .= "AND BP.ID=" . IntVal($val) . "\n"; } break; case "PROPERTY_TYPE": if (strlen($val) > 0) { $strSqlSearch .= "AND BP.PROPERTY_TYPE='" . $DB->ForSql($val) . "'\n"; } break; case "CODE": if (strlen($val) > 0) { $strSqlSearch .= "AND " . CIBLock::_Upper("BP.CODE") . " LIKE " . CIBLock::_Upper("'" . $DB->ForSql($val) . "'") . "\n"; } break; case "EMPTY": if (strlen($val) > 0) { if ($val == "Y") { $strSqlSearch .= "AND BEP.ID IS NULL\n"; } elseif ($VERSION != 2) { $strSqlSearch .= "AND BEP.ID IS NOT NULL\n"; } } break; } } $arSqlOrder = array(); if ($arOrder) { foreach ($arOrder as $by => $order) { $order = strtolower($order); if ($order != "desc") { $order = "asc"; } $by = strtolower($by); if ($by == "sort") { $arSqlOrder["BP.SORT"] = $order; } elseif ($by == "id") { $arSqlOrder["BP.ID"] = $order; } elseif ($by == "name") { $arSqlOrder["BP.NAME"] = $order; } elseif ($by == "active") { $arSqlOrder["BP.ACTIVE"] = $order; } elseif ($by == "value_id") { $arSqlOrder["BEP.ID"] = $order; } elseif ($by == "enum_sort") { $arSqlOrder["BEPE.SORT"] = $order; } else { $arSqlOrder["BP.SORT"] = $order; } } } else { if ($by == "id") { $arSqlOrder["BP.ID"] = "asc"; } elseif ($by == "name") { $arSqlOrder["BP.NAME"] = "asc"; } elseif ($by == "active") { $arSqlOrder["BP.ACTIVE"] = "asc"; } elseif ($by == "value_id") { $arSqlOrder["BEP.ID"] = $order; } elseif ($by == "enum_sort") { $arSqlOrder["BEPE.SORT"] = $order; } else { $arSqlOrder["BP.SORT"] = "asc"; $by = "sort"; } if ($order != "desc") { $arSqlOrder["BP.SORT"] = "asc"; $arSqlOrder["BP.ID"] = "asc"; $arSqlOrder["BEPE.SORT"] = "asc"; $arSqlOrder["BEP.ID"] = "asc"; $order = "asc"; } else { $arSqlOrder["BP.SORT"] = "desc"; $arSqlOrder["BP.ID"] = "desc"; $arSqlOrder["BEPE.SORT"] = "desc"; $arSqlOrder["BEP.ID"] = "desc"; } } $strSqlOrder = ""; foreach ($arSqlOrder as $key => $val) { $strSqlOrder .= ", " . $key . " " . $val; } if ($strSqlOrder != "") { $strSqlOrder = ' ORDER BY ' . substr($strSqlOrder, 1); } if ($VERSION == 2) { $strTable = "b_iblock_element_prop_m" . $IBLOCK_ID; } else { $strTable = "b_iblock_element_property"; } $strSql = "\n\t\t\tSELECT BP.*, BEP.ID as PROPERTY_VALUE_ID, BEP.VALUE, BEP.DESCRIPTION, BEPE.VALUE VALUE_ENUM, BEPE.XML_ID VALUE_XML_ID, BEPE.SORT VALUE_SORT\n\t\t\tFROM b_iblock B\n\t\t\t\tINNER JOIN b_iblock_property BP ON B.ID=BP.IBLOCK_ID\n\t\t\t\tLEFT JOIN " . $strTable . " BEP ON (BP.ID = BEP.IBLOCK_PROPERTY_ID AND BEP.IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . ")\n\t\t\t\tLEFT JOIN b_iblock_property_enum BEPE ON (BP.PROPERTY_TYPE = 'L' AND BEPE.ID=BEP.VALUE_ENUM AND BEPE.PROPERTY_ID=BP.ID)\n\t\t\tWHERE B.ID = " . $IBLOCK_ID . "\n\t\t\t\t" . $strSqlSearch . "\n\t\t\t" . $strSqlOrder; if ($VERSION == 2) { $result = array(); $arElements = array(); $rs = $DB->Query($strSql); while ($ar = $rs->Fetch()) { if ($ar["VERSION"] == 2 && $ar["MULTIPLE"] == "N") { if (!array_key_exists($ELEMENT_ID, $arElements)) { $strSql = "\n\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\tFROM b_iblock_element_prop_s" . $ar["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\t"; $rs2 = $DB->Query($strSql); $arElements[$ELEMENT_ID] = $rs2->Fetch(); } if (!isset($arFilter["EMPTY"]) || $arFilter["EMPTY"] == "Y" || strlen($arElements[$ELEMENT_ID]["PROPERTY_" . $ar["ID"]]) > 0) { $val = $arElements[$ELEMENT_ID]["PROPERTY_" . $ar["ID"]]; $ar["PROPERTY_VALUE_ID"] = $ELEMENT_ID . ":" . $ar["ID"]; if ($ar["PROPERTY_TYPE"] == "L" && intval($val) > 0) { $arEnum = CIBlockPropertyEnum::GetByID($val); if ($arEnum !== false) { $ar["VALUE_ENUM"] = $arEnum["VALUE"]; $ar["VALUE_XML_ID"] = $arEnum["XML_ID"]; $ar["VALUE_SORT"] = $arEnum["SORT"]; } } else { $ar["VALUE_ENUM"] = ""; } if ($ar["PROPERTY_TYPE"] == "N" && strlen($val) > 0) { $val = CIBlock::NumberFormat($val); } $ar["DESCRIPTION"] = $arElements[$ELEMENT_ID]["DESCRIPTION_" . $ar["ID"]]; $ar["VALUE"] = $val; } else { continue; } } if ($arFilter["EMPTY"] == "N" && $ar["PROPERTY_VALUE_ID"] == "") { continue; } $result[] = $ar; } $rs = new CIBlockPropertyResult(); $rs->InitFromArray($result); } else { $rs = new CIBlockPropertyResult($DB->Query($strSql)); } return $rs; }
function Fetch() { /** @global CCacheManager $CACHE_MANAGER */ global $CACHE_MANAGER; /** @global CDatabase $DB */ global $DB; $res = parent::Fetch(); if (!is_object($this)) { return $res; } $arUpdate = array(); if ($res) { if (is_array($this->arIBlockLongProps)) { foreach ($res as $k => $v) { if (preg_match("#^ALIAS_(\\d+)_(.*)\$#", $k, $match)) { $res[$this->arIBlockLongProps[$match[1]] . $match[2]] = $v; unset($res[$k]); } } } if (isset($res["IBLOCK_ID"]) && defined("BX_COMP_MANAGED_CACHE") && $res["IBLOCK_ID"] != $this->_LAST_IBLOCK_ID) { CIBlock::registerWithTagCache($res["IBLOCK_ID"]); $this->_LAST_IBLOCK_ID = $res["IBLOCK_ID"]; } if (isset($res["ID"]) && $res["ID"] != "" && is_array($this->arIBlockMultProps)) { foreach ($this->arIBlockMultProps as $field_name => $db_prop) { if (array_key_exists($field_name, $res)) { if (is_object($res[$field_name])) { $res[$field_name] = $res[$field_name]->load(); } if (preg_match("/(_VALUE)\$/", $field_name)) { $descr_name = preg_replace("/(_VALUE)\$/", "_DESCRIPTION", $field_name); } else { $descr_name = preg_replace("/^(PROPERTY_)/", "DESCRIPTION_", $field_name); } if (strlen($res[$field_name]) <= 0) { $strSql = "\n\t\t\t\t\t\t\t\tSELECT VALUE,DESCRIPTION\n\t\t\t\t\t\t\t\tFROM b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tIBLOCK_ELEMENT_ID = " . intval($res["ID"]) . "\n\t\t\t\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID = " . intval($db_prop["ORIG_ID"]) . "\n\t\t\t\t\t\t\t\tORDER BY ID\n\t\t\t\t\t\t\t"; $rs = $DB->Query($strSql); $res[$field_name] = array(); $res[$descr_name] = array(); while ($ar = $rs->Fetch()) { $res[$field_name][] = $ar["VALUE"]; $res[$descr_name][] = $ar["DESCRIPTION"]; } $arUpdate["b_iblock_element_prop_s" . $db_prop["IBLOCK_ID"]]["PROPERTY_" . $db_prop["ORIG_ID"]] = serialize(array("VALUE" => $res[$field_name], "DESCRIPTION" => $res[$descr_name])); } else { $tmp = unserialize($res[$field_name]); $res[$field_name] = $tmp["VALUE"]; $res[$descr_name] = $tmp["DESCRIPTION"]; } if (is_array($res[$field_name]) && $db_prop["PROPERTY_TYPE"] == "L") { $arTemp = array(); foreach ($res[$field_name] as $key => $val) { $arEnum = CIBlockPropertyEnum::GetByID($val); if ($arEnum !== false) { $arTemp[$val] = $arEnum["VALUE"]; } } $res[$field_name] = $arTemp; } } } foreach ($arUpdate as $strTable => $arFields) { $strUpdate = $DB->PrepareUpdate($strTable, $arFields); if ($strUpdate != "") { $strSql = "UPDATE " . $strTable . " SET " . $strUpdate . " WHERE IBLOCK_ELEMENT_ID = " . intval($res["ID"]); $DB->QueryBind($strSql, $arFields); } } } if (is_array($this->arIBlockConvProps)) { foreach ($this->arIBlockConvProps as $strFieldName => $arCallback) { if (is_array($res[$strFieldName])) { foreach ($res[$strFieldName] as $key => $value) { $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $value, "DESCRIPTION" => ""))); $res[$strFieldName][$key] = $arValue["VALUE"]; } } else { $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $res[$strFieldName], "DESCRIPTION" => ""))); $res[$strFieldName] = $arValue["VALUE"]; } } } if (is_array($this->arIBlockNumProps)) { foreach ($this->arIBlockNumProps as $field_name => $db_prop) { if (strlen($res[$field_name]) > 0) { $res[$field_name] = htmlspecialcharsex(CIBlock::NumberFormat($res[$field_name])); } } } if (isset($res["UC_ID"])) { $res["CREATED_BY_FORMATTED"] = CUser::FormatName($this->nameTemplate, array("NAME" => $res["UC_NAME"], "LAST_NAME" => $res["UC_LAST_NAME"], "SECOND_NAME" => $res["UC_SECOND_NAME"], "EMAIL" => $res["UC_EMAIL"], "ID" => $res["UC_ID"], "LOGIN" => $res["UC_LOGIN"]), true, false); unset($res["UC_NAME"]); unset($res["UC_LAST_NAME"]); unset($res["UC_SECOND_NAME"]); unset($res["UC_EMAIL"]); unset($res["UC_ID"]); unset($res["UC_LOGIN"]); } } elseif (defined("BX_COMP_MANAGED_CACHE") && $this->_LAST_IBLOCK_ID == "" && count($this->_FILTER_IBLOCK_ID)) { foreach ($this->_FILTER_IBLOCK_ID as $iblock_id => $t) { CIBlock::registerWithTagCache($iblock_id); } } return $res; }
public function fillItemValues(&$resultItem, $arProperty, $flag = null) { static $cache = array(); if (is_array($arProperty)) { if (isset($arProperty["PRICE"])) { return null; } $key = $arProperty["VALUE"]; $PROPERTY_TYPE = $arProperty["PROPERTY_TYPE"]; $PROPERTY_USER_TYPE = $arProperty["USER_TYPE"]; $PROPERTY_ID = $arProperty["ID"]; } else { $key = $arProperty; $PROPERTY_TYPE = $resultItem["PROPERTY_TYPE"]; $PROPERTY_USER_TYPE = $resultItem["USER_TYPE"]; $PROPERTY_ID = $resultItem["ID"]; $arProperty = $resultItem; } if ($PROPERTY_TYPE == "F") { return null; } elseif ($PROPERTY_TYPE == "N") { $convertKey = (double) $key; if (strlen($key) <= 0) { return null; } if (!isset($resultItem["VALUES"]["MIN"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MIN"]) || doubleval($resultItem["VALUES"]["MIN"]["VALUE"]) > $convertKey) { $resultItem["VALUES"]["MIN"]["VALUE"] = preg_replace("/\\.0+\$/", "", $key); } if (!isset($resultItem["VALUES"]["MAX"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MAX"]) || doubleval($resultItem["VALUES"]["MAX"]["VALUE"]) < $convertKey) { $resultItem["VALUES"]["MAX"]["VALUE"] = preg_replace("/\\.0+\$/", "", $key); } return null; } elseif ($arProperty["DISPLAY_TYPE"] == "U") { $date = substr($key, 0, 10); if (!$date) { return null; } $timestamp = MakeTimeStamp($date, "YYYY-MM-DD"); if (!$timestamp) { return null; } if (!isset($resultItem["VALUES"]["MIN"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MIN"]) || $resultItem["VALUES"]["MIN"]["VALUE"] > $timestamp) { $resultItem["VALUES"]["MIN"]["VALUE"] = $timestamp; } if (!isset($resultItem["VALUES"]["MAX"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MAX"]) || $resultItem["VALUES"]["MAX"]["VALUE"] < $timestamp) { $resultItem["VALUES"]["MAX"]["VALUE"] = $timestamp; } return null; } elseif ($PROPERTY_TYPE == "E" && $key <= 0) { return null; } elseif ($PROPERTY_TYPE == "G" && $key <= 0) { return null; } elseif (strlen($key) <= 0) { return null; } $arUserType = array(); if ($PROPERTY_USER_TYPE != "") { $arUserType = CIBlockProperty::GetUserType($PROPERTY_USER_TYPE); if (isset($arUserType["GetExtendedValue"])) { $PROPERTY_TYPE = "Ux"; } elseif (isset($arUserType["GetPublicViewHTML"])) { $PROPERTY_TYPE = "U"; } } if ($PROPERTY_USER_TYPE === "DateTime") { $key = call_user_func_array($arUserType["GetPublicViewHTML"], array($arProperty, array("VALUE" => $key), array("MODE" => "SIMPLE_TEXT", "DATETIME_FORMAT" => "SHORT"))); $PROPERTY_TYPE = "S"; } $htmlKey = htmlspecialcharsbx($key); if (isset($resultItem["VALUES"][$htmlKey])) { return $htmlKey; } $file_id = null; $url_id = null; switch ($PROPERTY_TYPE) { case "L": $enum = CIBlockPropertyEnum::GetByID($key); if ($enum) { $value = $enum["VALUE"]; $sort = $enum["SORT"]; $url_id = toLower($enum["XML_ID"]); } else { return null; } break; case "E": if (!isset($cache[$PROPERTY_TYPE][$key])) { $arLinkFilter = array("ID" => $key, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y"); $rsLink = CIBlockElement::GetList(array(), $arLinkFilter, false, false, array("ID", "IBLOCK_ID", "NAME", "SORT", "CODE")); $cache[$PROPERTY_TYPE][$key] = $rsLink->Fetch(); } $value = $cache[$PROPERTY_TYPE][$key]["NAME"]; $sort = $cache[$PROPERTY_TYPE][$key]["SORT"]; if ($cache[$PROPERTY_TYPE][$key]["CODE"]) { $url_id = toLower($cache[$PROPERTY_TYPE][$key]["CODE"]); } else { $url_id = toLower($value); } break; case "G": if (!isset($cache[$PROPERTY_TYPE][$key])) { $arLinkFilter = array("ID" => $key, "GLOBAL_ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"); $rsLink = CIBlockSection::GetList(array(), $arLinkFilter, false, array("ID", "IBLOCK_ID", "NAME", "LEFT_MARGIN", "DEPTH_LEVEL", "CODE")); $cache[$PROPERTY_TYPE][$key] = $rsLink->Fetch(); $cache[$PROPERTY_TYPE][$key]['DEPTH_NAME'] = str_repeat(".", $cache[$PROPERTY_TYPE][$key]["DEPTH_LEVEL"]) . $cache[$PROPERTY_TYPE][$key]["NAME"]; } $value = $cache[$PROPERTY_TYPE][$key]['DEPTH_NAME']; $sort = $cache[$PROPERTY_TYPE][$key]["LEFT_MARGIN"]; if ($cache[$PROPERTY_TYPE][$key]["CODE"]) { $url_id = toLower($cache[$PROPERTY_TYPE][$key]["CODE"]); } else { $url_id = toLower($value); } break; case "U": if (!isset($cache[$PROPERTY_ID])) { $cache[$PROPERTY_ID] = array(); } if (!isset($cache[$PROPERTY_ID][$key])) { $cache[$PROPERTY_ID][$key] = call_user_func_array($arUserType["GetPublicViewHTML"], array($arProperty, array("VALUE" => $key), array("MODE" => "SIMPLE_TEXT"))); } $value = $cache[$PROPERTY_ID][$key]; $sort = 0; $url_id = toLower($value); break; case "Ux": if (!isset($cache[$PROPERTY_ID])) { $cache[$PROPERTY_ID] = array(); } if (!isset($cache[$PROPERTY_ID][$key])) { $cache[$PROPERTY_ID][$key] = call_user_func_array($arUserType["GetExtendedValue"], array($arProperty, array("VALUE" => $key))); } $value = $cache[$PROPERTY_ID][$key]['VALUE']; $file_id = $cache[$PROPERTY_ID][$key]['FILE_ID']; $sort = isset($cache[$PROPERTY_ID][$key]['SORT']) ? $cache[$PROPERTY_ID][$key]['SORT'] : 0; $url_id = toLower($cache[$PROPERTY_ID][$key]['UF_XML_ID']); break; default: $value = $key; $sort = 0; $url_id = toLower($value); break; } $keyCrc = abs(crc32($htmlKey)); $safeValue = htmlspecialcharsex($value); $sort = (int) $sort; $filterPropertyID = $this->SAFE_FILTER_NAME . '_' . $PROPERTY_ID; $filterPropertyIDKey = $filterPropertyID . '_' . $keyCrc; $resultItem["VALUES"][$htmlKey] = array("CONTROL_ID" => $filterPropertyIDKey, "CONTROL_NAME" => $filterPropertyIDKey, "CONTROL_NAME_ALT" => $filterPropertyID, "HTML_VALUE_ALT" => $keyCrc, "HTML_VALUE" => "Y", "VALUE" => $safeValue, "SORT" => $sort, "UPPER" => ToUpper($safeValue), "FLAG" => $flag); if ($file_id) { $resultItem["VALUES"][$htmlKey]['FILE'] = CFile::GetFileArray($file_id); } if ($url_id) { $resultItem["VALUES"][$htmlKey]['URL_ID'] = $url_id; } return $htmlKey; }
function ExportElements($PROPERTY_MAP, $SECTION_MAP, $start_time, $INTERVAL, $counter_limit = 0, $arElementFilter = false) { $counter = 0; $arSelect = array( "ID", "IBLOCK_ID", "XML_ID", "ACTIVE", "CODE", "NAME", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "TAGS", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "PREVIEW_PICTURE", "DETAIL_PICTURE", ); if(is_array($arElementFilter)) { $arFilter = $arElementFilter; } else { if($arElementFilter === "none") return 0; $arFilter = array ( "IBLOCK_ID"=> $this->arIBlock["ID"], "ACTIVE" => "Y", ">ID" => $this->next_step["LAST_ID"], ); if($arElementFilter === "all") unset($arFilter["ACTIVE"]); } $arOrder = array( "ID" => "ASC", ); $arPropOrder = array( "sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc", ); $rsElements = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect); while($arElement = $rsElements->Fetch()) { if($this->next_step["catalog"]) fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_OFFER").">\n"); else fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_POSITION").">\n"); if(strlen($arElement["XML_ID"])>0) $xml_id = $arElement["XML_ID"]; else $xml_id = $arElement["ID"]; if($this->PRODUCT_IBLOCK_ID > 0) { $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) { fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_NAME").">".htmlspecialcharsbx($arElement["NAME"])."</".GetMessage("IBLOCK_XML2_NAME").">\n"); if($this->bExtended) fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_BX_TAGS").">".htmlspecialcharsbx($arElement["TAGS"])."</".GetMessage("IBLOCK_XML2_BX_TAGS").">\n"); $arSections = array(); $rsSections = CIBlockElement::GetElementGroups($arElement["ID"], true); while($arSection = $rsSections->Fetch()) if(array_key_exists($arSection["ID"], $SECTION_MAP)) $arSections[] = $SECTION_MAP[$arSection["ID"]]; fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_GROUPS").">\n"); foreach($arSections as $xml_id) fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."</".GetMessage("IBLOCK_XML2_ID").">\n"); fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_GROUPS").">\n"); if(!$this->bExtended) fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx(FormatText($arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]))."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n"); fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_PICTURE"), $this->ExportFile($arElement["DETAIL_PICTURE"]))); fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n"); if($this->bExtended) { $this->ExportPropertyValue("CML2_ACTIVE", ($arElement["ACTIVE"]=="Y"? "true": "false")); $this->ExportPropertyValue("CML2_CODE", $arElement["CODE"]); $this->ExportPropertyValue("CML2_SORT", intval($arElement["SORT"])); $this->ExportPropertyValue("CML2_ACTIVE_FROM", CDatabase::FormatDate($arElement["ACTIVE_FROM"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_ACTIVE_TO", CDatabase::FormatDate($arElement["ACTIVE_TO"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_PREVIEW_TEXT", $arElement["PREVIEW_TEXT"], $arElement["PREVIEW_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_DETAIL_TEXT", $arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_PREVIEW_PICTURE", $this->ExportFile($arElement["PREVIEW_PICTURE"])); } $rsProps = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y")); $arProps = array(); while($arProp = $rsProps->Fetch()) { $pid = $arProp["ID"]; if(!array_key_exists($pid, $arProps)) $arProps[$pid] = array( "PROPERTY_TYPE" => $arProp["PROPERTY_TYPE"], "LINK_IBLOCK_ID" => $arProp["LINK_IBLOCK_ID"], "VALUES" => array(), ); if($arProp["PROPERTY_TYPE"] == "L") $arProps[$pid]["VALUES"][] = array( "VALUE" => $arProp["VALUE_ENUM"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE"], ); else $arProps[$pid]["VALUES"][] = array( "VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE_ENUM_ID"], ); } foreach($arProps as $pid => $arProp) { $bEmpty = true; fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n"); fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($PROPERTY_MAP[$pid])."</".GetMessage("IBLOCK_XML2_ID").">\n"); foreach($arProp["VALUES"] as $arValue) { $value = $arValue["VALUE"]; if(is_array($value) || strlen($value)) { $bEmpty = false; $bSerialized = false; if($this->bExtended) { if($arProp["PROPERTY_TYPE"]=="L") { $value = CIBlockPropertyEnum::GetByID($arValue["VALUE_ENUM_ID"]); $value = $value["XML_ID"]; } elseif($arProp["PROPERTY_TYPE"]=="F") { $value = $this->ExportFile($value); } elseif($arProp["PROPERTY_TYPE"]=="G") { $value = $this->GetSectionXML_ID($arProp["LINK_IBLOCK_ID"], $value); } elseif($arProp["PROPERTY_TYPE"]=="E") { $value = $this->GetElementXML_ID($arProp["LINK_IBLOCK_ID"], $value); } if(is_array($value) && $arProp["PROPERTY_TYPE"]!=="F") { $bSerialized = true; $value = serialize($value); } } fwrite($this->fp, $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $value)); if($this->bExtended) { fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n"); if($bSerialized) fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_SERIALIZED").">true</".GetMessage("IBLOCK_XML2_SERIALIZED").">\n"); fwrite($this->fp, $this->formatXMLNode(7, GetMessage("IBLOCK_XML2_VALUE"), $value)); fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx($arValue["DESCRIPTION"])."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n"); fwrite($this->fp, "\t\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n"); } } } if($bEmpty) fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_VALUE")."></".GetMessage("IBLOCK_XML2_VALUE").">\n"); fwrite($this->fp, "\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n"); } fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n"); } if($this->next_step["catalog"]) { $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") => GetMessage("IBLOCK_XML2_PCS"), ); } } 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"); } } if($this->next_step["catalog"]) fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_OFFER").">\n"); else fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_POSITION").">\n"); $this->next_step["LAST_ID"] = $arElement["ID"]; $counter++; if($INTERVAL > 0 && (time()-$start_time) > $INTERVAL) break; if($counter_limit > 0 && ($counter >= $counter_limit)) break; } return $counter; }
$ar_Debug["FIRST_TO"][] = "\$currentRun : $currentRun"; $propramTOID = intval ( $_REQUEST['programTO'] ); $chId = intval ( $_REQUEST['chassis'] ); $run_at_year = intval ( $_REQUEST['run_at_year'] ); /* get correct value from Enum Type properties */ $d = CIBlockPropertyEnum::GetByID( intval ( $_REQUEST['years_of_work']) ); $years_of_work = $d["XML_ID"] / 12 ; $cntrct_transport_task = intval ( $_REQUEST["task"]) ; $cntrct_type = intval ( $_REQUEST["type"] ); $d = CIBlockPropertyEnum::GetByID( intval( $_REQUEST["exclude_washing"]) ); $with_out_washing = ( $d["XML_ID"] == "N" )? true:false ; if ( $chId > 0 && $run_at_year > 0 && $years_of_work > 0 ){ $discount = floatval($_REQUEST["discount"]); $params = array ( "CURRENT_RUN" => $currentRun, "WASHING" => $with_out_washing, "RUN_AT_YEAR" => $run_at_year,"YEARS_OF_WORK" => $years_of_work ); try{ $result ["TO"] = GetTO( $propramTOID, $chId, true, $with_out_washing ); calcCostTOWorks( $result ["TO"] ); countTO ( $result["TO"] , $years_of_work * $run_at_year, $currentRun ); calcByTo ( $result , $run_at_year, $years_of_work , $currentRun ); }catch(exception $e){