- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/index/collectpathindex.php
- Класс: BitrixTranslateControllerIndexCollectPathIndex
- Вызов: CollectPathIndex::run
public function run($path = '')
{
if (empty($path))
{
$path = TranslateConfig::getDefaultPath();
}
if (preg_match("#(.+/lang)(/?w*)#", $path, $matches))
{
$path = $matches[1];
}
$path = '/'. trim($path, '/.\');
// skip indexing if index exists
if (MainContext::getCurrent()->getRequest()->get('checkIndexExists') === 'Y')
{
$indexPath = TranslateIndexPathIndex::loadByPath($path);
if ($indexPath instanceof TranslateIndexPathIndex)
{
if ($indexPath->getIndexed())
{
return [
'STATUS' => TranslateControllerSTATUS_COMPLETED
];
}
}
}
if ($this->isNewProcess)
{
$languages = $this->controller->getRequest()->get('languages');
if (is_array($languages) && !in_array('all', $languages))
{
$languages = array_intersect($languages, TranslateConfig::getEnabledLanguages());
if (!empty($languages))
{
$this->languages = $languages;
}
}
$indexer = new IndexPathIndexCollection();
$filter = new TranslateFilter(['path' => $path]);
if (!empty($this->languages))
{
$filter->langId = $this->languages;
}
$this->totalItems = $indexer->countItemsToProcess($filter);
$this->processedItems = 0;
$this->saveProgressParameters();
$indexer->purge($filter);
/*
->unvalidate($filter);
'indexedTime' => new MainTypeDateTime(
date('Y-m-d H:i:s', strtotime('-'.self::EXPIRATION_DEPTH)),
'Y-m-d H:i:s'
)*/
$this->instanceTimer()->setTimeLimit(5);
$this->isNewProcess = false;
}
else
{
$progressParams = $this->getProgressParameters();
if (isset($progressParams['totalItems']) && (int)$progressParams['totalItems'] > 0)
{
$this->totalItems = (int)$progressParams['totalItems'];
$this->processedItems = (int)$progressParams['processedItems'];
}
if (isset($progressParams['seekPathLangId']))
{
$this->seekPathLangId = $progressParams['seekPathLangId'];
}
}
return $this->performStep('runIndexing', ['path' => $path]);
}