- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/export/exportaction.php
- Класс: BitrixTranslateControllerExportExportAction
- Вызов: ExportAction::findSamples
public function findSamples(string $searchPhrase, string $searchLangId, $stripPath, int $limit = 50, array $restrictByPathId = []): array
{
$select = [
'PATH_ID' => 'PATH_ID',
'PHRASE_CODE' => 'CODE',
'FILE_PATH' => 'PATH.PATH',
];
$phraseFilter = [];
$minLengthFulltextWorld = IndexPhraseIndexSearch::getFullTextMinLength();
$fulltextIndexSearchStr = IndexPhraseIndexSearch::prepareTextForFulltextSearch($searchPhrase);
if (mb_strlen($fulltextIndexSearchStr) > $minLengthFulltextWorld)
{
$phraseFilter['*=PHRASE'] = $fulltextIndexSearchStr;
}
$phraseFilter['=PHRASE'] = $searchPhrase;
if (is_numeric($stripPath))
{
$phraseFilter['!=PATH_ID'] = $stripPath;
}
else
{
$phraseFilter['!=PATH.PATH'] = $stripPath;
}
if (!empty($restrictByPathId))
{
$phraseFilter['=PATH.DESCENDANTS.PARENT_ID'] = $restrictByPathId; //ancestor
}
$ftsClass = IndexInternalsPhraseFts::getFtsEntityClass($searchLangId);
/** @var MainORMQueryResult $cachePathRes */
$phraseInxRes = $ftsClass::getList([
'filter' => $phraseFilter,
'select' => $select,
'limit' => $limit,
]);
$samples = [];
$fileInxCache = [];
while ($phraseInx = $phraseInxRes->fetch())
{
$pathId = (int)$phraseInx['PATH_ID'];
$phraseCode = $phraseInx['PHRASE_CODE'];
if (!isset($fileInxCache[$pathId]))
{
$fullPaths = $this->getFullPath($pathId);
$fileInxCache[$pathId] = $this->mergeLangFiles($phraseInx['FILE_PATH'], $fullPaths);
}
if (
isset($fileInxCache[$pathId][$phraseCode])
&& $fileInxCache[$pathId][$phraseCode][$searchLangId] == $searchPhrase
)
{
$samples[] = $fileInxCache[$pathId][$phraseCode];
}
}
return $samples;
}