- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/export/exportpath.php
- Класс: BitrixTranslateControllerExportExportPath
- Вызов: ExportPath::run
public function run(string $path = '', bool $runBefore = false): array
{
if ($runBefore)
{
$this->onBeforeRun();
}
if ($this->isNewProcess)
{
$pathList = $this->controller->getRequest()->get('pathList');
$pathList = preg_split("/[rn]+/", $pathList);
array_walk($pathList, 'trim');
$pathList = array_unique(array_filter($pathList));
if (empty($pathList))
{
$this->addError(new MainError(Loc::getMessage('TR_EXPORT_EMPTY_PATH_LIST')));
return [
'STATUS' => TranslateControllerSTATUS_COMPLETED,
];
}
foreach ($pathList as $testPath)
{
if (TranslateIOPath::isPhpFile($testPath))
{
if (TranslateIOPath::isLangDir($testPath))
{
$this->pathList[] = $testPath;
}
}
else
{
$this->pathList[] = $testPath;
}
}
// phrase codes
$codeList = $this->controller->getRequest()->get('codeList');
if (!empty($codeList))
{
$codeList = preg_split("/[rn]+/", $codeList);
array_walk($codeList, 'trim');
$this->codeList = array_unique(array_filter($codeList));
}
$this->totalItems = count($this->pathList);
$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($path.'-samples', $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,
];
}
return $this->performStep('runExporting');
}