- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/export/exportfile.php
- Класс: BitrixTranslateControllerExportExportFile
- Вызов: ExportFile::run
public function run(string $path = '', bool $runBefore = false): array
{
if (empty($path) || !preg_match("#(.+/lang)(/?w*)#", $path, $matches))
{
$this->addError(new MainError(Loc::getMessage('TR_EXPORT_EMPTY_PATH_LIST')));
return [
'STATUS' => TranslateControllerSTATUS_COMPLETED
];
}
if (!TranslateIOPath::isLangDir($path))
{
$this->addError(new MainError(Loc::getMessage('TR_EXPORT_FILE_NOT_LANG', ['#FILE#' => $path])));
return [
'STATUS' => TranslateControllerSTATUS_COMPLETED
];
}
if ($runBefore)
{
$this->onBeforeRun();
}
$this->langFilePath = TranslateIOPath::replaceLangId($path, '#LANG_ID#');
$fullPaths = [];
foreach ($this->languages as $langId)
{
$langRelPath = TranslateIOPath::replaceLangId($path, $langId);
$langFullPath = TranslateIOPath::tidy(self::$documentRoot . '/' . $langRelPath);
if (self::$useTranslationRepository && in_array($langId, self::$translationRepositoryLanguages))
{
$langFullPath = MainLocalizationTranslation::convertLangPath($langFullPath, $langId);
}
$fullPaths[$langId] = $langFullPath;
}
$this->data = $this->mergeLangFiles($this->langFilePath, $fullPaths, $this->collectUntranslated);
if ($this->isNewProcess)
{
$this->totalItems = (int)count($this->data);
$this->processedItems = 0;
if ($this->totalItems > 0)
{
$this->exportFileName = $this->generateExportFileName($path, $this->languages);
$csvFile = $this->createExportTempFile($this->exportFileName);
$this->exportFilePath = $csvFile->getPhysicalPath();
$this->exportFileSize = $csvFile->getSize();
}
if ($this->appendSamples)
{
$this->samplesFileName = $this->generateExportFileName('samples-'.$path, $this->languages);
$sampleFile = $this->createExportTempFile($this->samplesFileName);
$this->samplesFilePath = $sampleFile->getPhysicalPath();
$this->samplesFileSize = $sampleFile->getSize();
}
$this->saveProgressParameters();
return [
'STATUS' => $this->totalItems > 0
? TranslateControllerSTATUS_PROGRESS
: TranslateControllerSTATUS_COMPLETED,
'PROCESSED_ITEMS' => 0,
'TOTAL_ITEMS' => $this->totalItems,
'TOTAL_PHRASES' => $this->exportedPhraseCount,
'TOTAL_SAMPLES' => $this->exportedSamplesCount,
];
}
return $this->performStep('runExporting', ['path' => $path]);
}