- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/controller/export.php
- Класс: BitrixMainControllerExport
- Вызов: Export::preformAnswer
protected function preformAnswer($action)
{
if ($action == self::ACTION_CLEAR || $action == self::ACTION_CANCEL || $action == self::ACTION_PURGE)
{
$result = [];
}
else
{
$fileSize = $this->fileSize;
if (!$this->isExportCompleted && $this->uploadedSize > 0)
{
$fileSize = $this->uploadedSize + $this->fileSize;
}
elseif ($this->isExportCompleted && $this->uploadedSize > $this->fileSize)
{
$fileSize = $this->uploadedSize;
}
$result = array(
'STATUS' => ($this->isExportCompleted ? self::STATUS_COMPLETED : self::STATUS_PROGRESS),
'PROCESSED_ITEMS' => $this->processedItems,
'TOTAL_ITEMS' => $this->totalItems,
'UPLOADED_PART' => $this->uploadedPart,
'UPLOADED_SIZE' => $this->uploadedSize,
'UPLOADED_SIZE_FORMAT' => CFile::FormatSize($this->uploadedSize),
'FILE_SIZE_FORMAT' => CFile::FormatSize($fileSize),
);
$messagePlaceholders = array(
'#PROCESSED_ITEMS#' => $this->processedItems,
'#TOTAL_ITEMS#' => $this->totalItems,
'#UPLOADED_PART#' => $this->uploadedPart,
'#UPLOADED_SIZE#' => $this->uploadedSize,
'#UPLOADED_SIZE_FORMAT#' => CFile::FormatSize($this->uploadedSize),
'#FILE_SIZE_FORMAT#' => CFile::FormatSize($fileSize),
);
}
if ($action == self::ACTION_VOID)
{
$message = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_VOID'));
}
elseif ($action == self::ACTION_PURGE)
{
$message = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_PURGE'));
}
elseif ($action == self::ACTION_CLEAR)
{
$message = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_FILE_DROPPED'));
}
elseif ($action == self::ACTION_CANCEL)
{
$message = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_ACTION_CANCEL'));
}
elseif ($action == self::ACTION_UPLOAD)
{
$message =
htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_ACTION_UPLOAD', $messagePlaceholders)). '
'.
$this->preformExpectedDuration();
}
elseif ($action == self::ACTION_EXPORT)
{
$message =
htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_ACTION_EXPORT', $messagePlaceholders)). '
'.
$this->preformExpectedDuration();
}
elseif ($this->isExportCompleted)
{
$message =
htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_COMPLETED')). '
'.
htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_ACTION_EXPORT', $messagePlaceholders));
$downloadLink = '';
if ($this->isBitrix24 || $this->useCloud === true)
{
if ($this->isUploadFinished)
{
$downloadLink = $this->generateCloudLink();
}
}
else
{
$downloadLink = $this->generateDownloadLink();
}
if ($downloadLink !== '')
{
$result['DOWNLOAD_LINK'] = $downloadLink;
$result['FILE_NAME'] = $this->fileName;
$result['DOWNLOAD_LINK_NAME'] = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_DOWNLOAD'));
$result['CLEAR_LINK_NAME'] = htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_CLEAR'));
}
}
else
{
$message =
htmlspecialcharsbx(Loc::getMessage('MAIN_EXPORT_ACTION_EXPORT', $messagePlaceholders)). '
'.
$this->preformExpectedDuration();
}
$result['SUMMARY_HTML'] = $message;
return $result;
}