/** * @return array[string][string]string */ public function queryValues() { $templateInstance = new BaseTemplate($this); $templates = $templateInstance->findTemplates(); foreach ($templates as $CODE => $row) { $templates[$CODE]["VALUE"] = \Bitrix\Iblock\Template\Engine::process($this->createTemplateEntity(), $row["TEMPLATE"]); } return $templates; }
$arPropertySaveValues[$srcKey] = array(); foreach ($srcValue as $fileID => $fileValue) { $arPropertySaveValues[$srcKey][$fileID] = CIBlock::makeFilePropArray($srcValue[$fileID], false); } } else { $arPropertySaveValues[$srcKey] = CIBlock::makeFilePropArray($srcValue, false); } break; } } } $arPropertySaveValues["CML2_LINK"] = $parentElement; $arIBlockElementAdd['PROPERTY_VALUES'] = $arPropertySaveValues; $sku = new \Bitrix\Iblock\Template\Entity\Element(0); $sku->setFields($arIBlockElementAdd); $arIBlockElementAdd["NAME"] = htmlspecialcharsback(\Bitrix\Iblock\Template\Engine::process($sku, $title)); unset($arIBlockElementAdd['PROPERTY_VALUES']["CML2_LINK"]); $idNewElement = $obIBlockElement->Add($arIBlockElementAdd, false, true, true); if ($idNewElement) { $productData['ID'] = $idNewElement; CCatalogProduct::Add($productData, false); foreach ($arPriceGroup as $price) { CPrice::Add(array("PRODUCT_ID" => $idNewElement, "CURRENCY" => $price["CURRENCY"], "PRICE" => $price["PRICE"], "CATALOG_GROUP_ID" => $price["TYPE"])); } $element = new \Bitrix\Iblock\InheritedProperty\ElementValues($subIBlockId, $idNewElement); $template = new \Bitrix\Iblock\InheritedProperty\BaseTemplate($element); $template->set(array("MY_TEMPLATE" => $title)); } else { $errorMessage .= $obIBlockElement->LAST_ERROR; break; }
/** * Function returns file name formatted by the template. * * @param \Bitrix\Iblock\InheritedProperty\BaseTemplate $ipropTemplates Templates to lookup. * @param string $templateName Name of the template to choose from $ipropTemplates. * @param array $fields Array contains fields for processing the template. * @param array $file Array contains information about file in format of $_FILES. * * @return string */ public static function makeFileName(\Bitrix\Iblock\InheritedProperty\BaseTemplate $ipropTemplates, $templateName, array $fields, array $file) { if (preg_match("/^(.+)(\\.[a-zA-Z0-9]+)\$/", $file["name"], $fileName)) { if (!isset($fields["IPROPERTY_TEMPLATES"]) || $fields["IPROPERTY_TEMPLATES"][$templateName] == "") { $templates = $ipropTemplates->findTemplates(); $TEMPLATE = $templates[$templateName]["TEMPLATE"]; } else { $TEMPLATE = $fields["IPROPERTY_TEMPLATES"][$templateName]; } if ($TEMPLATE != "") { list($template, $modifiers) = Helper::splitTemplate($TEMPLATE); if ($template != "") { $values = $ipropTemplates->getValuesEntity(); $entity = $values->createTemplateEntity(); $entity->setFields($fields); return \Bitrix\Iblock\Template\Engine::process($entity, $TEMPLATE) . $fileName[2]; } elseif ($modifiers != "") { $simpleTemplate = new NodeRoot(); $simpleTemplate->addChild(new NodeText($fileName[1])); $simpleTemplate->setModifiers($modifiers); $baseEntity = new Entity\Base(0); return $simpleTemplate->process($baseEntity) . $fileName[2]; } } } return $file["name"]; }
if (is_array($_POST["IBLOCK_SECTION"])) { $section_id = min(array_filter($_POST["IBLOCK_SECTION"], "strlen")); } else { $section_id = 0; } $arFields = array("IBLOCK_ID" => $_REQUEST["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $section_id, "NAME" => $_POST["NAME"], "CODE" => $_POST["CODE"], "PREVIEW_TEXT" => $_POST["PREVIEW_TEXT"], "DETAIL_TEXT" => $_POST["DETAIL_TEXT"]); } else { $ipropTemplates = null; $arFields = array(); } if ($ipropTemplates) { $values = $ipropTemplates->getValuesEntity(); $entity = $values->createTemplateEntity(); $entity->setFields($arFields); $templates = $ipropTemplates->findTemplates(); if (is_array($_POST["IPROPERTY_TEMPLATES"])) { foreach ($_POST["IPROPERTY_TEMPLATES"] as $TEMPLATE_NAME => $TEMPLATE_VALUE) { $templates[$TEMPLATE_NAME] = array("TEMPLATE" => \Bitrix\Iblock\Template\Helper::convertArrayToModifiers($TEMPLATE_VALUE)); } } $result = array(); foreach ($templates as $TEMPLATE_NAME => $templateInfo) { $result[] = array("id" => $TEMPLATE_NAME, "value" => \Bitrix\Main\Text\String::htmlEncode(\Bitrix\Iblock\Template\Engine::process($entity, $templateInfo["TEMPLATE"]))); } echo CUtil::PhpToJSObject($result); //$entity = $values->createTemplateEntity(); //$entity->setFields($arFields); //$templates = $values->getTemplateEntity(); } } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
} } } } if (!empty($arDirProperties)) { foreach ($arDirProperties as $arOneConvert) { if (isset($arPropertySaveValues[$arOneConvert['ID']])) { $arPropertySaveValues[$arOneConvert['ID']] = $arOneConvert['CONVERT'][$arPropertySaveValues[$arOneConvert['ID']]]; } } } $arPropertySaveValues["CML2_LINK"] = $parentElement; $arIBlockElementAdd['PROPERTY_VALUES'] = $arPropertySaveValues; $sku = new \Bitrix\Iblock\Template\Entity\Element(0); $sku->setFields($arIBlockElementAdd); $arIBlockElementAdd["NAME"] = \Bitrix\Iblock\Template\Engine::process($sku, $title); unset($arIBlockElementAdd['PROPERTY_VALUES']["CML2_LINK"]); $idNewElement = $obIBlockElement->Add($arIBlockElementAdd, false, true, true); if ($idNewElement) { CCatalogProduct::Add(array("ID" => $idNewElement, "WEIGHT" => $_POST["IB_SEG_WEIGHT"], "LENGTH" => $_POST["IB_SEG_BASE_LENGTH"], "WIDTH" => $_POST["IB_SEG_BASE_WIDTH"], "HEIGHT" => $_POST["IB_SEG_BASE_HEIGHT"], "VAT_ID" => $_POST["IB_SEG_VAT_ID"], "VAT_INCLUDED" => $_POST["IB_SEG_VAT_INCLUDED"])); foreach ($arPriceGroup as $price) { CPrice::Add(array("PRODUCT_ID" => $idNewElement, "CURRENCY" => $price["CURRENCY"], "PRICE" => $price["PRICE"], "CATALOG_GROUP_ID" => $price["TYPE"])); } $element = new \Bitrix\Iblock\InheritedProperty\ElementValues($subIBlockId, $idNewElement); $template = new \Bitrix\Iblock\InheritedProperty\BaseTemplate($element); $template->set(array("MY_TEMPLATE" => $title)); } else { $errorMessage .= $obIBlockElement->LAST_ERROR; break; } }