91 public function run(
$path =
'', $runBefore =
false)
105 if ($this->isNewProcess)
108 $this->totalItems = 0;
109 $this->processedItems = 0;
110 $this->totalFileCount = 0;
113 $languageId = $this->controller->getRequest()->get(
'languageId');
114 if (empty($languageId))
118 if (!in_array($languageId, self::$enabledLanguages))
124 $this->languageId = $languageId;
128 $this->convertEncoding = ($this->controller->getRequest()->
get(
'convertEncoding') ===
'Y');
131 $encoding = $this->controller->getRequest()->get(
'encoding');
132 if ($encoding !==
null && in_array($encoding, self::$allowedEncodings))
134 $this->encoding = $encoding;
136 elseif ($this->convertEncoding)
141 if ($this->convertEncoding)
143 if (self::$useTranslationRepository)
146 $encodingOut = $this->encoding;
147 if ($encodingIn ===
'utf-8' && $encodingOut !==
'utf-8')
149 $this->
addError(
new Error(Loc::getMessage(
'TR_ERROR_LANGUAGE_CHARSET_NON_UTF')));
154 $encodingIn =
'utf-8';
155 $encodingOut = $this->encoding;
156 if (
Translate\Config::getCultureEncoding($this->languageId) !==
'utf-8')
158 $this->
addError(
new Error(Loc::getMessage(
'TR_ERROR_LANGUAGE_CHARSET_NON_UTF')));
168 $this->encoding = $encodingOut =
'utf-8';
171 $this->convertEncoding = (\mb_strtolower($encodingIn) !== \mb_strtolower($encodingOut));
175 $assemblyDate = $this->controller->getRequest()->get(
'assemblyDate');
176 if ($assemblyDate !==
null && \preg_replace(
"/[\D]+/",
"", $assemblyDate) && \mb_strlen($assemblyDate) == 8)
178 $this->assemblyDate = $assemblyDate;
187 $this->packFile = ($this->controller->getRequest()->
get(
'packFile') ===
'Y');
193 if (!empty($exportFolder))
196 if ($tempDir->isExists())
208 $tempDir = $tempDir->createSubdirectory($this->languageId);
210 $this->tmpFolderPath = $tempDir->getPhysicalPath().
'/';
211 if (!$tempDir->isExists())
214 new Error(Loc::getMessage(
'TR_ERROR_CREATE_TEMP_FOLDER', [
'#PATH#' => $this->tmpFolderPath]))
221 $fileDateMarkFullPath = $this->tmpFolderPath.
226 $fileDateMark =
new Main\IO\File($fileDateMarkFullPath);
227 if ($fileDateMark->putContents($assemblyDate) ===
false)
230 new Error(Loc::getMessage(
'TR_ERROR_OPEN_FILE', [
'#FILE#' => $fileDateMarkFullPath]))
236 $this->processedItems = 0;
242 'PROCESSED_ITEMS' => 0,
243 'TOTAL_ITEMS' => $this->totalItems,
249 $this->languageId = $progressParams[
'languageId'];
250 $this->convertEncoding = $progressParams[
'convertEncoding'];
251 $this->encoding = $progressParams[
'encoding'];
252 $this->assemblyDate = $progressParams[
'assemblyDate'];
253 $this->packFile = $progressParams[
'packFile'];
254 $this->tmpFolderPath = $progressParams[
'tmpFolderPath'];
256 if (isset($progressParams[
'totalItems']) && (
int)$progressParams[
'totalItems'] > 0)
258 $this->totalItems = (int)$progressParams[
'totalItems'];
259 $this->processedItems = (int)$progressParams[
'processedItems'];
260 $this->totalFileCount = (int)$progressParams[
'totalFileCount'];
263 if (isset($progressParams[
'seekPathLangId']))
265 $this->seekPathLangId = $progressParams[
'seekPathLangId'];