Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementtable.php
1<?php
2namespace Bitrix\Iblock;
3
11
12Loc::loadMessages(__FILE__);
13
79{
80 const TYPE_TEXT = 'text';
81 const TYPE_HTML = 'html';
82
88 public static function getTableName()
89 {
90 return 'b_iblock_element';
91 }
92
98 public static function getMap()
99 {
100 return array(
101 'ID' => new ORM\Fields\IntegerField('ID', array(
102 'primary' => true,
103 'autocomplete' => true,
104 'title' => Loc::getMessage('ELEMENT_ENTITY_ID_FIELD'),
105 )),
106 'TIMESTAMP_X' => new ORM\Fields\DatetimeField('TIMESTAMP_X', array(
107 'default_value' => function()
108 {
109 return new Main\Type\DateTime();
110 },
111 'title' => Loc::getMessage('ELEMENT_ENTITY_TIMESTAMP_X_FIELD'),
112 )),
113 'MODIFIED_BY' => new ORM\Fields\IntegerField('MODIFIED_BY', array(
114 'title' => Loc::getMessage('ELEMENT_ENTITY_MODIFIED_BY_FIELD'),
115 )),
116 'DATE_CREATE' => new ORM\Fields\DatetimeField('DATE_CREATE', array(
117 'default_value' => function()
118 {
119 return new Main\Type\DateTime();
120 },
121 'title' => Loc::getMessage('ELEMENT_ENTITY_DATE_CREATE_FIELD'),
122 )),
123 'CREATED_BY' => new ORM\Fields\IntegerField('CREATED_BY', array(
124 'title' => Loc::getMessage('ELEMENT_ENTITY_CREATED_BY_FIELD'),
125 )),
126 'IBLOCK_ID' => new ORM\Fields\IntegerField('IBLOCK_ID', array(
127 'required' => true,
128 'title' => Loc::getMessage('ELEMENT_ENTITY_IBLOCK_ID_FIELD'),
129 )),
130 'IBLOCK_SECTION_ID' => new ORM\Fields\IntegerField('IBLOCK_SECTION_ID', array(
131 'title' => Loc::getMessage('ELEMENT_ENTITY_IBLOCK_SECTION_ID_FIELD'),
132 )),
133 'ACTIVE' => new ORM\Fields\BooleanField('ACTIVE', array(
134 'values' => array('N', 'Y'),
135 'default_value' => 'Y',
136 'title' => Loc::getMessage('ELEMENT_ENTITY_ACTIVE_FIELD'),
137 )),
138 'ACTIVE_FROM' => new ORM\Fields\DatetimeField('ACTIVE_FROM', array(
139 'title' => Loc::getMessage('ELEMENT_ENTITY_ACTIVE_FROM_FIELD'),
140 )),
141 'ACTIVE_TO' => new ORM\Fields\DatetimeField('ACTIVE_TO', array(
142 'title' => Loc::getMessage('ELEMENT_ENTITY_ACTIVE_TO_FIELD'),
143 )),
144 'SORT' => new ORM\Fields\IntegerField('SORT', array(
145 'default_value' => 500,
146 'title' => Loc::getMessage('ELEMENT_ENTITY_SORT_FIELD'),
147 )),
148 'NAME' => new ORM\Fields\StringField('NAME', array(
149 'required' => true,
150 'validation' => array(__CLASS__, 'validateName'),
151 'title' => Loc::getMessage('ELEMENT_ENTITY_NAME_FIELD'),
152 )),
153 'PREVIEW_PICTURE' => new ORM\Fields\IntegerField('PREVIEW_PICTURE', array(
154 'title' => Loc::getMessage('ELEMENT_ENTITY_PREVIEW_PICTURE_FIELD'),
155 )),
156 'PREVIEW_TEXT' => new ORM\Fields\TextField('PREVIEW_TEXT', array(
157 'title' => Loc::getMessage('ELEMENT_ENTITY_PREVIEW_TEXT_FIELD'),
158 )),
159 'PREVIEW_TEXT_TYPE' => new ORM\Fields\EnumField('PREVIEW_TEXT_TYPE', array(
160 'values' => array(self::TYPE_TEXT, self::TYPE_HTML),
161 'default_value' => self::TYPE_TEXT,
162 'title' => Loc::getMessage('ELEMENT_ENTITY_PREVIEW_TEXT_TYPE_FIELD'),
163 )),
164 'DETAIL_PICTURE' => new ORM\Fields\IntegerField('DETAIL_PICTURE', array(
165 'title' => Loc::getMessage('ELEMENT_ENTITY_DETAIL_PICTURE_FIELD'),
166 )),
167 'DETAIL_TEXT' => new ORM\Fields\TextField('DETAIL_TEXT', array(
168 'title' => Loc::getMessage('ELEMENT_ENTITY_DETAIL_TEXT_FIELD'),
169 )),
170 'DETAIL_TEXT_TYPE' => new ORM\Fields\EnumField('DETAIL_TEXT_TYPE', array(
171 'values' => array(self::TYPE_TEXT, self::TYPE_HTML),
172 'default_value' => self::TYPE_TEXT,
173 'title' => Loc::getMessage('ELEMENT_ENTITY_DETAIL_TEXT_TYPE_FIELD'),
174 )),
175 'SEARCHABLE_CONTENT' => new ORM\Fields\TextField('SEARCHABLE_CONTENT', array(
176 'title' => Loc::getMessage('ELEMENT_ENTITY_SEARCHABLE_CONTENT_FIELD'),
177 )),
178 'WF_STATUS_ID' => new ORM\Fields\IntegerField('WF_STATUS_ID', array(
179 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_STATUS_ID_FIELD'),
180 )),
181 'WF_PARENT_ELEMENT_ID' => new ORM\Fields\IntegerField('WF_PARENT_ELEMENT_ID', array(
182 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_PARENT_ELEMENT_ID_FIELD'),
183 )),
184 'WF_NEW' => new ORM\Fields\EnumField('WF_NEW', array(
185 'values' => array('N', 'Y'),
186 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_NEW_FIELD'),
187 )),
188 'WF_LOCKED_BY' => new ORM\Fields\IntegerField('WF_LOCKED_BY', array(
189 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_LOCKED_BY_FIELD'),
190 )),
191 'WF_DATE_LOCK' => new ORM\Fields\DatetimeField('WF_DATE_LOCK', array(
192 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_DATE_LOCK_FIELD'),
193 )),
194 'WF_COMMENTS' => new ORM\Fields\TextField('WF_COMMENTS', array(
195 'title' => Loc::getMessage('ELEMENT_ENTITY_WF_COMMENTS_FIELD'),
196 )),
197 'IN_SECTIONS' => new ORM\Fields\BooleanField('IN_SECTIONS', array(
198 'values' => array('N', 'Y'),
199 'title' => Loc::getMessage('ELEMENT_ENTITY_IN_SECTIONS_FIELD'),
200 )),
201 'XML_ID' => new ORM\Fields\StringField('XML_ID', array(
202 'validation' => array(__CLASS__, 'validateXmlId'),
203 'title' => Loc::getMessage('ELEMENT_ENTITY_XML_ID_FIELD'),
204 )),
205 'CODE' => new ORM\Fields\StringField('CODE', array(
206 'validation' => array(__CLASS__, 'validateCode'),
207 'title' => Loc::getMessage('ELEMENT_ENTITY_CODE_FIELD'),
208 )),
209 'TAGS' => new ORM\Fields\StringField('TAGS', array(
210 'validation' => array(__CLASS__, 'validateTags'),
211 'title' => Loc::getMessage('ELEMENT_ENTITY_TAGS_FIELD'),
212 )),
213 'TMP_ID' => new ORM\Fields\StringField('TMP_ID', array(
214 'validation' => array(__CLASS__, 'validateTmpId'),
215 'title' => Loc::getMessage('ELEMENT_ENTITY_TMP_ID_FIELD'),
216 )),
217 'SHOW_COUNTER' => new ORM\Fields\IntegerField('SHOW_COUNTER', array(
218 'default_value' => 0,
219 'title' => Loc::getMessage('ELEMENT_ENTITY_SHOW_COUNTER_FIELD'),
220 )),
221 'SHOW_COUNTER_START' => new ORM\Fields\DatetimeField('SHOW_COUNTER_START', array(
222 'title' => Loc::getMessage('ELEMENT_ENTITY_SHOW_COUNTER_START_FIELD'),
223 )),
224 'IBLOCK' => new ORM\Fields\Relations\Reference(
225 'IBLOCK',
226 '\Bitrix\Iblock\Iblock',
227 array('=this.IBLOCK_ID' => 'ref.ID'),
228 array('join_type' => 'LEFT')
229 ),
230 'WF_PARENT_ELEMENT' => new ORM\Fields\Relations\Reference(
231 'WF_PARENT_ELEMENT',
232 '\Bitrix\Iblock\Element',
233 array('=this.WF_PARENT_ELEMENT_ID' => 'ref.ID'),
234 array('join_type' => 'LEFT')
235 ),
236 'IBLOCK_SECTION' => new ORM\Fields\Relations\Reference(
237 'IBLOCK_SECTION',
238 '\Bitrix\Iblock\Section',
239 array('=this.IBLOCK_SECTION_ID' => 'ref.ID'),
240 array('join_type' => 'LEFT')
241 ),
242 'MODIFIED_BY_USER' => new ORM\Fields\Relations\Reference(
243 'MODIFIED_BY_USER',
244 '\Bitrix\Main\User',
245 array('=this.MODIFIED_BY' => 'ref.ID'),
246 array('join_type' => 'LEFT')
247 ),
248 'CREATED_BY_USER' => new ORM\Fields\Relations\Reference(
249 'CREATED_BY_USER',
250 '\Bitrix\Main\User',
251 array('=this.CREATED_BY' => 'ref.ID'),
252 array('join_type' => 'LEFT')
253 ),
254 'WF_LOCKED_BY_USER' => new ORM\Fields\Relations\Reference(
255 'WF_LOCKED_BY_USER',
256 '\Bitrix\Main\User',
257 array('=this.WF_LOCKED_BY' => 'ref.ID'),
258 array('join_type' => 'LEFT')
259 ),
260 );
261 }
267 public static function validateName()
268 {
269 return array(
270 new ORM\Fields\Validators\LengthValidator(null, 255),
271 );
272 }
273
279 public static function validateXmlId()
280 {
281 return array(
282 new ORM\Fields\Validators\LengthValidator(null, 255),
283 );
284 }
290 public static function validateCode()
291 {
292 return array(
293 new ORM\Fields\Validators\LengthValidator(null, 255),
294 );
295 }
301 public static function validateTags()
302 {
303 return array(
304 new ORM\Fields\Validators\LengthValidator(null, 255),
305 );
306 }
312 public static function validateTmpId()
313 {
314 return array(
315 new ORM\Fields\Validators\LengthValidator(null, 40),
316 );
317 }
318
325 public static function add(array $data)
326 {
327 $result = new ORM\Data\AddResult();
328 $result->addError(new ORM\EntityError(
329 Loc::getMessage('ELEMENT_ENTITY_MESS_ADD_BLOCKED')
330 ));
331 return $result;
332 }
333
341 public static function update($primary, array $data)
342 {
343 $result = new ORM\Data\UpdateResult();
344 $result->addError(new ORM\EntityError(
345 Loc::getMessage('ELEMENT_ENTITY_MESS_UPDATE_BLOCKED')
346 ));
347 return $result;
348 }
349
356 public static function delete($primary)
357 {
358 $result = new ORM\Data\DeleteResult();
359 $result->addError(new ORM\EntityError(
360 Loc::getMessage('ELEMENT_ENTITY_MESS_DELETE_BLOCKED')
361 ));
362 return $result;
363 }
364}
static add(array $data)
static update($primary, array $data)
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29