• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/controller/index/collectfileindex.php
  • Класс: BitrixTranslateControllerIndexCollectFileIndex
  • Вызов: CollectFileIndex::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;
			}
		}

		$filter = new TranslateFilter(['path' => $path]);
		if (!empty($this->languages))
		{
			$filter->langId = $this->languages;
		}

		$this->totalItems = (new IndexFileIndexCollection())->countItemsToProcess($filter);

		$this->saveProgressParameters();

		$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['seekPathId']))
		{
			$this->seekPathId = $progressParams['seekPathId'];
		}
	}

	return $this->performStep('runIndexing', ['path' => $path]);
}