• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/controller/import/indexcsv.php
  • Класс: BitrixTranslateControllerImportIndexCsv
  • Вызов: IndexCsv::run
public function run($runBefore = false)
{
	if ($runBefore)
	{
		$this->onBeforeRun();
	}

	$this->csvFile = new TranslateIOCsvFile($this->csvFilePath);

	$this->csvFile
		->setFieldsType(TranslateIOCsvFile::FIELDS_TYPE_WITH_DELIMITER)
		->setFirstHeader(false)
	;

	if (!$this->csvFile->openLoad())
	{
		$this->addError(new MainError(Loc::getMessage('TR_IMPORT_EMPTY_FILE_ERROR')));

		return [
			'STATUS' => TranslateControllerSTATUS_COMPLETED
		];
	}
	if (!$this->verifyCsvFile())
	{
		$this->addError(new MainError(Loc::getMessage('TR_IMPORT_FILE_ERROR')));
		return [
			'STATUS' => TranslateControllerSTATUS_COMPLETED
		];
	}

	if ($this->isNewProcess)
	{
		$this->clearProgressParameters();

		$this->totalItems = 0;
		$uniquePaths = [];
		$fileColumn = $this->columnList['file'];
		while ($csvRow = $this->csvFile->fetch())
		{
			$filePath = (isset($csvRow[$fileColumn]) ? $csvRow[$fileColumn] : '');
			if ($filePath == '')
			{
				continue;
			}
			if (isset($uniquePaths[$filePath]))
			{
				continue;
			}
			$uniquePaths[$filePath] = 1;
			$this->totalItems ++;
		}
		$this->csvFile->moveFirst();

		$this->processedItems = 0;
		$this->seekLine = 0;

		$this->saveProgressParameters();

		$this->isNewProcess = false;
	}
	else
	{
		$progressParams = $this->getProgressParameters();

		if (isset($progressParams['totalItems']))
		{
			$this->totalItems = $progressParams['totalItems'];
		}
		if (isset($progressParams['seekLine']))
		{
			$this->seekLine = $progressParams['seekLine'];
		}
		if (isset($progressParams['seekPath']))
		{
			$this->seekPath = $progressParams['seekPath'];
		}
	}

	return $this->performStep('runIndexing');
}