1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
field.php
См. документацию.
1<?php
2namespace Bitrix\Main\Filter;
3
4class Field
5{
7 protected $dataProvider = null;
9 protected $id = '';
11 protected $name = '';
13 protected $type = '';
15 protected $isDefault = false;
17 protected $data = null;
19 protected $isPartial = false;
21 protected $sectionId = '';
22 protected $iconParams = [];
23
24 protected ?string $subtype = null;
25
27 {
28 $this->dataProvider = $dataProvider;
29 $this->id = $id;
30
31 if(!is_array($params))
32 {
33 $params = [];
34 }
35
36 $this->name = $params['name'] ?? $id;
37 $this->type = $params['type'] ?? '';
38 $this->isDefault = $params['default'] ?? false;
39
40 $this->isPartial = $params['partial'] ?? false;
41 $this->data = $params['data'] ?? null;
42 $this->subtype = $params['subtype'] ?? null;
43 }
44
49 public function getDataProvider()
50 {
52 }
53
59 {
60 $this->dataProvider = $dataProvider;
61 }
62
66 protected function prepareData()
67 {
68 return $this->dataProvider->prepareFieldData($this->id);
69 }
70
74 public function prepareHtml()
75 {
76 return $this->dataProvider->prepareFieldHtml($this);
77 }
78
82 public function getId()
83 {
84 return $this->id;
85 }
86
90 public function setID($id)
91 {
92 $this->id = $id;
93 }
94
98 public function getName()
99 {
100 return $this->name;
101 }
102
106 public function setName($name)
107 {
108 $this->name = $name;
109 }
110
114 public function getType()
115 {
116 return $this->type;
117 }
118
122 public function setType($type)
123 {
124 $this->type = $type;
125 }
126
130 public function isDefault()
131 {
132 return $this->isDefault;
133 }
134
138 public function markAsDefault($isDefault)
139 {
140 $this->isDefault = $isDefault;
141 }
142
148 public function isPartial()
149 {
150 return $this->isPartial;
151 }
152
156 public function getData()
157 {
158 return $this->data;
159 }
160
165 public function getDataItem($key)
166 {
167 return $this->data !== null && isset($this->data[$key]) ? $this->data[$key] : null;
168 }
169
174 public function getSectionId(): string
175 {
176 return $this->sectionId;
177 }
178
183 public function setSectionId(string $sectionId): void
184 {
185 $this->sectionId = $sectionId;
186 }
187
191 public function getIconParams(): array
192 {
193 return $this->iconParams;
194 }
195
200 public function setIconParams(array $iconParams): void
201 {
202 $this->iconParams = $iconParams;
203 }
204
210 public function assemble()
211 {
212 if(!$this->isPartial)
213 {
214 return;
215 }
216
217 $this->data = $this->prepareData();
218 $this->isPartial = false;
219
220 if(is_array($this->data))
221 {
222 $html = $this->prepareHtml();
223 if($html !== '')
224 {
225 $this->data['html'] = $html;
226 }
227 }
228 }
229
234 public function toArray(array $options = null)
235 {
236 if(!is_array($options))
237 {
238 $options = [];
239 }
240
241 $result = [ 'id' => $this->id, 'name' => $this->name ];
242 if($this->type !== '')
243 {
244 $result['type'] = $this->type;
245 }
246
247 if($this->isDefault)
248 {
249 $result['default'] = true;
250 }
251
252 if ($this->sectionId !== '')
253 {
254 $result['sectionId'] = $this->sectionId;
255 }
256 if (!empty($this->iconParams))
257 {
258 $result['icon'] = $this->iconParams;
259 }
260
261 if(isset($options['lightweight']) && $options['lightweight'])
262 {
263 $result['lightweight'] = true;
264 return $result;
265 }
266
267 if($this->isPartial())
268 {
269 $this->assemble();
270 }
271
272 if(is_array($this->data))
273 {
274 foreach($this->data as $key => $data)
275 {
276 $result[$key] = $data;
277 }
278 }
279
280 if ($this->subtype)
281 {
282 $result['subtype'] = $this->subtype;
283 }
284
285 return $result;
286 }
287
288 public function getSubtype(): ?string
289 {
290 return $this->subtype;
291 }
292
293 public function setSubtype(?string $subtype): void
294 {
295 $this->subtype = $subtype;
296 }
297}
isDefault()
Определения field.php:130
getId()
Определения field.php:82
setName($name)
Определения field.php:106
getDataItem($key)
Определения field.php:165
getName()
Определения field.php:98
setDataProvider(DataProvider $dataProvider)
Определения field.php:58
isPartial()
Определения field.php:148
getSectionId()
Определения field.php:174
__construct(DataProvider $dataProvider, $id, array $params=null)
Определения field.php:26
string $subtype
Определения field.php:24
markAsDefault($isDefault)
Определения field.php:138
getSubtype()
Определения field.php:288
prepareData()
Определения field.php:66
$isDefault
Определения field.php:15
setIconParams(array $iconParams)
Определения field.php:200
$iconParams
Определения field.php:22
$data
Определения field.php:17
setSubtype(?string $subtype)
Определения field.php:293
getData()
Определения field.php:156
getIconParams()
Определения field.php:191
getType()
Определения field.php:114
setSectionId(string $sectionId)
Определения field.php:183
$isPartial
Определения field.php:19
$type
Определения field.php:13
getDataProvider()
Определения field.php:49
$dataProvider
Определения field.php:7
$name
Определения field.php:11
assemble()
Определения field.php:210
$sectionId
Определения field.php:21
setType($type)
Определения field.php:122
setID($id)
Определения field.php:90
toArray(array $options=null)
Определения field.php:234
$id
Определения field.php:9
prepareHtml()
Определения field.php:74
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(empty($signedUserToken)) $key
Определения quickway.php:257
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799