- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLExport
- Вызов: CIBlockCMLExport::ExportSmartFilter
function ExportSmartFilter($level, $iblockId, $sectionId, $PROPERTY_MAP, $productIblockId = 0)
{
$propertyLinksBySection = array();
if ($sectionId === false)
{
$propertyLinksBySection[0] = CIBlockSectionPropertyLink::GetArray($iblockId, 0);
foreach($propertyLinksBySection[0] as $PID => $arLink)
{
if($arLink["INHERITED"] != "N" || !array_key_exists($PID, $PROPERTY_MAP))
{
unset($propertyLinksBySection[0][$PID]);
}
else
{
if ($productIblockId > 0)
{
$iblock_xml_id = $this->GetIBlockXML_ID($productIblockId, CIBlock::GetArrayByID($productIblockId, "XML_ID"));
$propertyLinksBySection[0][$PID]["IBLOCK_XML_ID"] = $iblock_xml_id;
}
}
}
$arFilter = array(
"IBLOCK_ID" => $productIblockId? $productIblockId: $iblockId,
"CHECK_PERMISSIONS" => "N",
);
$rsSections = CIBlockSection::GetList(array("left_margin"=>"asc"), $arFilter, false, array("ID", "XML_ID", "IBLOCK_ID"));
while($arSection = $rsSections->Fetch())
{
$section_xml_id = $this->GetSectionXML_ID($arSection["IBLOCK_ID"], $arSection["ID"], $arSection["XML_ID"]);
$iblock_xml_id = $this->GetIBlockXML_ID($arSection["IBLOCK_ID"], CIBlock::GetArrayByID($arSection["IBLOCK_ID"], "XML_ID"));
$propertyLinksBySection[$arSection["ID"]] = CIBlockSectionPropertyLink::GetArray($iblockId, $arSection["ID"]);
foreach($propertyLinksBySection[$arSection["ID"]] as $PID => $arLink)
{
if($arLink["INHERITED"] != "N" || !array_key_exists($PID, $PROPERTY_MAP))
{
unset($propertyLinksBySection[$arSection["ID"]][$PID]);
}
else
{
$propertyLinksBySection[$arSection["ID"]][$PID]["IBLOCK_XML_ID"] = $iblock_xml_id;
$propertyLinksBySection[$arSection["ID"]][$PID]["SECTION_XML_ID"] = $section_xml_id;
}
}
}
}
else
{
$propertyLinksBySection[$sectionId] = CIBlockSectionPropertyLink::GetArray($iblockId, $sectionId);
foreach($propertyLinksBySection[$sectionId] as $PID => $arLink)
{
if($arLink["INHERITED"] != "N" || !array_key_exists($PID, $PROPERTY_MAP))
unset($propertyLinksBySection[$sectionId][$PID]);
}
}
$first = true;
foreach ($propertyLinksBySection as $arPropLink)
{
if(!empty($arPropLink))
{
if ($first)
{
fwrite($this->fp, str_repeat("t", $level)."<".GetMessage("IBLOCK_XML2_SECTION_PROPERTIES").">n");
$first = false;
}
foreach($arPropLink as $PID => $arLink)
{
$xmlLink = array(
GetMessage("IBLOCK_XML2_ID") => $PROPERTY_MAP[$PID],
GetMessage("IBLOCK_XML2_SMART_FILTER") => ($arLink["SMART_FILTER"] == "Y"? "true": "false"),
GetMessage("IBLOCK_XML2_SMART_FILTER_DISPLAY_TYPE") => $arLink["DISPLAY_TYPE"],
GetMessage("IBLOCK_XML2_SMART_FILTER_DISPLAY_EXPANDED") => ($arLink["DISPLAY_EXPANDED"] == "Y"? "true": "false"),
GetMessage("IBLOCK_XML2_SMART_FILTER_HINT") => $arLink["FILTER_HINT"],
);
if (isset($arLink["IBLOCK_XML_ID"]))
{
$xmlLink[GetMessage("IBLOCK_XML2_BX_LINKED_IBLOCK")] = $arLink["IBLOCK_XML_ID"];
}
if (isset($arLink["SECTION_XML_ID"]))
{
$xmlLink[GetMessage("IBLOCK_XML2_GROUP")] = $arLink["SECTION_XML_ID"];
}
fwrite($this->fp, $this->formatXMLNode($level+1, GetMessage("IBLOCK_XML2_PROPERTY"), $xmlLink));
}
}
}
if (!$first)
{
fwrite($this->fp, str_repeat("t", $level)."".GetMessage("IBLOCK_XML2_SECTION_PROPERTIES").">n");
}
}