14 use Translate\Controller\ProcessParams;
33 private $archiveFilePath;
35 private $archiveFileType;
46 $configureActions = parent::configureActions();
51 'class' => Translate\Controller\Asset\Collect::class,
57 'class' => Translate\Controller\Asset\Extract::class,
64 'class' => Translate\Controller\Asset\Apply::class,
71 'class' => Translate\Controller\Asset\ApplyPublic::class,
78 'class' => Translate\Controller\Asset\Pack::class,
90 Main\Engine\ActionFilter\Csrf::class,
117 return $configureActions;
128 $this->
keepField([
'archiveFilePath',
'archiveFileType']);
141 isset($_FILES, $_FILES[
'tarFile'], $_FILES[
'tarFile'][
'tmp_name']) &&
142 ($_FILES[
'tarFile'][
'error'] == \UPLOAD_ERR_OK) &&
143 \file_exists($_FILES[
'tarFile'][
'tmp_name'])
147 (\filesize($_FILES[
'tarFile'][
'tmp_name']) > 0) &&
149 \mb_substr($_FILES[
'tarFile'][
'name'], -7) ===
'.tar.gz' ||
150 \mb_substr($_FILES[
'tarFile'][
'name'], -4) ===
'.tar'
154 if (\mb_substr($_FILES[
'tarFile'][
'name'], -7) ===
'.tar.gz')
163 if ($this->moveUploadedFile($_FILES[
'tarFile'], $suffix))
166 $success = ($this->
hasErrors() ===
false);
176 if ($_FILES[
'tarFile'][
'error'] == UPLOAD_ERR_INI_SIZE)
180 '#SIZE#' => \CFile::formatSize(self::getMaxUploadSize())
195 $result[
'STATUS'] = Translate\Controller\STATUS_COMPLETED;
211 private function moveUploadedFile($postedFile, $suffix =
'.tar', $timeToLive = 3): bool
214 isset($postedFile[
'tmp_name']) &&
215 \file_exists($postedFile[
'tmp_name'])
219 $tmpFile = Translate\IO\File::generateTemporalFile(
'translate', $suffix, $timeToLive);
220 if (@\copy($postedFile[
'tmp_name'], $tmpFile->getPhysicalPath()))
222 $this->archiveFileType = $suffix;
223 $this->archiveFilePath = $tmpFile->getPhysicalPath();
244 if (!empty($settings[
'tmpFolderPath']))
247 if ($tempLanguageDir->isExists())
249 if ($tempLanguageDir->delete() !==
true)
257 'STATUS' => Translate\Controller\STATUS_COMPLETED
282 if (!empty($settings[
'archiveFilePath']))
285 if ($path->isExists())
293 'STATUS' => Translate\Controller\STATUS_COMPLETED
309 $cancelingAction = $this->request->get(
'cancelingAction');
311 \in_array($cancelingAction, [self::ACTION_COLLECT, self::ACTION_PACK]) ?
317 'SUMMARY' => $summary,
318 'STATUS' => Translate\Controller\STATUS_COMPLETED
332 if (!empty($settings[
'downloadParams'][
'filePath']) && !empty($settings[
'downloadParams'][
'fileName']))
334 $file =
new Main\IO\File($settings[
'downloadParams'][
'filePath']);
335 if ($file->isExists())
339 $settings[
'downloadParams'][
'fileName'],
340 $settings[
'downloadParams'][
'fileType']
369 static $maxUploadSize = -1;
370 if ($maxUploadSize < 0)
372 $maxUploadSize = \min(
373 \CUtil::unformat(
'32M'),
374 \CUtil::unformat(\ini_get(
'post_max_size')),
375 \CUtil::unformat(\ini_get(
'upload_max_filesize'))
379 return $maxUploadSize;
static getMessage($code, $replace=null, $language=null)