1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sectiontable.php
См. документацию.
1<?php
2namespace Bitrix\Iblock;
3
4use Bitrix\Main\Localization\Loc;
5use Bitrix\Main\ORM;
6use Bitrix\Main\ORM\Event;
7use Bitrix\Main\ORM\EventResult;
8use Bitrix\Main\ORM\Fields\Validators;
9use Bitrix\Main\Type\DateTime;
10
60
62{
63 public const TYPE_TEXT = 'text';
64 public const TYPE_HTML = 'html';
65
66 private static array $oldValues = [];
67
73 public static function getTableName(): string
74 {
75 return 'b_iblock_section';
76 }
77
83 public static function getMap(): array
84 {
85 return [
86 'ID' => [
87 'data_type' => 'integer',
88 'primary' => true,
89 'autocomplete' => true,
90 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_ID_FIELD'),
91 ],
92 'TIMESTAMP_X' => [
93 'data_type' => 'datetime',
94 'required' => true,
95 'default_value' => function()
96 {
97 return new DateTime();
98 }
99 ,
100 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_TIMESTAMP_X_FIELD'),
101 ],
102 'MODIFIED_BY' => [
103 'data_type' => 'integer',
104 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_MODIFIED_BY_FIELD'),
105 ],
106 'DATE_CREATE' => [
107 'data_type' => 'datetime',
108 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_DATE_CREATE_FIELD'),
109 ],
110 'CREATED_BY' => [
111 'data_type' => 'integer',
112 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_CREATED_BY_FIELD'),
113 ],
114 'IBLOCK_ID' => [
115 'data_type' => 'integer',
116 'required' => true,
117 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_IBLOCK_ID_FIELD'),
118 ],
119 'IBLOCK_SECTION_ID' => [
120 'data_type' => 'integer',
121 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_IBLOCK_SECTION_ID_FIELD'),
122 ],
123 'ACTIVE' => [
124 'data_type' => 'boolean',
125 'values' => ['N', 'Y'],
126 'default_value' => 'Y',
127 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_ACTIVE_FIELD'),
128 ],
129 'GLOBAL_ACTIVE' => [
130 'data_type' => 'boolean',
131 'values' => ['N', 'Y'],
132 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_GLOBAL_ACTIVE_FIELD'),
133 ],
134 'SORT' => [
135 'data_type' => 'integer',
136 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_SORT_FIELD'),
137 ],
138 'NAME' => [
139 'data_type' => 'string',
140 'required' => true,
141 'validation' => function()
142 {
143 return [
144 new Validators\LengthValidator(null, 255),
145 ];
146 },
147 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_NAME_FIELD'),
148 ],
149 'PICTURE' => [
150 'data_type' => 'integer',
151 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_PICTURE_FIELD'),
152 ],
153 'LEFT_MARGIN' => [
154 'data_type' => 'integer',
155 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_LEFT_MARGIN_FIELD'),
156 ],
157 'RIGHT_MARGIN' => [
158 'data_type' => 'integer',
159 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_RIGHT_MARGIN_FIELD'),
160 ],
161 'DEPTH_LEVEL' => [
162 'data_type' => 'integer',
163 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_DEPTH_LEVEL_FIELD'),
164 ],
165 'DESCRIPTION' => [
166 'data_type' => 'text',
167 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_DESCRIPTION_FIELD'),
168 ],
169 'DESCRIPTION_TYPE' => [
170 'data_type' => 'enum',
171 'required' => true,
172 'values' => [
173 self::TYPE_TEXT,
174 self::TYPE_HTML,
175 ],
176 'default_value' => self::TYPE_TEXT,
177 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_DESCRIPTION_TYPE_FIELD'),
178 ],
179 'SEARCHABLE_CONTENT' => [
180 'data_type' => 'text',
181 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_SEARCHABLE_CONTENT_FIELD'),
182 ],
183 'CODE' => [
184 'data_type' => 'string',
185 'validation' => function()
186 {
187 return [
188 new Validators\LengthValidator(null, 255),
189 ];
190 },
191 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_CODE_FIELD'),
192 ],
193 'XML_ID' => [
194 'data_type' => 'string',
195 'validation' => function()
196 {
197 return [
198 new Validators\LengthValidator(null, 255),
199 ];
200 },
201 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_XML_ID_FIELD'),
202 ],
203 'TMP_ID' => [
204 'data_type' => 'string',
205 'validation' => function()
206 {
207 return [
208 new Validators\LengthValidator(null, 40),
209 ];
210 },
211 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_TMP_ID_FIELD'),
212 ],
213 'DETAIL_PICTURE' => [
214 'data_type' => 'integer',
215 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_DETAIL_PICTURE_FIELD'),
216 ],
217 'SOCNET_GROUP_ID' => [
218 'data_type' => 'integer',
219 'title' => Loc::getMessage('IBLOCK_SECTION_ENTITY_SOCNET_GROUP_ID_FIELD'),
220 ],
221 'IBLOCK' => [
222 'data_type' => 'Bitrix\Iblock\Iblock',
223 'reference' => ['=this.IBLOCK_ID' => 'ref.ID'],
224 ],
225 'PARENT_SECTION' => [
226 'data_type' => 'Bitrix\Iblock\Section',
227 'reference' => ['=this.IBLOCK_SECTION_ID' => 'ref.ID'],
228 ],
229 'CREATED_BY_USER' => [
230 'data_type' => 'Bitrix\Main\User',
231 'reference' => ['=this.CREATED_BY' => 'ref.ID'],
232 ],
233 'MODIFIED_BY_USER' => [
234 'data_type' => 'Bitrix\Main\User',
235 'reference' => ['=this.MODIFIED_BY' => 'ref.ID'],
236 ],
237 ];
238 }
239
246 public static function onBeforeAdd(Event $event): EventResult
247 {
248 $result = new EventResult;
249 $fields = $event->getParameter('fields');
250 if (!isset($fields['TIMESTAMP_X']))
251 {
252 $result->modifyFields([
253 'TIMESTAMP_X' => new DateTime(),
254 ]);
255 }
256
257 return $result;
258 }
259
260 public static function onAfterAdd(Event $event): void
261 {
263 $section = $event->getParameter('object');
264 $section->fill(['IBLOCK_ID', 'IBLOCK_SECTION_ID', 'NAME', 'SORT']);
265
266 // clear tag cache
267 \CIBlock::clearIblockTagCache($section->getIblockId());
268
269 // recount tree
270 \CIBlockSection::recountTreeAfterAdd($section->collectValues());
271 }
272
279 public static function onBeforeUpdate(Event $event): EventResult
280 {
281 $result = new EventResult;
282 $fields = $event->getParameter('fields');
283 if (!isset($fields['TIMESTAMP_X']))
284 {
285 $result->modifyFields([
286 'TIMESTAMP_X' => new DateTime(),
287 ]);
288 }
289
290 return $result;
291 }
292
293 public static function onUpdate(Event $event): void
294 {
296 $section = $event->getParameter('object');
297
298 // save old fields
299 $row = static::getRow([
300 'select' => [
301 'ID',
302 'IBLOCK_ID',
303 'SORT',
304 'NAME',
305 'IBLOCK_SECTION_ID',
306 'LEFT_MARGIN',
307 'RIGHT_MARGIN',
308 'DEPTH_LEVEL',
309 'ACTIVE',
310 ],
311 'filter' => [
312 '=ID' => $section->getId(),
313 ],
314 ]);
315 self::$oldValues = $row !== null ? $row : [];
316 }
317
318 public static function onAfterUpdate(Event $event): void
319 {
321 $section = $event->getParameter('object');
322 $section->fill(['IBLOCK_ID', 'IBLOCK_SECTION_ID', 'NAME', 'SORT', 'ACTIVE']);
323
324 // clear tag cache
325 \CIBlock::clearIblockTagCache($section->getIblockId());
326
327 // recount tree
328 \CIBlockSection::recountTreeAfterUpdate($section->collectValues(), self::$oldValues);
329 self::$oldValues = [];
330 }
331
332 public static function onDelete(Event $event): void
333 {
334 $section = static::wakeUpObject($event->getParameter('id'));
335 $section->fill(['IBLOCK_ID']);
336
337 // clear tag cache
338 \CIBlock::clearIblockTagCache($section->getIblockId());
339 }
340
341 public static function onAfterDelete(Event $event): void
342 {
343 // recount tree
344 $primary = $event->getParameter('id');
345 if (!is_array($primary))
346 {
347 $primary = ['ID' => $primary];
348 }
349 \CIBlockSection::recountTreeOnDelete($primary);
350 }
351}
static getMap()
Определения sectiontable.php:83
static onDelete(Event $event)
Определения sectiontable.php:332
static onBeforeAdd(Event $event)
Определения sectiontable.php:246
const TYPE_HTML
Определения sectiontable.php:64
static onAfterDelete(Event $event)
Определения sectiontable.php:341
static onBeforeUpdate(Event $event)
Определения sectiontable.php:279
const TYPE_TEXT
Определения sectiontable.php:63
static getTableName()
Определения sectiontable.php:73
Определения event.php:5
static onAfterUpdate(Event $event)
Определения datamanager.php:2012
static onAfterAdd(Event $event)
Определения datamanager.php:2009
static onUpdate(Event $event)
Определения datamanager.php:2011
</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
$event
Определения prolog_after.php:141
$fields
Определения yandex_run.php:501