6use \Bitrix\Main\Localization\Loc;
9Loc::loadMessages(__FILE__);
25 return 'BX.Landing.Node.Component';
35 foreach ($additionalVals as
$code =>
$val)
37 self::$predefineForDynamicProps[
$code] =
$val;
50 $components = \PHPParser::parseScript(
$content);
51 foreach ($components as $component)
54 if ($component[
'DATA'][
'COMPONENT_NAME'] ==
$code)
58 return $param !==
null;
60 $componentCode = ($component[
'DATA'][
'VARIABLE'] ? $component[
'DATA'][
'VARIABLE'] .
'=' :
'') .
61 '$APPLICATION->IncludeComponent(' . PHP_EOL .
62 "\t" .
'"' . $component[
'DATA'][
'COMPONENT_NAME'] .
'", ' . PHP_EOL .
63 "\t" .
'"' . $component[
'DATA'][
'TEMPLATE_NAME'] .
'", ' . PHP_EOL .
64 "\t" .
'array(' . PHP_EOL .
65 "\t" .
"\t" . \PHPParser::returnPHPStr2(
$params) . PHP_EOL .
66 "\t" .
'),' . PHP_EOL .
67 "\t" . ($component[
'DATA'][
'PARENT_COMP'] ? $component[
'DATA'][
'PARENT_COMP'] :
'false') .
68 (!empty($component[
'DATA'][
'FUNCTION_PARAMS']) ?
',' . PHP_EOL .
69 "\t" .
'array(' . PHP_EOL .
"\t" .
"\t" . \PHPParser::returnPHPStr2($component[
'DATA'][
'FUNCTION_PARAMS']) . PHP_EOL .
70 "\t" .
')' :
'') . PHP_EOL .
72 $componentCode = str_replace(
array(
'<?',
'?>'),
array(
'< ?',
'? >'), $componentCode);
93 self::checkPhpCode(
$k) ||
94 self::checkPhpCode($v)
103 mb_substr(
$code, 0, 2) ==
'={' &&
104 mb_substr(
$code, -1, 1) ==
'}' &&
130 if (isset ($manifest[
'nodes'][$selector][
'extra']))
133 $allowedProps = $manifest[
'nodes'][$selector][
'extra'];
135 if (History::isActive())
137 foreach ($allowedProps as
$code => $prop)
139 $propsBefore[
$code] = self::transformPropValue(
148 if (isset($allowedProps[
$code]))
150 $updateProps[
$code] = self::transformPropValue(
156 unset($updateProps[
$code]);
160 if (!empty($updateProps))
164 array_key_exists(
'SECTION_ID', $updateProps) &&
165 !trim($updateProps[
'SECTION_ID'])
168 $updateProps[
'SECTION_ID'] =
'={$sectionId}';
171 $newContent = self::saveComponent(
177 foreach ($doc->getChildNodesArray() as $node)
179 $node->getParentNode()->removeChild($node);
182 $doc->loadHTML($newContent);
184 if (History::isActive())
186 $propsAfter = array_merge($propsBefore, $updateProps);
188 $history->push(
'EDIT_COMPONENT', [
190 'selector' => $selector,
192 'valueBefore' => $propsBefore,
193 'valueAfter' => $propsAfter,
210 !isset($manifest[
'extra'][
'editable']) ||
211 !is_array($manifest[
'extra'][
'editable'])
218 $editable = $manifest[
'extra'][
'editable'];
222 !isset($manifestFull[
'attrs']) ||
223 !is_array($manifestFull[
'attrs'])
226 $manifestFull[
'attrs'] =
array();
230 !isset($manifestFull[
'style']) ||
231 !is_array($manifestFull[
'style'])
234 $manifestFull[
'style'] =
array();
237 $manifestFull[
'disableCache'] =
true;
238 $manifest[
'allowInlineEdit'] =
false;
240 $originalStyleBlock = isset($manifestFull[
'style'][
'block'])
241 ? $manifestFull[
'style'][
'block']
245 $components = \PHPParser::parseScript($block->
getContent());
247 foreach ($components as $component)
249 foreach ($component[
'DATA'][
'PARAMS'] as
$key => $param)
253 && stripos($param,
'={$classBlock->get') !==
false
254 && $value = $classBlock->get(
$key)
257 $component[
'DATA'][
'PARAMS'][
$key] = $value;
266 $component[
'DATA'][
'COMPONENT_NAME']
269 $component[
'DATA'][
'COMPONENT_NAME'],
270 $component[
'DATA'][
'TEMPLATE_NAME'],
272 self::$predefineForDynamicProps
274 if (isset($propsTemplate[
'PARAMETERS']))
276 $propsTemplate = $propsTemplate[
'PARAMETERS'];
278 $props = @\CComponentUtil::getComponentProps(
279 $component[
'DATA'][
'COMPONENT_NAME'],
280 self::$predefineForDynamicProps
282 if (isset(
$props[
'PARAMETERS']))
286 if (!empty($propsTemplate) && is_array($propsTemplate))
288 foreach ($propsTemplate as
$code => $prop)
294 $styleAttrs =
array();
296 !isset($manifestFull[
'style']) ||
297 !is_array($manifestFull[
'style'])
300 $manifestFull[
'style'] =
array(
305 else if (!isset($manifestFull[
'style'][
'nodes']))
307 $manifestFull[
'style'] =
array(
308 'nodes' => $manifestFull[
'style']
311 $manifestFull[
'style'][
'block'] = array_merge(
array(
312 'name' => isset($componentDesc[
'NAME'])
313 ? $componentDesc[
'NAME']
316 'additional' =>
array(
318 'name' => Loc::getMessage(
'LANDING_NODE_CMP_STYLE_BLOCK'),
319 'attrs' => &$styleAttrs
322 ), $originalStyleBlock);
323 foreach ($editable as $field => $fieldItem)
325 if (isset(
$props[$field]))
328 $newExtra[$field] =
$props[$field];
329 $newExtra[$field][
'VALUE'] = $component[
'DATA'][
'PARAMS'][$field] ??
null;
335 $propType = self::transformPropType(
array(
336 'name' => $fieldItem[
'name'] ?? $newExtra[$field][
'NAME'],
337 'style' => isset($fieldItem[
'style'])
338 && $fieldItem[
'style'],
339 'original_type' =>
'component',
340 'component_type' => $newExtra[$field][
'TYPE'] ??
'',
341 'attribute' => $field,
342 'value' => self::preparePropValue(
343 $newExtra[$field][
'VALUE'],
346 'default_value' => $newExtra[$field][
'DEFAULT'] ??
null,
348 'allowInlineEdit' =>
false
349 ) + $fieldItem, $newExtra[$field]);
350 $newExtra[$field][
'ATTRIBUTE_TYPE'] = $propType[
'type'];
351 if ($propType[
'style'])
354 $styleAttrs[] = $propType;
362 if (empty($styleAttrs))
364 if ($originalStyleBlock)
366 $manifestFull[
'style'][
'block'] = $originalStyleBlock;
370 unset($manifestFull[
'style'][
'block']);
374 if (!empty($newExtra))
376 $manifest[
'extra'] = $newExtra;
392 if (isset($prop[
'TYPE']))
395 $prop[
'TYPE'] ==
'CUSTOM' &&
396 isset($prop[
'JS_EVENT'])
399 $prop[
'TYPE'] = $prop[
'TYPE'] .
'_' . $prop[
'JS_EVENT'];
402 switch ($prop[
'TYPE'])
406 $item[
'items'] =
array();
407 if (isset($prop[
'MULTIPLE']) && $prop[
'MULTIPLE'] ==
'Y')
409 $item[
'type'] =
'multiselect';
410 if (!is_array($item[
'value']))
412 $item[
'value'] =
array($item[
'value']);
417 $prop[
'MULTIPLE'] =
'N';
418 $item[
'type'] =
'dropdown';
420 if (isset($prop[
'VALUES']) && is_array($prop[
'VALUES']))
422 foreach ($prop[
'VALUES'] as
$code =>
$val)
424 $item[
'items'][] =
array(
428 $prop[
'MULTIPLE'] ==
'Y' &&
429 in_array(
$code, $item[
'value'])
430 ) ||
$code == $item[
'value']
438 $item[
'type'] =
'checkbox';
441 'name' => $item[
'name'],
444 (isset($item[
'value']) && $item[
'value'] !==
'')
450 $item[
'compact'] =
true;
451 unset($item[
'name']);
454 case 'CUSTOM_initDraggableAddControl':
456 $item[
'type'] =
'catalog-view';
457 $item[
'items'] =
array(
458 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-1.svg',
'value' =>
'0'),
459 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-2.svg',
'value' =>
'1'),
460 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-3.svg',
'value' =>
'2'),
461 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-4.svg',
'value' =>
'3'),
462 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-1-4.svg',
'value' =>
'4'),
463 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-4-1.svg',
'value' =>
'5'),
464 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-6.svg',
'value' =>
'6'),
465 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-1-6.svg',
'value' =>
'7'),
466 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-6-1.svg',
'value' =>
'8'),
467 array(
'name' =>
'',
'image' =>
'/bitrix/images/landing/catalog_images/preset-line.svg',
'value' =>
'9')
469 $jsArray = \Cutil::jsObjectToPhp($item[
'value'],
true);
470 $item[
'value'] =
array();
471 if (is_array($jsArray))
473 foreach ($jsArray as
$val)
475 if (isset(
$val[
'VARIANT']))
477 $item[
'value'][] = (int)
$val[
'VARIANT'];
483 case 'CUSTOM_initPositionControl':
485 $item[
'type'] =
'position';
486 $item[
'items'] =
array(
487 'top-left' =>
array(
'content' =>
'',
'value' =>
'top-left'),
488 'top-center' =>
array(
'content' =>
'',
'value' =>
'top-center'),
489 'top-right' =>
array(
'content' =>
'',
'value' =>
'top-right'),
490 'middle-left' =>
array(
'content' =>
'',
'value' =>
'middle-left'),
491 'middle-center' =>
array(
'content' =>
'',
'value' =>
'middle-center'),
492 'middle-right' =>
array(
'content' =>
'',
'value' =>
'middle-right'),
493 'bottom-left' =>
array(
'content' =>
'',
'value' =>
'bottom-left'),
494 'bottom-center' =>
array(
'content' =>
'',
'value' =>
'bottom-center'),
495 'bottom-right' =>
array(
'content' =>
'',
'value' =>
'bottom-right')
499 case 'CUSTOM_initDraggableOrderControl':
501 $item[
'type'] =
'sortable-list';
502 $item[
'items'] =
array();
503 if (!is_array($item[
'value']))
505 $item[
'value'] = explode(
',', $item[
'value']);
507 $items = Json::decode($prop[
'JS_DATA']);
512 $item[
'items'][] =
array(
515 'preview' =>
'/bitrix/images/landing/catalog_images/preview/'.mb_strtolower(
$code) .
'.svg?v3'
521 case 'CUSTOM_initColorField':
523 $item[
'type'] =
'color';
524 $item[
'subtype'] =
'color';
528 case 'CUSTOM_initIconField':
530 $item[
'type'] =
'icon';
531 $item[
'disableLink'] =
'true';
532 $item[
'value'] = is_array($item[
'value']) && !empty($item[
'value'])
539 case 'CUSTOM_initImageField':
542 $item[
'type'] =
'image';
543 $item[
'disableLink'] =
'true';
544 $data = \Cutil::jsObjectToPhp($prop[
'JS_DATA'],
true);
545 $item[
'dimensions'] =
$data[
'dimensions'] ??
'false';
550 case 'CUSTOM_initUserSelectField':
552 $item[
'type'] =
'user-select';
553 $item[
'value'] = (int)$item[
'value'] > 0 ? $item[
'value'] : $prop[
'DEFAULT'];
554 $item[
'value'] = (int)$item[
'value'];
559 case 'CUSTOM_initDynamicSource':
561 $item[
'type'] =
'dynamic_source';
562 $item[
'hideSort'] =
'true';
563 $data = \Cutil::jsObjectToPhp($prop[
'JS_DATA'],
true);
564 if (
$data[
'sources'] && is_array(
$data[
'sources']))
566 $item[
'sources'] =
$data[
'sources'];
568 if (
$data[
'title'] && is_string(
$data[
'title']))
570 $item[
'title'] =
$data[
'title'];
572 if (
$data[
'stubText'] && is_string(
$data[
'stubText']))
574 $item[
'stubText'] =
$data[
'stubText'];
576 if (
$data[
'useLink'] && is_string(
$data[
'useLink']))
578 $item[
'useLink'] =
$data[
'useLink'];
580 if (
$data[
'linkType'] && is_string(
$data[
'linkType']))
582 $item[
'linkType'] =
$data[
'linkType'];
590 if (!isset($item[
'type']) || !$item[
'type'])
592 $item[
'type'] =
'text';
594 switch ($item[
'type'])
598 $item[
'disableBlocks'] =
true;
604 $filterId =
'LANDING_FLT_' . $item[
'attribute'];
606 'bitrix:main.ui.filter',
610 'FILTER_ID' => $filterId,
611 'FILTER' => isset($item[
'fields'])
614 'DISABLE_SEARCH' =>
true,
615 'ENABLE_LABEL' =>
true
618 $item[
'html'] = ob_get_clean();
619 $item[
'filterId'] = $filterId;
624 $item[
'placeholder'] =
'';
643 if (isset($prop[
'type']))
645 switch ($prop[
'type'])
649 if ($value && isset($prop[
'entityType']))
653 $prop[
'entityType'] ==
'element' &&
654 $value !=
'={$elementCode}' &&
655 $value !=
'={$elementId}'
658 $value =
'#catalogElement' . $value;
661 $prop[
'entityType'] ==
'section' &&
662 $value !=
'={$sectionCode}' &&
663 $value !=
'={$sectionId}'
666 $value =
'#catalogSection' . $value;
683 if (!is_array($value))
685 $value = \CUtil::jsObjectToPhp($value,
true);
688 if (isset($prop[
'TYPE']))
691 $prop[
'TYPE'] ==
'CUSTOM' &&
692 isset($prop[
'JS_EVENT'])
695 $prop[
'TYPE'] = $prop[
'TYPE'] .
'_' . $prop[
'JS_EVENT'];
698 isset($prop[
'MULTIPLE']) &&
699 $prop[
'MULTIPLE'] ==
'Y' &&
703 $value =
array($value);
706 switch ($prop[
'TYPE'])
710 if (is_array($value))
712 $value = array_shift($value);
720 case 'CUSTOM_initDraggableAddControl':
723 if (is_array($value))
725 foreach ($value as
$val)
733 $value = \CUtil::phpToJsObject($newValue);
736 case 'CUSTOM_initDraggableOrderControl':
738 if (is_array($value))
740 $value = implode(
',', $value);
746 if (isset($prop[
'ATTRIBUTE_TYPE']))
748 switch ($prop[
'ATTRIBUTE_TYPE'])
752 if (preg_match(
'/^#landing([\d]+)$/', $value,
$matches))
754 $lansing = \Bitrix\Landing\Landing::createInstance(
$matches[1], [
755 'skip_blocks' =>
true
757 if ($lansing->exist())
759 $value = $lansing->getPublicUrl();
762 else if (preg_match(
'/^#catalog(Element|Section)([\d]+)$/', $value,
$matches))
786 return \Bitrix\Landing\PublicAction\Utils::getIblockURL($elementId, $urlType);
802 $params[
'type'] =
'CRM_PRODUCT_CATALOG';
803 $params[
'default_product'] =
false;
828 if (isset($manifest[
'attrs'][$selector]))
830 $allowedProps = $manifest[
'attrs'][$selector];
831 foreach ($allowedProps as $attr)
833 if (!self::checkPhpCode($attr[
'value']))
835 $data[$attr[
'attribute']] = $attr[
'value'];
842 isset($manifest[
'style'][
'block'][
'additional']) &&
843 is_array($manifest[
'style'][
'block'][
'additional'])
846 foreach ($manifest[
'style'][
'block'][
'additional'] as $item)
849 isset($item[
'attrs']) &&
850 is_array($item[
'attrs'])
853 foreach ($item[
'attrs'] as $attr)
855 if (!self::checkPhpCode($attr[
'value']))
857 $data[$attr[
'attribute']] = $attr[
'value'];
getManifest(bool $extended=false, bool $missCache=false, array $params=array())
static getIblockParams($key=false)
static getIblockURL($elementId, $urlType)
static setPredefineForDynamicProps(array $additionalVals)
static transformPropValue($value, $prop)
static prepareManifest(Block $block, array $manifest, array &$manifestFull=array())
static $predefineForDynamicProps
static checkPhpCode($code)
static preparePropValue($value, $prop)
static getNode(Block $block, $selector)
static transformPropType(array $item, $prop)
static saveComponent($content, $code, array $params)
static saveNode(Block $block, $selector, array $data)
static get($moduleId, $name, $default="", $siteId=false)
static GetTemplateProps($componentName, $templateName, $siteTemplate="", $arCurrentValues=array())
static GetComponentDescr($componentName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']