47 $components = \PHPParser::parseScript($content);
48 foreach ($components as $component)
51 if ($component[
'DATA'][
'COMPONENT_NAME'] == $code)
53 $params = array_merge($component[
'DATA'][
'PARAMS'], $params);
54 $componentCode = ($component[
'DATA'][
'VARIABLE'] ? $component[
'DATA'][
'VARIABLE'] .
'=' :
'') .
55 '$APPLICATION->IncludeComponent(' . PHP_EOL .
56 "\t" .
'"' . $component[
'DATA'][
'COMPONENT_NAME'] .
'", ' . PHP_EOL .
57 "\t" .
'"' . $component[
'DATA'][
'TEMPLATE_NAME'] .
'", ' . PHP_EOL .
58 "\t" .
'array(' . PHP_EOL .
59 "\t" .
"\t" . \PHPParser::returnPHPStr2($params) . PHP_EOL .
60 "\t" .
'),' . PHP_EOL .
61 "\t" . ($component[
'DATA'][
'PARENT_COMP'] ? $component[
'DATA'][
'PARENT_COMP'] :
'false') .
62 (!empty($component[
'DATA'][
'FUNCTION_PARAMS']) ?
',' . PHP_EOL .
63 "\t" .
'array(' . PHP_EOL .
"\t" .
"\t" . \PHPParser::returnPHPStr2($component[
'DATA'][
'FUNCTION_PARAMS']) . PHP_EOL .
64 "\t" .
')' :
'') . PHP_EOL .
66 $componentCode = str_replace(array(
'<?',
'?>'), array(
'< ?',
'? >'), $componentCode);
67 $content = mb_substr($content, 0, $component[
'START']).$componentCode.mb_substr($content, $component[
'END']);
84 foreach ($code as $k => $v)
87 self::checkPhpCode($k) ||
88 self::checkPhpCode($v)
97 mb_substr($code, 0, 2) ==
'={' &&
98 mb_substr($code, -1, 1) ==
'}' &&
119 $manifest = $block->getManifest();
120 if (isset($manifest[
'nodes'][$selector][
'extra']))
122 $updateProps = array();
123 $allowedProps = $manifest[
'nodes'][$selector][
'extra'];
124 foreach ($data as $code => $val)
126 if (isset($allowedProps[$code]))
128 $updateProps[$code] = self::transformPropValue(
132 if (self::checkPhpCode(array($code => $updateProps[$code])))
134 unset($updateProps[$code]);
138 if (!empty($updateProps))
142 array_key_exists(
'SECTION_ID', $updateProps) &&
143 !trim($updateProps[
'SECTION_ID'])
146 $updateProps[
'SECTION_ID'] =
'={$sectionId}';
148 $doc = $block->getDom();
149 $newContent = self::saveComponent(
155 foreach ($doc->getChildNodesArray() as $node)
157 $node->getParentNode()->removeChild($node);
160 $doc->loadHTML($newContent);
175 !isset($manifest[
'extra'][
'editable']) ||
176 !is_array($manifest[
'extra'][
'editable'])
183 $editable = $manifest[
'extra'][
'editable'];
187 !isset($manifestFull[
'attrs']) ||
188 !is_array($manifestFull[
'attrs'])
191 $manifestFull[
'attrs'] = array();
195 !isset($manifestFull[
'style']) ||
196 !is_array($manifestFull[
'style'])
199 $manifestFull[
'style'] = array();
202 $manifestFull[
'disableCache'] =
true;
203 $manifest[
'allowInlineEdit'] =
false;
205 $originalStyleBlock = isset($manifestFull[
'style'][
'block'])
206 ? $manifestFull[
'style'][
'block']
210 $components = \PHPParser::parseScript($block->getContent());
211 $classBlock = $block->getBlockClass();
212 foreach ($components as $component)
214 foreach ($component[
'DATA'][
'PARAMS'] as $key => $param)
218 && stripos($param,
'={$classBlock->get') !==
false
219 && $value = $classBlock->get($key)
222 $component[
'DATA'][
'PARAMS'][$key] = $value;
225 $componentName = $manifest[
'code'];
227 if ($component[
'DATA'][
'COMPONENT_NAME'] == $componentName)
230 $componentDesc = \CComponentUtil::GetComponentDescr(
231 $component[
'DATA'][
'COMPONENT_NAME']
233 $propsTemplate = @\CComponentUtil::GetTemplateProps(
234 $component[
'DATA'][
'COMPONENT_NAME'],
235 $component[
'DATA'][
'TEMPLATE_NAME'],
237 self::$predefineForDynamicProps
239 if (isset($propsTemplate[
'PARAMETERS']))
241 $propsTemplate = $propsTemplate[
'PARAMETERS'];
243 $props = @\CComponentUtil::getComponentProps(
244 $component[
'DATA'][
'COMPONENT_NAME'],
245 self::$predefineForDynamicProps
247 if (isset($props[
'PARAMETERS']))
249 $props = $props[
'PARAMETERS'];
251 if (!empty($propsTemplate) && is_array($propsTemplate))
253 foreach ($propsTemplate as $code => $prop)
255 $props[$code] = $prop;
259 $styleAttrs = array();
261 !isset($manifestFull[
'style']) ||
262 !is_array($manifestFull[
'style'])
265 $manifestFull[
'style'] = array(
270 else if (!isset($manifestFull[
'style'][
'nodes']))
272 $manifestFull[
'style'] = array(
273 'nodes' => $manifestFull[
'style']
276 $manifestFull[
'style'][
'block'] = array_merge(array(
277 'name' => isset($componentDesc[
'NAME'])
278 ? $componentDesc[
'NAME']
281 'additional' => array(
284 'attrs' => &$styleAttrs
287 ), $originalStyleBlock);
288 foreach ($editable as $field => $fieldItem)
290 if (isset($props[$field]))
293 $newExtra[$field] = $props[$field];
294 $newExtra[$field][
'VALUE'] = isset($component[
'DATA'][
'PARAMS'][$field])
295 ? $component[
'DATA'][
'PARAMS'][$field]
298 if (!isset($manifestFull[
'attrs'][$componentName]))
300 $manifestFull[
'attrs'][$componentName] = array();
302 $propType = self::transformPropType(array(
303 'name' => isset($fieldItem[
'name'])
305 : $newExtra[$field][
'NAME'],
306 'style' => isset($fieldItem[
'style'])
307 && $fieldItem[
'style'],
308 'original_type' =>
'component',
309 'component_type' => isset($newExtra[$field][
'TYPE'])
310 ? $newExtra[$field][
'TYPE']
312 'attribute' => $field,
313 'value' => self::preparePropValue(
314 $newExtra[$field][
'VALUE'],
318 'allowInlineEdit' => false
319 ) + $fieldItem, $newExtra[$field]);
320 $newExtra[$field][
'ATTRIBUTE_TYPE'] = $propType[
'type'];
321 if ($propType[
'style'])
323 $propType[
'selector'] = $componentName;
324 $styleAttrs[] = $propType;
328 $manifestFull[
'attrs'][$componentName][] = $propType;
332 if (empty($styleAttrs))
334 if ($originalStyleBlock)
336 $manifestFull[
'style'][
'block'] = $originalStyleBlock;
340 unset($manifestFull[
'style'][
'block']);
344 if (!empty($newExtra))
346 $manifest[
'extra'] = $newExtra;
582 if (!is_array($value))
584 $value = \CUtil::jsObjectToPhp($value);
587 if (isset($prop[
'TYPE']))
590 $prop[
'TYPE'] ==
'CUSTOM' &&
591 isset($prop[
'JS_EVENT'])
594 $prop[
'TYPE'] = $prop[
'TYPE'] .
'_' . $prop[
'JS_EVENT'];
597 isset($prop[
'MULTIPLE']) &&
598 $prop[
'MULTIPLE'] ==
'Y' &&
602 $value = array($value);
605 switch ($prop[
'TYPE'])
609 if (is_array($value))
611 $value = array_shift($value);
619 case 'CUSTOM_initDraggableAddControl':
622 if (is_array($value))
624 foreach ($value as $val)
632 $value = \CUtil::phpToJsObject($newValue);
635 case 'CUSTOM_initDraggableOrderControl':
637 if (is_array($value))
639 $value = implode(
',', $value);
645 if (isset($prop[
'ATTRIBUTE_TYPE']))
647 switch ($prop[
'ATTRIBUTE_TYPE'])
651 if (preg_match(
'/^#landing([\d]+)$/', $value, $matches))
653 $lansing = \Bitrix\Landing\Landing::createInstance($matches[1], [
654 'skip_blocks' =>
true
656 if ($lansing->exist())
658 $value = $lansing->getPublicUrl();
661 else if (preg_match(
'/^#catalog(Element|Section)([\d]+)$/', $value, $matches))
663 $value = $matches[2];