Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
lfeditor
Commits
165b07d2
Commit
165b07d2
authored
Apr 03, 2018
by
Fabian Galinski
😾
Browse files
[TASK] More cleanup
parent
729b792c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Classes/Service/FileBaseService.php
View file @
165b07d2
...
...
@@ -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
(
LF
Exception
$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['
,
'<![CDATA['
,
$fileContent
);
$fileContent
=
str_replace
(
']]>'
,
']]>'
,
$fileContent
);
if
(
\
strpos
(
$fileContent
,
'<generator>LFEditor</generator>'
)
===
FALSE
)
{
$fileContent
=
\
str_replace
([
'<![CDATA['
,
']]>'
],
[
'<![CDATA['
,
']]>'
],
$fileContent
);
}
else
{
return
FALSE
;
}
...
...
@@ -203,5 +201,3 @@ abstract class FileBaseService extends FileService {
return
$fileContent
;
}
}
?>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment