- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/index/pathindexcollection.php
- Класс: BitrixTranslateIndexPathIndexCollection
- Вызов: PathIndexCollection::constructAncestorsByPath
public function constructAncestorsByPath($path): ?array
{
if (isset($this->ancestorsPaths[$path]))
{
return $this->ancestorsPaths[$path];
}
$pathParts = explode('/', trim($path, '/'));
$searchPath = '';
$ancestorsPathSearch = [];
foreach ($pathParts as $part)
{
$searchPath .= '/'. $part;
if (isset($this->ancestorsPaths[$searchPath]))
{
continue;
}
$ancestorsPathSearch[] = $searchPath;
}
$pathRes = IndexInternalsPathIndexTable::getList([
'select' => ['ID', 'DEPTH_LEVEL', 'IS_LANG', 'PATH'],
'filter' => ['=PATH' => $ancestorsPathSearch],
]);
while ($pathInx = $pathRes->fetch())
{
$pathInx['IS_LANG'] = ($pathInx['IS_LANG'] == 'Y');
$this->ancestorsPaths[$pathInx['PATH']] = $pathInx;
}
if (isset($this->ancestorsPaths[$path]))
{
return $this->ancestorsPaths[$path];
}
$pathInx = null;
$searchPath = '';
$searchParentId = 0;
$searchDepthLevel = 0;
$isLang = false;
foreach ($pathParts as $part)
{
$searchPath .= '/'. $part;
if (isset($this->ancestorsPaths[$searchPath]) && $searchPath !== $path)
{
$searchParentId = (int)$this->ancestorsPaths[$searchPath]['ID'];
$searchDepthLevel = (int)$this->ancestorsPaths[$searchPath]['DEPTH_LEVEL'] + 1;
$isLang = $this->ancestorsPaths[$searchPath]['IS_LANG'];
continue;
}
if ($isLang === false)
{
$isLang = ($part === 'lang');
}
$nodeData = [
'NAME' => $part,
'PATH' => $searchPath,
'PARENT_ID' => $searchParentId,
'DEPTH_LEVEL' => $searchDepthLevel,
'IS_LANG' => $isLang ? 'Y' : 'N',
'IS_DIR' => (TranslateIOPath::isPhpFile($part) ? 'N' : 'Y'),
];
$pathInx = IndexInternalsPathIndexTable::add($nodeData);
$searchParentId = $pathInx->getId();
$this->ancestorsPaths[$searchPath] = [
'ID' => $searchParentId,
'DEPTH_LEVEL' => $searchDepthLevel,
'IS_LANG' => $isLang,
'PATH' => $searchPath,
];
$searchDepthLevel ++;
}
return $this->ancestorsPaths[$path];
}