Commit 09482c8c authored by Rémy DANIEL's avatar Rémy DANIEL

Revert "[BUGFIX] Errors can appear for the first usage of a language file with <CDATA[]]> values"

This reverts commit 1e624594.
parent 305d8297
......@@ -85,8 +85,6 @@ abstract class FileBaseService extends FileService {
$this->setWorkspace('base');
parent::init($file, $path, $metaFile);
$this->prepareLanguageFilesForFirstUsage();
}
/**
......@@ -142,62 +140,4 @@ abstract class FileBaseService extends FileService {
$this->localLang = $localLang;
$this->originLang = $originLang;
}
/**
* Prepares this language file and it's translations for the first usage.
*
* @throws LFException
* @return void
*/
protected function prepareLanguageFilesForFirstUsage() {
$adaptedContent = $this->checkFileForFirstImport($this->absFile);
if ($adaptedContent) {
$files = [];
$files[$this->absFile] = $adaptedContent;
$languages = SgLib::getSystemLanguages();
foreach ($languages as $lang) {
if ($lang === 'default') {
continue;
}
$file = \dirname($this->absFile) . '/' . $this->nameLocalizedFile($lang);
if (file_exists($file) && $this->checkLocalizedFile(basename($file), $lang)) {
$adaptedContent = $this->checkFileForFirstImport($file);
if ($adaptedContent) {
$files[$file] = $adaptedContent;
}
}
}
$this->writeFilesWithContent($files);
}
}
/**
* Checks if the given file is generated by this extension, if not the data will be prepared and returned.
*
* @param string $file
* @return bool|string
*/
protected function checkFileForFirstImport($file) {
if (!file_exists($file)) {
return FALSE;
}
// Don't do this on a XML file, because the CDATA will be ignored, if it's done...
$fileParts = pathinfo($file);
if ($fileParts['extension'] === 'xml') {
return FALSE;
}
$fileContent = file_get_contents($file);
if (\strpos($fileContent, '<generator>LFEditor</generator>') === FALSE) {
$fileContent = \str_replace(['<![CDATA[', ']]>'], ['&lt;![CDATA[', ']]&gt;'], $fileContent);
} else {
return FALSE;
}
return $fileContent;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment