Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
node.php
1<?php
2namespace Bitrix\Landing;
3
4abstract class Node
5{
10 abstract public static function getHandlerJS();
11
19 abstract public static function saveNode(\Bitrix\Landing\Block $block, $selector, array $data);
20
27 abstract public static function getNode(\Bitrix\Landing\Block $block, $selector);
28
36 //abstract public static function prepareManifest(\Bitrix\Landing\Block $block, array $manifest, array &$manifestFull = array());
37
44 //abstract public static function getSearchableNode($block, $selector);
45
51 protected static function prepareSearchContent($value)
52 {
53 if (is_string($value))
54 {
55 $value = strip_tags($value);
56 $value = preg_replace('/[\s]{2,}/', ' ', $value);
57 $value = trim($value);
58 }
59
60 return $value;
61 }
62
69 public static function prepareFieldDefinition(array $field)
70 {
71 $field = array_change_key_case($field, CASE_LOWER);
72 $field['id'] = static::prepareStringValue($field, 'id');
73 $field['type'] = static::prepareStringValue($field, 'type');
74 $field['name'] = static::prepareStringValue($field, 'name');
75 if (empty($field['id']) || empty($field['type']) || empty($field['name']))
76 {
77 return null;
78 }
79
81 $className = Node\Type::getClassName($field['type']);
82 if (!class_exists($className))
83 {
84 return null;
85 }
86 return $className::validateFieldDefinition($field);
87 }
88
93 protected static function validateFieldDefinition(array $field)
94 {
95 return [
96 'id' => $field['id'],
97 'type' => $field['type'],
98 'name' => $field['name']
99 ];
100 }
101
107 protected static function prepareStringValue(array $row, $name)
108 {
109 if (empty($row[$name]) || !is_string($row[$name]))
110 {
111 return null;
112 }
113 $row[$name] = trim($row[$name]);
114 if ($row[$name] === '')
115 {
116 return null;
117 }
118 return $row[$name];
119 }
120}
static prepareSearchContent($value)
Definition node.php:51
static validateFieldDefinition(array $field)
Definition node.php:93
static getNode(\Bitrix\Landing\Block $block, $selector)
static saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
static prepareStringValue(array $row, $name)
Definition node.php:107