93 $checkLanguages = \array_intersect(
$filter->langId, $checkLanguages);
100 if (!($topPath = $topPathRes->fetch()))
106 '=PATH.DESCENDANTS.PARENT_ID' => $topPath[
'ID'],
107 '=LANG_ID' => $checkLanguages,
110 if (isset($seek, $seek->pathId))
112 $fileFilter[
'>PATH_ID'] = $seek->pathId;
120 ->addSelect(
'PATH_ID')
122 ->registerRuntimeField(
new ExpressionField(
'FILE_IDS',
"GROUP_CONCAT(%s ORDER BY (%s) SEPARATOR '\\n')", [
'ID',
'ID']))
123 ->addSelect(
'FILE_IDS')
125 ->registerRuntimeField(
new ExpressionField(
'LANG_IDS',
"GROUP_CONCAT(%s ORDER BY (%s) SEPARATOR '\\n')", [
'LANG_ID',
'ID']))
126 ->addSelect(
'LANG_IDS')
128 ->registerRuntimeField(
new ExpressionField(
'FULL_PATHS',
"GROUP_CONCAT(%s ORDER BY (%s) SEPARATOR '\\n')", [
'FULL_PATH',
'ID']))
129 ->addSelect(
'FULL_PATHS')
131 ->setFilter($fileFilter)
132 ->setOrder([
'PATH_ID' =>
'ASC'])
133 ->addGroup(
'PATH_ID')
136 $fileListRes = $fileListQuery->exec();
139 ->registerRuntimeField(
new ExpressionField(
'MAXID',
'MAX(%s)', [
'ID']))
144 $processedItemCount = 0;
150 while ($pathRow = $fileListRes->fetch())
152 $filePortion[] = $pathRow;
153 if (\
count($filePortion) >= 5)
158 if (empty($filePortion))
164 $phraseCodeData = [];
167 $nonexistentFiles = [];
169 foreach ($filePortion as $indexFile)
171 $pathId = (int)$indexFile[
'PATH_ID'];
172 $pathIdPortion[] = $lastPathId = $pathId;
175 foreach (\explode(
"\n", $indexFile[
'FILE_IDS']) as $v)
177 $fileIds[] = (int)$v;
181 foreach (\explode(
"\n", $indexFile[
'LANG_IDS']) as $v)
183 $langIds[] = \trim($v);
187 foreach (\explode(
"\n", $indexFile[
'FULL_PATHS']) as $v)
189 $filePaths[] = \trim($v);
192 foreach ($fileIds as $inx => $indexFileId)
194 $langId = $langIds[$inx];
195 $fullPath = $filePaths[$inx];
199 echo
"Lang file: {$fullPath}\n";
203 $current->setLangId($langId);
204 if (!$current->load())
206 $nonexistentFiles[] = $indexFileId;
211 'ID' => $indexFileId,
212 'PATH_ID' => $pathId,
213 'LANG_ID' => $langId,
214 'PHRASE_COUNT' => $current->count(),
215 'FULL_PATH' => $current->getPath(),
220 foreach ($current as
$code => $phrase)
223 $phraseCodeData[] = [
225 'FILE_ID' => $indexFileId,
226 'PATH_ID' => $pathId,
227 'LANG_ID' => $langId,
230 if (!isset($phraseData[$langId]))
232 $phraseData[$langId] = [];
234 $phraseData[$langId][] = [
236 'FILE_ID' => $indexFileId,
237 'PATH_ID' => $pathId,
244 $processedItemCount +=
\count($fileIds);
248 Index\Internals\PhraseIndexTable::bulkDelete([
249 '=PATH_ID' => $pathIdPortion,
250 '=LANG_ID' => $checkLanguages,
253 if (\
count($nonexistentFiles) > 0)
255 Index\Internals\PhraseIndexTable::bulkDelete([
'=FILE_ID' => $nonexistentFiles]);
256 Index\Internals\FileIndexTable::bulkDelete([
'=ID' => $nonexistentFiles]);
257 foreach (
Translate\Config::getEnabledLanguages() as $langId)
260 $ftsClass::bulkDelete([
'=FILE_ID' => $nonexistentFiles]);
265 if (\
count($phraseCodeData) > 0)
267 Index\Internals\FileIndexTable::bulkAdd($fileData,
'ID');
268 Index\Internals\PhraseIndexTable::bulkAdd($phraseCodeData);
269 foreach ($phraseData as $langId => $phraseLangData)
272 $ftsClass::bulkAdd($phraseLangData,
'ID');
276 Index\Internals\PathIndexTable::bulkUpdate(
278 [
'=ID' => $pathIdPortion]
281 if ($timer !==
null && $timer->hasTimeLimitReached())
285 $seek->nextPathId = $lastPathId;
292 if ($timer ===
null || !$timer->hasTimeLimitReached())
294 Index\Internals\PathIndexTable::bulkUpdate(
298 '=DESCENDANTS.PARENT_ID' => $topPath[
'ID'],
303 return $processedItemCount;