Commit 165b07d2 authored by Fabian Galinski's avatar Fabian Galinski

[TASK] More cleanup

parent 729b792c
......@@ -66,19 +66,17 @@ abstract class FileBaseService extends FileService {
/**
* extended init
*
* @throws LFException
* @param string $file name of the file (can be a path, if you need this (no check))
* @param string $path path to the file
* @param string $metaFile
*
* @return void
* @throws \InvalidArgumentException
* @throws LFException
*/
public function init($file, $path, $metaFile) {
if (class_exists('TYPO3\CMS\Core\Localization\Locales')) {
/** @var $locales Locales */
$locales = GeneralUtility::makeInstance('TYPO3\CMS\Core\Localization\Locales');
$availableLanguages = implode('|', $locales->getLocales());
} else {
$availableLanguages = TYPO3_languages;
}
$locales = GeneralUtility::makeInstance(Locales::class);
$availableLanguages = implode('|', $locales->getLocales());
// localization files should not be edited
if ($this->checkLocalizedFile(basename($file), $availableLanguages)) {
......@@ -94,6 +92,7 @@ abstract class FileBaseService extends FileService {
/**
* reads the absolute language file with all localized sub files
*
* @throws \Exception
* @throws LFException
* @return void
*/
......@@ -102,12 +101,12 @@ abstract class FileBaseService extends FileService {
$localLang = $this->readLLFile($this->absFile, 'default');
// loop all languages
$languages = SgLib::getSystemLanguages();
$originLang = array();
$originLang = [];
foreach ($languages as $lang) {
$originLang[$lang] = $this->absFile;
if ((is_array($localLang[$lang]) && count($localLang[$lang])) || $lang === 'default') {
if (is_array($localLang[$lang]) && count($localLang[$lang])) {
ksort($localLang[$lang]);
if ($lang === 'default' || (\is_array($localLang[$lang]) && \count($localLang[$lang])) ) {
if (\is_array($localLang[$lang]) && \count($localLang[$lang])) {
\ksort($localLang[$lang]);
}
continue;
}
......@@ -116,7 +115,7 @@ abstract class FileBaseService extends FileService {
$lFile = $this->getLocalizedFile($localLang[$lang], $lang);
if ($lFile && $this->checkLocalizedFile(basename($lFile), $lang)) {
$originLang[$lang] = $lFile;
$localLang[$lang] = array();
$localLang[$lang] = [];
if (!is_file($lFile)) {
continue;
......@@ -125,7 +124,7 @@ abstract class FileBaseService extends FileService {
// read the content
try {
$llang = $this->readLLFile($lFile, $lang);
} catch (LFException $e) {
} catch (\Exception $e) {
throw $e;
}
......@@ -135,7 +134,7 @@ abstract class FileBaseService extends FileService {
}
// check
if (!is_array($localLang)) {
if (!\is_array($localLang)) {
throw new LFException('failure.search.noFileContent');
}
......@@ -153,7 +152,7 @@ abstract class FileBaseService extends FileService {
protected function prepareLanguageFilesForFirstUsage() {
$adaptedContent = $this->checkFileForFirstImport($this->absFile);
if ($adaptedContent) {
$files = array();
$files = [];
$files[$this->absFile] = $adaptedContent;
$languages = SgLib::getSystemLanguages();
......@@ -162,7 +161,7 @@ abstract class FileBaseService extends FileService {
continue;
}
$file = dirname($this->absFile) . '/' . $this->nameLocalizedFile($lang);
$file = \dirname($this->absFile) . '/' . $this->nameLocalizedFile($lang);
if (file_exists($file) && $this->checkLocalizedFile(basename($file), $lang)) {
$adaptedContent = $this->checkFileForFirstImport($file);
if ($adaptedContent) {
......@@ -193,9 +192,8 @@ abstract class FileBaseService extends FileService {
}
$fileContent = file_get_contents($file);
if (strpos($fileContent, '<generator>LFEditor</generator>') === FALSE) {
$fileContent = str_replace('<![CDATA[', '&lt;![CDATA[', $fileContent);
$fileContent = str_replace(']]>', ']]&gt;', $fileContent);
if (\strpos($fileContent, '<generator>LFEditor</generator>') === FALSE) {
$fileContent = \str_replace(['<![CDATA[', ']]>'], ['&lt;![CDATA[', ']]&gt;'], $fileContent);
} else {
return FALSE;
}
......@@ -203,5 +201,3 @@ abstract class FileBaseService extends FileService {
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