Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
urlrewrite.php
1<?php
3
4use \Bitrix\Main\Localization\Loc;
5use \Bitrix\Main\Entity;
6use \Bitrix\Landing\Manager;
7
8Loc::loadMessages(__FILE__);
9
26class UrlRewriteTable extends Entity\DataManager
27{
32 public static function getTableName()
33 {
34 return 'b_landing_urlrewrite';
35 }
36
41 public static function getMap()
42 {
43 return array(
44 'ID' => new Entity\IntegerField('ID', array(
45 'primary' => true,
46 'autocomplete' => true,
47 'title' => 'ID'
48 )),
49 'SITE_ID' => new Entity\IntegerField('SITE_ID', array(
50 'title' => Loc::getMessage('LANDING_TABLE_FIELD_SITE_ID'),
51 'required' => true
52 )),
53 'RULE' => new Entity\StringField('RULE', array(
54 'title' => Loc::getMessage('LANDING_TABLE_FIELD_RULE'),
55 'required' => true
56 )),
57 'LANDING_ID' => new Entity\IntegerField('LANDING_ID', array(
58 'title' => Loc::getMessage('LANDING_TABLE_FIELD_LANDING_ID'),
59 'required' => true
60 )),
61 'CREATED_BY_ID' => new Entity\IntegerField('CREATED_BY_ID', array(
62 'title' => Loc::getMessage('LANDING_TABLE_FIELD_CREATED_BY_ID'),
63 'required' => true
64 )),
65 'MODIFIED_BY_ID' => new Entity\IntegerField('MODIFIED_BY_ID', array(
66 'title' => Loc::getMessage('LANDING_TABLE_FIELD_MODIFIED_BY_ID'),
67 'required' => true
68 )),
69 'DATE_CREATE' => new Entity\DatetimeField('DATE_CREATE', array(
70 'title' => Loc::getMessage('LANDING_TABLE_FIELD_DATE_CREATE'),
71 'required' => true
72 )),
73 'DATE_MODIFY' => new Entity\DatetimeField('DATE_MODIFY', array(
74 'title' => Loc::getMessage('LANDING_TABLE_FIELD_DATE_MODIFY'),
75 'required' => true
76 ))
77 );
78 }
79
85 public static function add(array $fields)
86 {
87 $uid = Manager::getUserId();
88 $uid = $uid ? $uid : 1;
89 $date = new \Bitrix\Main\Type\DateTime;
90
91 if (!isset($fields['CREATED_BY_ID']))
92 {
93 $fields['CREATED_BY_ID'] = $uid;
94 }
95 if (!isset($fields['MODIFIED_BY_ID']))
96 {
97 $fields['MODIFIED_BY_ID'] = $uid;
98 }
99 if (!isset($fields['DATE_CREATE']))
100 {
101 $fields['DATE_CREATE'] = $date;
102 }
103 if (!isset($fields['DATE_MODIFY']))
104 {
105 $fields['DATE_MODIFY'] = $date;
106 }
107
108 return parent::add($fields);
109 }
110
117 public static function update($id, array $fields = array())
118 {
119 $uid = Manager::getUserId();
120 $date = new \Bitrix\Main\Type\DateTime;
121
122 if (!isset($fields['MODIFIED_BY_ID']))
123 {
124 $fields['MODIFIED_BY_ID'] = $uid;
125 }
126 if (!isset($fields['DATE_MODIFY']))
127 {
128 $fields['DATE_MODIFY'] = $date;
129 }
130 if (!$fields['DATE_MODIFY'])
131 {
132 unset($fields['DATE_MODIFY']);
133 }
134
135 return parent::update($id, $fields);
136 }
137}
static update($id, array $fields=array())
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29