Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TYPO3
languagevisibility
Commits
6ed60963
Commit
6ed60963
authored
Jun 18, 2020
by
Fabio Stegmeyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] make visibility option human readbable
parent
7bfce8c2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
74 deletions
+82
-74
Classes/Element/Element.php
Classes/Element/Element.php
+1
-1
Classes/Hook/TceMainHook.php
Classes/Hook/TceMainHook.php
+1
-1
Classes/Repository/VisibilityFlagRepository.php
Classes/Repository/VisibilityFlagRepository.php
+1
-1
Classes/Service/BackendServices.php
Classes/Service/BackendServices.php
+13
-13
Classes/Service/FrontendServices.php
Classes/Service/FrontendServices.php
+2
-2
Classes/Service/VisibilityService.php
Classes/Service/VisibilityService.php
+14
-16
Classes/Updates/VisibilitySettingsMigrationWizard.php
Classes/Updates/VisibilitySettingsMigrationWizard.php
+21
-4
Classes/UserFunction/FieldVisibilityUserFunction.php
Classes/UserFunction/FieldVisibilityUserFunction.php
+5
-5
Configuration/TCA/Overrides/sys_language.php
Configuration/TCA/Overrides/sys_language.php
+12
-12
Resources/Private/Language/de.locallang_db.xlf
Resources/Private/Language/de.locallang_db.xlf
+5
-9
Resources/Private/Language/locallang_db.xlf
Resources/Private/Language/locallang_db.xlf
+5
-8
ext_tables.sql
ext_tables.sql
+2
-2
No files found.
Classes/Element/Element.php
View file @
6ed60963
...
...
@@ -314,7 +314,7 @@ abstract class Element {
);
if
(
$flagRow
===
FALSE
||
$flagRow
===
NULL
)
{
$flag
=
'
-
'
;
$flag
=
'
active
'
;
}
else
{
$flag
=
$flagRow
[
'flag'
];
}
...
...
Classes/Hook/TceMainHook.php
View file @
6ed60963
...
...
@@ -236,7 +236,7 @@ class TceMainHook {
if
(
$flagRow
!==
NULL
&&
isset
(
$flagRow
[
'flag'
]))
{
$flag
=
$flagRow
[
'flag'
];
}
else
{
$flag
=
'
-
'
;
$flag
=
'
active
'
;
}
// since the data mapper automatically copies the flag records,
...
...
Classes/Repository/VisibilityFlagRepository.php
View file @
6ed60963
...
...
@@ -205,7 +205,7 @@ class VisibilityFlagRepository implements SingletonInterface {
$queryBuilder
->
delete
(
'tx_languagevisibility_visibility_flag'
)
->
where
(
$queryBuilder
->
expr
()
->
eq
(
'flag'
,
$queryBuilder
->
createNamedParameter
(
'
-
'
))
$queryBuilder
->
expr
()
->
eq
(
'flag'
,
$queryBuilder
->
createNamedParameter
(
'
active
'
))
)
->
execute
();
}
...
...
Classes/Service/BackendServices.php
View file @
6ed60963
...
...
@@ -266,15 +266,15 @@ class BackendServices extends AbstractServices {
if
(
!
$isOverlay
)
{
if
(
$uid
===
0
)
{
$select
[
'
-'
]
=
'-
'
;
$select
[
'
yes'
]
=
'yes
'
;
$select
[
'
no'
]
=
'no
'
;
$select
[
'
active'
]
=
'active
'
;
$select
[
'
enforce'
]
=
'enforce
'
;
$select
[
'
inactive'
]
=
'inactive
'
;
}
else
{
$select
[
'
-'
]
=
'-
'
;
$select
[
'
yes'
]
=
'yes
'
;
$select
[
't
'
]
=
't
'
;
$select
[
'f
'
]
=
'f
'
;
$select
[
'
no'
]
=
'no
'
;
$select
[
'
active'
]
=
'active
'
;
$select
[
'
enforce'
]
=
'enforce
'
;
$select
[
't
ranslated'
]
=
'translated
'
;
$select
[
'f
allback'
]
=
'fallback
'
;
$select
[
'
inactive'
]
=
'inactive
'
;
}
//check permissions, if user has no permission only no for the language is allowed
...
...
@@ -293,18 +293,18 @@ class BackendServices extends AbstractServices {
}
$select
=
[];
if
(
$isInFallback
)
{
$select
[
'
-'
]
=
'-
'
;
$select
[
'
active'
]
=
'active
'
;
}
if
(
$uid
!==
0
&&
self
::
isTranslatedAsDefaultEnabled
())
{
$select
[
't
'
]
=
't
'
;
$select
[
't
ranslated'
]
=
'translated
'
;
}
$select
[
'
no'
]
=
'no
'
;
$select
[
'
inactive'
]
=
'inactive
'
;
}
}
else
{
//overlays elements can only have "force to no"
$select
[
'
-'
]
=
'-
'
;
$select
[
'
no'
]
=
'no
'
;
$select
[
'
active'
]
=
'active
'
;
$select
[
'
inactive'
]
=
'inactive
'
;
}
/**
...
...
Classes/Service/FrontendServices.php
View file @
6ed60963
...
...
@@ -74,11 +74,11 @@ class FrontendServices extends AbstractServices implements SingletonInterface {
$visibilityFlag
=
$visibilityFlag
[
'flag'
];
}
if
(
!
$visibilityFlag
||
$visibilityFlag
===
'
yes
'
||
$visibilityFlag
===
'
-
'
)
{
if
(
!
$visibilityFlag
||
$visibilityFlag
===
'
enforce
'
||
$visibilityFlag
===
'
active
'
)
{
return
TRUE
;
}
if
(
$visibilityFlag
===
'
no'
||
$visibilityFlag
===
'no+
'
)
{
if
(
$visibilityFlag
===
'
inactive
'
)
{
return
FALSE
;
}
...
...
Classes/Service/VisibilityService.php
View file @
6ed60963
...
...
@@ -144,26 +144,24 @@ class VisibilityService implements SingletonInterface {
*/
public
function
resolveVisibility
(
$visibility
,
$language
,
$element
):
bool
{
if
(
$visibility
===
''
||
$visibility
===
'
-
'
)
{
if
(
$visibility
===
''
||
$visibility
===
'
active
'
)
{
return
TRUE
;
}
if
(
$visibility
===
'
yes
'
)
{
if
(
$visibility
===
'
enforce
'
)
{
if
(
!
$element
->
hasTranslation
(
$language
->
getLanguageId
()))
{
$this
->
_relevantOverlayLanguageId
=
0
;
}
$result
=
TRUE
;
}
elseif
(
$visibility
===
'
no+
'
)
{
}
elseif
(
$visibility
===
'
inactive
'
)
{
$result
=
FALSE
;
}
elseif
(
$visibility
===
'no'
)
{
$result
=
FALSE
;
}
elseif
(
$visibility
===
't'
)
{
}
elseif
(
$visibility
===
'translated'
)
{
if
(
$element
->
hasTranslation
(
$language
->
getLanguageId
()))
{
$result
=
TRUE
;
}
else
{
$result
=
FALSE
;
}
}
elseif
(
$visibility
===
'f'
)
{
}
elseif
(
$visibility
===
'f
allback
'
)
{
$hidden
=
FALSE
;
$isContentElement
=
(
$element
instanceof
ContentElement
);
if
(
$isContentElement
)
{
...
...
@@ -297,21 +295,21 @@ class VisibilityService implements SingletonInterface {
$visibility
=
new
Visibility
();
$local
=
$element
->
getVisibilitySettingForLanguage
(
$language
->
getLanguageId
());
if
(
$local
!==
''
&&
$local
!==
'
-
'
)
{
if
(
$local
!==
''
&&
$local
!==
'
active
'
)
{
$visibility
->
setVisibilityString
(
$local
)
->
setVisibilityDescription
(
'local setting '
.
$local
);
return
$visibility
;
}
if
(
$element
->
isLanguageSetToAll
())
{
$visibility
->
setVisibilityString
(
'
yes
'
)
->
setVisibilityDescription
(
'language configured to all'
);
$visibility
->
setVisibilityString
(
'
enforce
'
)
->
setVisibilityDescription
(
'language configured to all'
);
return
$visibility
;
}
if
(
$element
->
isMonolithicTranslated
())
{
if
(
$element
->
languageEquals
(
$language
))
{
$visibility
->
setVisibilityString
(
'
yes
'
)
->
setVisibilityDescription
(
''
);
$visibility
->
setVisibilityString
(
'
enforce
'
)
->
setVisibilityDescription
(
''
);
}
else
{
$visibility
->
setVisibilityString
(
'
no
'
)
->
setVisibilityDescription
(
''
);
$visibility
->
setVisibilityString
(
'
inactive
'
)
->
setVisibilityDescription
(
''
);
}
return
$visibility
;
...
...
@@ -330,7 +328,7 @@ class VisibilityService implements SingletonInterface {
}
if
(
$visibility
->
getVisibilityString
()
===
''
)
{
$visibility
->
setVisibilityString
(
't'
)
->
setVisibilityDescription
(
$visibility
->
setVisibilityString
(
't
ranslated
'
)
->
setVisibilityDescription
(
'no visibility configured using default setting "t"'
);
}
...
...
@@ -354,7 +352,7 @@ class VisibilityService implements SingletonInterface {
'SELECT uid, tx_languagevisibility_defaultvisibilityel FROM sys_language'
);
$this
->
cachedDefaultVisibilityForElements
[
0
]
=
'f'
;
$this
->
cachedDefaultVisibilityForElements
[
0
]
=
'f
allback
'
;
if
(
$results
->
execute
())
{
foreach
(
$results
->
fetchAll
()
as
$entry
)
{
$this
->
cachedDefaultVisibilityForElements
[
$entry
[
'uid'
]]
=
$entry
[
'tx_languagevisibility_defaultvisibilityel'
];
...
...
@@ -364,7 +362,7 @@ class VisibilityService implements SingletonInterface {
// this can happen, when a language doesn't have a record
if
(
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
===
NULL
)
{
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
=
'f'
;
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
=
'f
allback
'
;
}
return
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
];
...
...
@@ -386,7 +384,7 @@ class VisibilityService implements SingletonInterface {
'SELECT uid, tx_languagevisibility_defaultvisibility FROM sys_language'
);
$this
->
cachedDefaultVisibilityForPages
[
0
]
=
'f'
;
$this
->
cachedDefaultVisibilityForPages
[
0
]
=
'f
allback
'
;
if
(
$results
->
execute
())
{
foreach
(
$results
->
fetchAll
()
as
$entry
)
{
...
...
@@ -397,7 +395,7 @@ class VisibilityService implements SingletonInterface {
// this can happen, when a language doesn't have a record
if
(
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
===
NULL
)
{
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
=
'f'
;
$this
->
cachedDefaultVisibilityForElements
[
$languageUid
]
=
'f
allback
'
;
}
return
$this
->
cachedDefaultVisibilityForPages
[
$languageUid
];
...
...
Classes/Updates/VisibilitySettingsMigrationWizard.php
View file @
6ed60963
...
...
@@ -24,6 +24,21 @@ class VisibilitySettingsMigrationWizard implements UpgradeWizardInterface {
*/
protected
$visibilityFlagRepository
;
/**
* mapping of old to new visibility flag strings
*
* @var string[]
*/
protected
$oldToNewFlagMapping
=
[
'-'
=>
'active'
,
'yes'
=>
'enforce'
,
'yes+'
=>
'enforce'
,
't'
=>
'translated'
,
'f'
=>
'fallback'
,
'no'
=>
'inactive'
,
'no+'
=>
'inactive'
,
];
/**
* Return the identifier for this wizard
* This should be the same string as used in the ext_localconf class registration
...
...
@@ -69,10 +84,10 @@ class VisibilitySettingsMigrationWizard implements UpgradeWizardInterface {
$availableLanguages
=
[];
// make sure we get ALL the languages
foreach
(
$sites
as
$site
){
foreach
(
$sites
as
$site
)
{
$availableLanguagesFromSites
=
$site
->
getAllLanguages
();
foreach
(
$availableLanguagesFromSites
as
$availableLanguage
){
if
(
!
isset
(
$availableLanguages
[
$availableLanguage
->
getLanguageId
()])){
foreach
(
$availableLanguagesFromSites
as
$availableLanguage
)
{
if
(
!
isset
(
$availableLanguages
[
$availableLanguage
->
getLanguageId
()]))
{
$availableLanguages
[
$availableLanguage
->
getLanguageId
()]
=
$availableLanguage
;
}
}
...
...
@@ -161,12 +176,14 @@ class VisibilitySettingsMigrationWizard implements UpgradeWizardInterface {
$recordUid
=
$table
.
'_'
.
$uid
;
}
$newVisibilityFlag
=
$this
->
oldToNewFlagMapping
[
$visibilitySetting
];
$queryBuilderVisibilityFlags
->
insert
(
'tx_languagevisibility_visibility_flag'
)
->
values
(
[
'pid'
=>
$pid
,
'flag'
=>
$
v
isibility
Settin
g
,
'flag'
=>
$
newV
isibility
Fla
g
,
'record_table'
=>
$table
,
'record_uid'
=>
$recordUid
,
'record_language_uid'
=>
$lid
,
...
...
Classes/UserFunction/FieldVisibilityUserFunction.php
View file @
6ed60963
...
...
@@ -190,7 +190,7 @@ class FieldVisibilityUserFunction {
$currentVisibilityFlag
=
$visbilityFlag
[
'flag'
];
}
else
{
$visibilityFlagUid
=
uniqid
(
'NEW'
,
TRUE
);
$currentVisibilityFlag
=
'
-
'
;
$currentVisibilityFlag
=
'
active
'
;
}
if
(
$changeableElement
->
getTable
()
===
'pages'
)
{
...
...
@@ -351,10 +351,10 @@ class FieldVisibilityUserFunction {
protected
function
getCSSClassFromVisibilityKey
(
$key
):
string
{
$res
=
''
;
switch
(
$key
)
{
case
'
yes
'
:
case
'
no
'
:
case
't'
:
case
'f'
:
case
'
enforce
'
:
case
'
inactive
'
:
case
't
ranslated
'
:
case
'f
allback
'
:
$res
=
$key
;
break
;
}
...
...
Configuration/TCA/Overrides/sys_language.php
View file @
6ed60963
...
...
@@ -34,13 +34,13 @@ call_user_func(
'type'
=>
'select'
,
'renderType'
=>
'selectSingle'
,
'items'
=>
[
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
-'
,
'
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t
'
,
't
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f
'
,
'f
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
yes'
,
'yes
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
no'
,
'no
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
active'
,
'active
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t
ranslated'
,
'translated
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f
allback'
,
'fallback
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
enforce'
,
'enforce
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
inactive'
,
'inactive
'
],
],
'default'
=>
'f'
,
'default'
=>
'f
allback
'
,
'size'
=>
1
,
'maxitems'
=>
1
,
]
...
...
@@ -52,13 +52,13 @@ call_user_func(
'type'
=>
'select'
,
'renderType'
=>
'selectSingle'
,
'items'
=>
[
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
-'
,
'
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t
'
,
't
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f
'
,
'f
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
yes'
,
'yes
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
no'
,
'no
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
active'
,
'active
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t
ranslated'
,
'translated
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f
allback'
,
'fallback
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
enforce'
,
'enforce
'
],
[
'LLL:EXT:'
.
$extKey
.
'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.
inactive'
,
'inactive
'
],
],
'default'
=>
'f'
,
'default'
=>
'f
allback
'
,
'size'
=>
1
,
'maxitems'
=>
1
,
]
...
...
Resources/Private/Language/de.locallang_db.xlf
View file @
6ed60963
...
...
@@ -83,27 +83,23 @@
<source>
empty
</source>
<target>
leer
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
-
"
approved=
"yes"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
active
"
approved=
"yes"
>
<source>
Active
</source>
<target>
Verfügbar
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.f"
approved=
"yes"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.f
allback
"
approved=
"yes"
>
<source>
   
+ or in fallback
</source>
<target>
   
+ oder im Fallback
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
no
"
approved=
"yes"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
inactive
"
approved=
"yes"
>
<source>
Inactive
</source>
<target>
Nicht verfügbar
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.no+"
approved=
"yes"
>
<source>
Inactive
</source>
<target>
Nicht verfügbar
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.t"
approved=
"yes"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.translated"
approved=
"yes"
>
<source>
+ only if translated
</source>
<target>
+ nur falls übersetzt
</target>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
yes
"
approved=
"yes"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
enforce
"
approved=
"yes"
>
<source>
+ enforce
</source>
<target>
+ erzwingen
</target>
</trans-unit>
...
...
Resources/Private/Language/locallang_db.xlf
View file @
6ed60963
...
...
@@ -64,22 +64,19 @@
<trans-unit
id=
"tx_languagevisibility_visibility.I."
>
<source>
empty
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
-
"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
active
"
>
<source>
Active
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.f"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.f
allback
"
>
<source>
   
+ or in fallback
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
no
"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
inactive
"
>
<source>
Inactive
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.no+"
>
<source>
Inactive
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.t"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.translated"
>
<source>
+ only if translated
</source>
</trans-unit>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
yes
"
>
<trans-unit
id=
"tx_languagevisibility_visibility.I.
enforce
"
>
<source>
+ enforce
</source>
</trans-unit>
<trans-unit
id=
"visibility"
>
...
...
ext_tables.sql
View file @
6ed60963
...
...
@@ -2,8 +2,8 @@
#
Table
structure
for
table
'sys_language'
#
CREATE
TABLE
sys_language
(
tx_languagevisibility_defaultvisibility
varchar
(
11
)
DEFAULT
't'
NOT
NULL
,
tx_languagevisibility_defaultvisibilityel
varchar
(
11
)
DEFAULT
't'
NOT
NULL
tx_languagevisibility_defaultvisibility
varchar
(
11
)
DEFAULT
't
ranslated
'
NOT
NULL
,
tx_languagevisibility_defaultvisibilityel
varchar
(
11
)
DEFAULT
't
ranslated
'
NOT
NULL
);
#
...
...
Write
Preview
Markdown
is supported
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