1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pathindex.php
См. документацию.
1<?php
2
3namespace Bitrix\Translate\Index\Internals;
4
5use Bitrix\Main;
6use Bitrix\Main\ORM;
7use Bitrix\Main\ORM\Data\DataManager;
8use Bitrix\Translate;
9use Bitrix\Translate\Index;
10
45
47{
49
55 public static function getTableName(): string
56 {
57 return 'b_translate_path';
58 }
59
65 public static function getObjectClass(): string
66 {
67 return Index\PathIndex::class;
68 }
69
75 public static function getCollectionClass(): string
76 {
77 return Index\PathIndexCollection::class;
78 }
79
85 public static function getMap(): array
86 {
87 return array(
88 'ID' => [
89 'data_type' => 'integer',
90 'primary' => true,
91 'autocomplete' => true,
92 ],
93 'PARENT_ID' => [
94 'data_type' => 'integer',
95 ],
96 'PATH' => [
97 'data_type' => 'string',
98 ],
99 'NAME' => [
100 'data_type' => 'string',
101 ],
102 'MODULE_ID' => [
103 'data_type' => 'string',
104 ],
105 'ASSIGNMENT' => [
106 'data_type' => 'enum',
107 'values' => Translate\ASSIGNMENT_TYPES,
108 ],
109 'DEPTH_LEVEL' => [
110 'data_type' => 'integer',
111 'default_value' => 0,
112 ],
113 'SORT' => [
114 'data_type' => 'integer',
115 'default_value' => 0,
116 ],
117 'IS_LANG' => [
118 'data_type' => 'boolean',
119 'values' => ['N', 'Y'],
120 'default_value' => 'N',
121 ],
122 'IS_DIR' => [
123 'data_type' => 'boolean',
124 'values' => ['N', 'Y'],
125 'default_value' => 'N',
126 ],
127 'OBLIGATORY_LANGS' => [
128 'data_type' => 'string',
129 ],
130 'INDEXED' => [
131 'data_type' => 'boolean',
132 'values' => ['N', 'Y'],
133 'default_value' => 'N',
134 ],
135 'INDEXED_TIME' => [
136 'data_type' => 'datetime',
137 ],
138 'FILE' => [
139 'data_type' => Index\Internals\FileIndexTable::class,
140 'reference' => [
141 '=this.ID' => 'ref.PATH_ID'
142 ],
143 'join_type' => 'LEFT',
144 ],
145 'ANCESTORS' => [
146 'data_type' => Index\Internals\PathTreeTable::class,
147 'reference' => [
148 '=this.ID' => 'ref.PARENT_ID',
149 ],
150 'join_type' => 'INNER',
151 ],
152 'DESCENDANTS' => [
153 'data_type' => Index\Internals\PathTreeTable::class,
154 'reference' => [
155 '=this.ID' => 'ref.PATH_ID',
156 ],
157 'join_type' => 'INNER',
158 ],
159 );
160 }
161
162
163
169 public static function onAfterAdd(ORM\Event $event): ORM\EventResult
170 {
171 $result = new ORM\EventResult();
172 $primary = $event->getParameter('primary');
173 $data = $event->getParameter('fields');
174
175 if (isset($primary['ID'], $data['PARENT_ID']))
176 {
177 $nodeId = $primary['ID'];
178 $parentId = $data['PARENT_ID'];
179 $tableName = PathTreeTable::getTableName();
181 $connection->query("
182 INSERT INTO {$tableName} (PARENT_ID, PATH_ID, DEPTH_LEVEL)
183 SELECT PARENT_ID, '{$nodeId}', DEPTH_LEVEL + 1 FROM {$tableName} WHERE PATH_ID = '{$parentId}'
184 UNION ALL
185 SELECT '{$nodeId}', '{$nodeId}', 0
186 ");
187 }
188
189 return $result;
190 }
191
197 public static function onAfterDelete(ORM\Event $event): ORM\EventResult
198 {
199 $result = new ORM\EventResult();
200 $primary = $event->getParameter('primary');
201
202 if (isset($primary['ID']))
203 {
204 $nodeId = $primary['ID'];
205 $tableName = PathTreeTable::getTableName();
207 $connection->query("DELETE FROM {$tableName} WHERE PATH_ID = '{$nodeId}'");
208 }
209
210 return $result;
211 }
212
220 public static function purge(?Translate\Filter $filter = null): void
221 {
222 $recursively = true;
223 if (isset($filter, $filter->recursively))
224 {
225 $recursively = $filter->recursively;
226 }
227
228 if ($recursively)
229 {
230 if (!isset($filter, $filter->langId))
231 {
233 }
235 }
236
237 if (!isset($filter, $filter->langId))
238 {
239 $filterOut = static::processFilter($filter);
240 static::bulkDelete($filterOut);
241 }
242 }
243
251 public static function processFilter(?Translate\Filter $filter = null): array
252 {
253 $filterOut = [];
254
255 if ($filter !== null)
256 {
257 foreach ($filter as $key => $value)
258 {
259 if (empty($value) && $value !== '0')
260 {
261 continue;
262 }
263
264 if ($key === 'path')
265 {
266 $filterOut['=%PATH'] = $value.'%';
267 }
268 elseif ($key === 'pathId')
269 {
270 $filterOut['=ID'] = $value;
271 }
272 elseif ($key === 'indexedTime')
273 {
274 $filterOut['<INDEXED_TIME'] = $value;
275 }
276 else
277 {
278 if (static::getEntity()->hasField(trim($key, '<>!=@~%*')))
279 {
280 $filterOut[$key] = $value;
281 }
282 }
283 }
284 }
285
286 return $filterOut;
287 }
288}
$connection
Определения actionsdefinitions.php:38
static getConnection($name="")
Определения application.php:638
Определения event.php:5
static purge(?Translate\Filter $filter=null)
Определения fileindex.php:123
static processFilter(?Translate\Filter $filter=null)
Определения pathindex.php:251
static onAfterDelete(ORM\Event $event)
Определения pathindex.php:197
static onAfterAdd(ORM\Event $event)
Определения pathindex.php:169
static purge(?Translate\Filter $filter=null)
Определения pathindex.php:220
static purge(?Translate\Filter $filter=null)
Определения pathtree.php:90
$data['IS_AVAILABLE']
Определения .description.php:13
</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
$filter
Определения iblock_catalog_list.php:54
Определения autoload.php:3
const ASSIGNMENT_TYPES
Определения autoload.php:89
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257