1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Field.php
См. документацию.
1<?php
2
4
5class Field
6{
7 protected array $property;
8 protected array $settings;
9
10 public function __construct(array $property)
11 {
12 $this->property = $property;
13 $this->settings = (
14 isset($this->property['SETTINGS']) && is_array($this->property['SETTINGS'])
15 ? $this->property['SETTINGS']
16 : []
17 );
18 }
19
20 public function getId(): string
21 {
22 return (string)$this->property['FIELD_ID'];
23 }
24
25 public function getIntId(): int
26 {
27 return (int)$this->property['ID'];
28 }
29
30 public function getSort(): int
31 {
32 return (int)$this->property['SORT'];
33 }
34
35 public function getName(): string
36 {
37 return (string)$this->property['NAME'];
38 }
39
40 public function getType()
41 {
42 return $this->property['TYPE'];
43 }
44
45 public function isRequired(): bool
46 {
47 return $this->property['IS_REQUIRED'] === 'Y';
48 }
49
50 public function isMultiple(): bool
51 {
52 return $this->property['MULTIPLE'] === 'Y';
53 }
54
55 public function getDefaultValue(): mixed
56 {
57 $defaultValue = $this->property['DEFAULT_VALUE'];
58
60 {
61 if ($this->getId() === 'ACTIVE_FROM')
62 {
63 if ($defaultValue === '=now')
64 {
65 return ConvertTimeStamp(time() + \CTimeZone::GetOffset(), 'FULL');
66 }
67
68 if ($defaultValue === '=today')
69 {
70 return ConvertTimeStamp(time() + \CTimeZone::GetOffset(), "SHORT");
71 }
72
73 return '';
74 }
75
76 if ($this->getId() === 'PREVIEW_PICTURE' || $this->getId() === 'DETAIL_PICTURE')
77 {
78 return '';
79 }
80
81 return $defaultValue;
82 }
83
84 if (array_key_exists('GetPublicEditHTML', $this->getPropertyUserType()) || $this->getType() === 'F')
85 {
86 if ($this->getType() === 'N:Sequence' && empty($defaultValue))
87 {
88 $seq = new \CIBlockSequence($this->getIBlockId(), $this->getIntId());
89 $defaultValue = $seq->GetNext();
90 }
91
92 return [
93 'n0' => [
94 'VALUE' => $defaultValue ?: '',
95 'DESCRIPTION' => '',
96 ],
97 ];
98 }
99
100 if ($this->getType() === 'G' || $this->getType() === 'E' || $this->getType() === 'L')
101 {
102 return is_array($defaultValue) ? $defaultValue : [$defaultValue];
103 }
104
105 $value = [
106 'n0' => ['VALUE' => $defaultValue, 'DESCRIPTION' => ''],
107 ];
108
109 if ($defaultValue !== '' && $this->isMultiple())
110 {
111 $value['n1'] = ['VALUE' => '', 'DESCRIPTION' => ''];
112 }
113
114 return $value;
115 }
116
117 public function getProperty(): array
118 {
119 return $this->property;
120 }
121
122 public function getPropertyType(): ?string
123 {
124 return is_string($this->property['PROPERTY_TYPE'] ?? null) ? $this->property['PROPERTY_TYPE'] : null;
125 }
126
127 public function getSettings(): array
128 {
129 return $this->settings;
130 }
131
132 private function getPropertyUserType(): array
133 {
134 return is_array($this->property['PROPERTY_USER_TYPE'] ?? null) ? $this->property['PROPERTY_USER_TYPE'] : [];
135 }
136
137 private function getIBlockId(): int
138 {
139 return (int)$this->property['IBLOCK_ID'];
140 }
141
142 private function getUserTypeSettings(): array
143 {
144 return isset($this->property['USER_TYPE_SETTINGS']) ? (array)$this->property['USER_TYPE_SETTINGS'] : [];
145 }
146
147 public function isShowInAddForm(): bool
148 {
149 if (in_array($this->getId(), ['DATE_CREATE', 'TIMESTAMP_X', 'CREATED_BY', 'MODIFIED_BY']))
150 {
151 return false;
152 }
153
154 if (!isset($this->settings['SHOW_ADD_FORM']))
155 {
156 return true;
157 }
158
159 return $this->settings['SHOW_ADD_FORM'] === 'Y';
160 }
161
162 public function isShowInEditForm(): bool
163 {
164 if (!isset($this->settings['SHOW_EDIT_FORM']))
165 {
166 return true;
167 }
168
169 return $this->settings['SHOW_EDIT_FORM'] === 'Y';
170 }
171
172 public function isAddReadOnlyField(): bool
173 {
174 if ($this->getType() === 'N:Sequence')
175 {
176 if (isset($this->getUserTypeSettings()['write']))
177 {
178 return $this->getUserTypeSettings()['write'] === 'N';
179 }
180
181 return true;
182 }
183
184 return isset($this->settings['ADD_READ_ONLY_FIELD']) && $this->settings['ADD_READ_ONLY_FIELD'] === 'Y';
185 }
186
187 public function isEditReadOnlyField(): bool
188 {
189 if ($this->getType() === 'N:Sequence')
190 {
191 if (isset($this->getUserTypeSettings()['write']))
192 {
193 return $this->getUserTypeSettings()['write'] === 'N';
194 }
195
196 return true;
197 }
198
199 return isset($this->settings['EDIT_READ_ONLY_FIELD']) && $this->settings['EDIT_READ_ONLY_FIELD'] === 'Y';
200 }
201}
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
isEditReadOnlyField()
Определения Field.php:187
isShowInEditForm()
Определения Field.php:162
getName()
Определения Field.php:35
array $property
Определения Field.php:7
getPropertyType()
Определения Field.php:122
isShowInAddForm()
Определения Field.php:147
getType()
Определения Field.php:40
__construct(array $property)
Определения Field.php:10
getSort()
Определения Field.php:30
getProperty()
Определения Field.php:117
getIntId()
Определения Field.php:25
isRequired()
Определения Field.php:45
isMultiple()
Определения Field.php:50
isAddReadOnlyField()
Определения Field.php:172
getSettings()
Определения Field.php:127
getDefaultValue()
Определения Field.php:55
array $settings
Определения Field.php:8
static IsField($type_id)
Определения listfieldtypes.php:26
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения Field.php:3