19 private int $seekPathLangId = 0;
21 private string $seekLangFilePath =
'';
22 private string $seekPhraseCode =
'';
33 $this->
keepField([
'seekPathLangId',
'seekLangFilePath',
'seekPhraseCode']);
35 Loc::loadLanguageFile(__DIR__ .
'/exportaction.php');
60 if (\preg_match(
"#(.+/lang/[^/]+/?)(.*)$#",
$path, $subMatches))
62 $subPath = $subMatches[2];
74 if ($this->isNewProcess)
77 $this->processedItems = 0;
79 if ($this->totalItems > 0)
82 $csvFile = $this->createExportTempFile($this->exportFileName);
83 $this->exportFilePath = $csvFile->getPhysicalPath();
84 $this->exportFileSize = $csvFile->getSize();
86 if ($this->appendSamples)
89 $sampleFile = $this->createExportTempFile($this->samplesFileName);
90 $this->samplesFilePath = $sampleFile->getPhysicalPath();
91 $this->samplesFileSize = $sampleFile->getSize();
98 'PROCESSED_ITEMS' => 0,
99 'TOTAL_ITEMS' => $this->totalItems,
100 'TOTAL_PHRASES' => $this->exportedPhraseCount,
101 'TOTAL_SAMPLES' => $this->exportedSamplesCount,
105 return $this->
performStep(
'runExporting', [
'path' =>
$path,
'subPath' => $subPath]);
118 $subPath = \trim(
$params[
'subPath'],
'/');
122 $csvFile->openWrite(
Main\
IO\FileStreamOpenMode::APPEND);
124 if ($this->appendSamples)
128 $samplesFile->openWrite(
Main\
IO\FileStreamOpenMode::APPEND);
135 '=%PATH' =>
$path.
'/%',
137 if (!empty($this->seekPathLangId))
139 $pathFilter[
'>=ID'] = $this->seekPathLangId;
142 $currentLangId = Loc::getCurrentLang();
145 'filter' => $pathFilter,
146 'order' => [
'ID' =>
'ASC'],
147 'select' => [
'ID',
'PATH'],
149 $processedItemCount = 0;
150 while (
$pathLang = $cachePathLangRes->fetch())
152 $lookThroughPath =
$pathLang[
'PATH'].
'/#LANG_ID#';
153 if (!empty($subPath))
155 $lookThroughPath .=
'/'. $subPath;
159 foreach ($filePaths as $langFilePath => $fullPaths)
161 if (!empty($this->seekLangFilePath))
163 if ($langFilePath == $this->seekLangFilePath)
165 $this->seekLangFilePath =
'';
176 if (!empty($this->seekPhraseCode))
178 if (
$code == $this->seekPhraseCode)
180 $this->seekPhraseCode =
'';
185 $csvFile->put(array_values($row));
189 && !empty($row[$currentLangId])
190 && mb_strlen($row[$currentLangId]) < $this->maxSampleSourceLength
193 $samples = $this->findSamples(
194 $row[$currentLangId],
198 $this->samplesRestriction
200 foreach ($samples as $sample)
202 $samplesFile->put(\array_values($sample));
203 $this->exportedSamplesCount ++;
207 $this->exportedPhraseCount ++;
211 $this->seekPhraseCode =
$code;
216 $this->seekPhraseCode =
'';
222 $this->seekLangFilePath = $langFilePath;
227 $this->seekLangFilePath =
'';
232 $processedItemCount ++;
236 $this->seekPathLangId = (int)
$pathLang[
'ID'];
241 $this->exportFileSize = $csvFile->getSize();
244 if ($this->appendSamples)
246 $this->samplesFileSize = $samplesFile->getSize();
247 $samplesFile->close();
250 $this->processedItems += $processedItemCount;
265 if ($csvFile->hasErrors())
267 $errors = $csvFile->getErrors();
270 if ($err->getCode() == Translate\IO\CsvFile::ERROR_32K_FIELD_LENGTH)
272 $result[
'WARNING'] = Loc::getMessage(
'TR_EXPORT_ERROR_32K_LENGTH');
static getList(array $parameters=array())