- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/export/csv.php
- Класс: BitrixTranslateControllerExportCsv
- Вызов: Csv::exportAction
public function exportAction($tabId, $path = ''): array
{
if (empty($tabId) || (int)$tabId <= 0)
{
throw new MainArgumentException("Missing 'tabId' parameter");
}
if (empty($path))
{
$path = TranslateConfig::getDefaultPath();
}
/** @var ExportAction|ExportFileList $action */
$action = $this->detectAction($path);
$result = $action->run($path, true);
if (count($action->getErrors()) > 0)
{
$this->addErrors($action->getErrors());
}
if ($action->hasProcessCompleted() && $result['TOTAL_ITEMS'] == 0)
{
$result['SUMMARY'] = Loc::getMessage('TR_EXPORT_VOID');
}
elseif ($action->hasProcessCompleted())
{
$fileProperties = $action->getDownloadingParameters();
$result['FILE_NAME'] = $fileProperties['fileName'];
$result['DOWNLOAD_LINK'] = $this->generateDownloadLink($fileProperties, 'export');
$messagePlaceholders = [
'#TOTAL_PHRASES#' => $result['TOTAL_PHRASES'],
'#FILE_SIZE_FORMAT#' => CFile::formatSize($fileProperties['fileSize']),
'#FILE_NAME#' => $result['FILE_NAME'],
'#FILE_LINK#' => $result['DOWNLOAD_LINK'],
];
$result['SUMMARY'] =
Loc::getMessage('TR_EXPORT_COMPLETED')
. "n". Loc::getMessage('TR_EXPORT_ACTION_EXPORT', $messagePlaceholders)
. " ". Loc::getMessage('TR_EXPORT_DOWNLOAD', $messagePlaceholders)
;
if ($this->appendSamples)
{
if ($result['TOTAL_SAMPLES'] > 0)
{
$fileSamplesProperties = $action->getDownloadingSamplesParameters();
$result['SAMPLES_LINK'] = $this->generateDownloadLink($fileSamplesProperties, 'samples');
$result['SAMPLES_FILE'] = $fileSamplesProperties['fileName'];
$messagePlaceholders = [
'#TOTAL_SAMPLES#' => $result['TOTAL_SAMPLES'],
'#FILE_SIZE_FORMAT#' => CFile::formatSize($fileSamplesProperties['fileSize']),
'#FILE_NAME#' => $result['SAMPLES_FILE'],
'#FILE_LINK#' => $result['SAMPLES_LINK'],
];
$result['SUMMARY'] .= "n" . Loc::getMessage('TR_EXPORT_SAMPLES', $messagePlaceholders);
$result['SUMMARY'] .= " " . Loc::getMessage('TR_EXPORT_DOWNLOAD', $messagePlaceholders);
}
else
{
$result['SUMMARY'] .= "n" . Loc::getMessage('TR_EXPORT_SAMPLES_NOT_FOUND');
}
}
}
return $result;
}