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

	// continue previous process
	$progressParams = $this->getProgressParameters();
	$this->packFile = (bool)$progressParams['packFile'];
	$this->languageId = $progressParams['languageId'];
	$this->tmpFolderPath = $progressParams['tmpFolderPath'];

	$this->totalFileCount = (int)$progressParams['totalFileCount'];

	if ($this->isNewProcess)
	{
		$this->totalItems = $this->totalFileCount;
		$this->processedItems = 0;
		$this->archiveFileName = $this->generateExportFileName();

		$exportFolder = TranslateConfig::getExportFolder();
		if (!empty($exportFolder))
		{
			$tempDir = new TranslateIODirectory($exportFolder);
		}
		else
		{
			$tempDir = TranslateIODirectory::generateTemporalDirectory('translate');
		}

		if (!$tempDir->isExists() || !$tempDir->isDirectory())
		{
			$this->addError(new Error(
				Loc::getMessage('TR_ERROR_CREATE_TEMP_FOLDER', ['#PATH#' => $tempDir->getPhysicalPath()])
			));
		}
		else
		{
			$this->archiveFilePath = $tempDir->getPhysicalPath(). '/'. $this->archiveFileName;
		}

		$this->seekPath = null;
	}
	else
	{
		$this->processedItems = (int)$progressParams['processedItems'];
		$this->archiveFilePath = $progressParams['archiveFilePath'];
		$this->archiveFileName = $progressParams['archiveFileName'];
		$this->seekPath = $progressParams['seekPath'];

		$tempDir = new TranslateIODirectory($this->tmpFolderPath);
		if (!$tempDir->isExists() || !$tempDir->isDirectory())
		{
			$this->addError(
				new Error(Loc::getMessage('TR_ERROR_SOURCE_FOLDER', ['#PATH#' => $this->tmpFolderPath]))
			);
		}
	}


	$this->archiveFile = new TranslateIOArchiver($this->archiveFilePath);

	if ($this->isNewProcess)
	{
		if ($this->archiveFile->isExists())
		{
			$this->archiveFile->delete();
		}
	}

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

		return [
			'STATUS' => ($this->totalItems > 0 ? TranslateControllerSTATUS_PROGRESS : TranslateControllerSTATUS_COMPLETED),
			'PROCESSED_ITEMS' => $this->processedItems,
			'TOTAL_ITEMS' => $this->totalItems,
		];
	}

	$this->archiveFile->setOptions([
		'COMPRESS' => $this->packFile,
	]);

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