Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
phraseindex.php
1<?php
2
4
9
39{
40 use Index\Internals\BulkOperation;
41
47 public static function getTableName(): string
48 {
49 return 'b_translate_phrase';
50 }
51
57 public static function getObjectClass(): string
58 {
59 return Index\PhraseIndex::class;
60 }
61
67 public static function getCollectionClass(): string
68 {
69 return Index\PhraseIndexCollection::class;
70 }
71
77 public static function getMap(): array
78 {
79 static $fields;
80 if ($fields === null)
81 {
82 $fields = [
83 'ID' => [
84 'data_type' => 'integer',
85 'primary' => true,
86 'autocomplete' => true,
87 ],
88 'FILE_ID' => [
89 'data_type' => 'integer',
90 ],
91 'PATH_ID' => [
92 'data_type' => 'integer',
93 ],
94 'LANG_ID' => [
95 'data_type' => 'string',
96 ],
97 'CODE' => [
98 'data_type' => 'string',
99 ],
100 'FILE' => [
101 'data_type' => Index\Internals\FileIndexTable::class,
102 'reference' => [
103 '=this.FILE_ID' => 'ref.ID',
104 ],
105 'join_type' => 'INNER',
106 ],
107 'PATH' => [
108 'data_type' => Index\Internals\PathIndexTable::class,
109 'reference' => [
110 '=this.PATH_ID' => 'ref.ID',
111 ],
112 'join_type' => 'INNER',
113 ],
114 ];
115
116 foreach (Translate\Config::getEnabledLanguages() as $langId)
117 {
118 $fields['PHRASE_' . mb_strtoupper($langId)] = [
119 'data_type' => Index\Internals\PhraseFts::getFtsEntityClass($langId),
120 'reference' => [
121 '=this.ID' => 'ref.ID',
122 ],
123 'join_type' => 'LEFT',
124 ];
125 }
126 }
127
128 return $fields;
129 }
130
138 public static function purge(?Translate\Filter $filter = null): void
139 {
140 $langs = isset($filter, $filter->langId) ? $filter->langId : Translate\Config::getEnabledLanguages();
141 foreach ($langs as $langId)
142 {
143 $ftsClass = Index\Internals\PhraseFts::getFtsEntityClass($langId);
144 $ftsClass::purge($filter);
145 }
146
147 $filterOut = static::processFilter($filter);
148 static::bulkDelete($filterOut);
149 }
150
158 public static function processFilter(?Translate\Filter $filter = null): array
159 {
160 $filterOut = [];
161
162 if ($filter !== null)
163 {
164 foreach ($filter as $key => $value)
165 {
166 if (empty($value) && $value !== '0')
167 {
168 continue;
169 }
170
171 if ($key === 'path')
172 {
173 $filterOut['=%PATH.PATH'] = $value.'%';
174 }
175 elseif ($key === 'fileId')
176 {
177 $filterOut['=FILE_ID'] = $value;
178 }
179 elseif ($key === 'pathId')
180 {
181 $filterOut['=PATH_ID'] = $value;
182 }
183 elseif ($key === 'langId')
184 {
185 $filterOut['=LANG_ID'] = $value;
186 }
187 elseif ($key === 'indexedTime')
188 {
189 $filterOut['<FILE.INDEXED_TIME'] = $value;
190 }
191 else
192 {
193 if (static::getEntity()->hasField(trim($key, '<>!=@~%*')))
194 {
195 $filterOut[$key] = $value;
196 }
197 }
198 }
199 }
200
201 return $filterOut;
202 }
203}
static processFilter(?Translate\Filter $filter=null)
static purge(?Translate\Filter $filter=null)