Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
filterentity.php
1<?php
3
7
8Loc::loadMessages(__FILE__);
9
26class FilterEntityTable extends Entity\DataManager
27{
32 public static function getTableName()
33 {
34 return 'b_landing_filter_entity';
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 'SOURCE_ID' => new Entity\StringField('SOURCE_ID', array(
50 'title' => Loc::getMessage('LANDING_TABLE_FIELD_SOURCE_ID'),
51 'required' => true
52 )),
53 'FILTER_HASH' => new Entity\StringField('FILTER_HASH', array(
54 'title' => Loc::getMessage('LANDING_TABLE_FIELD_FILTER_HASH'),
55 'required' => true
56 )),
57 'FILTER' => new Entity\StringField('FILTER', array(
58 'title' => Loc::getMessage('LANDING_TABLE_FIELD_FILTER'),
59 'serialized' => true,
60 'required' => true
61 )),
62 'CREATED_BY_ID' => new Entity\IntegerField('CREATED_BY_ID', array(
63 'title' => Loc::getMessage('LANDING_TABLE_FIELD_CREATED_BY_ID'),
64 'required' => true
65 )),
66 'MODIFIED_BY_ID' => new Entity\IntegerField('MODIFIED_BY_ID', array(
67 'title' => Loc::getMessage('LANDING_TABLE_FIELD_MODIFIED_BY_ID'),
68 'required' => true
69 )),
70 'DATE_CREATE' => new Entity\DatetimeField('DATE_CREATE', array(
71 'title' => Loc::getMessage('LANDING_TABLE_FIELD_DATE_CREATE'),
72 'required' => true
73 )),
74 'DATE_MODIFY' => new Entity\DatetimeField('DATE_MODIFY', array(
75 'title' => Loc::getMessage('LANDING_TABLE_FIELD_DATE_MODIFY'),
76 'required' => true
77 ))
78 );
79 }
80
87 public static function applyBlock($filterId, $blockId)
88 {
89 $res = FilterBlockTable::getList([
90 'select' => [
91 'ID'
92 ],
93 'filter' => [
94 'FILTER_ID' => $filterId,
95 'BLOCK_ID' => $blockId
96 ]
97 ]);
98 if (!$res->fetch())
99 {
100 FilterBlockTable::add([
101 'FILTER_ID' => $filterId,
102 'BLOCK_ID' => $blockId
103 ]);
104 }
105 unset($res);
107 }
108
114 public static function removeBlock($blockId)
115 {
116 $res = FilterBlockTable::getList([
117 'select' => [
118 'ID'
119 ],
120 'filter' => [
121 'BLOCK_ID' => $blockId
122 ]
123 ]);
124 while ($row = $res->fetch())
125 {
126 FilterBlockTable::delete($row['ID']);
127 }
128 unset($res, $row);
130 }
131
136 protected static function actualFilters(): void
137 {
138 $connection = Application::getConnection();
139 if ($connection->getType() === 'pgsql')
140 {
141 $connection->query('
142 DELETE FROM b_landing_filter_entity
143 WHERE ID IN (
144 SELECT F.ID
145 FROM b_landing_filter_entity F
146 LEFT JOIN b_landing_filter_block B ON B.FILTER_ID = F.ID
147 WHERE B.ID IS NULL
148 );
149 ');
150 } else {
151 $connection->query('
152 DELETE F FROM
153 b_landing_filter_entity F
154 LEFT JOIN
155 b_landing_filter_block B ON B.FILTER_ID = F.ID
156 WHERE
157 B.ID IS NULL;
158 ');
159 }
160 }
161}
static applyBlock($filterId, $blockId)
static getConnection($name="")
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29