Commit 6ed60963 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer

[TASK] make visibility option human readbable

parent 7bfce8c2
......@@ -314,7 +314,7 @@ abstract class Element {
);
if ($flagRow === FALSE || $flagRow === NULL) {
$flag = '-';
$flag = 'active';
} else {
$flag = $flagRow['flag'];
}
......
......@@ -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,
......
......@@ -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();
}
......
......@@ -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['translated'] = 'translated';
$select['fallback'] = '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['translated'] = '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';
}
/**
......
......@@ -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;
}
......
......@@ -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 === 'fallback') {
$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('translated')->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] = 'fallback';
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] = 'fallback';
}
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] = 'fallback';
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] = 'fallback';
}
return $this->cachedDefaultVisibilityForPages[$languageUid];
......
......@@ -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' => $visibilitySetting,
'flag' => $newVisibilityFlag,
'record_table' => $table,
'record_uid' => $recordUid,
'record_language_uid' => $lid,
......
......@@ -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 'translated' :
case 'fallback' :
$res = $key;
break;
}
......
......@@ -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.translated', 'translated'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.fallback', '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' => 'fallback',
'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.translated', 'translated'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.fallback', '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' => 'fallback',
'size' => 1,
'maxitems' => 1,
]
......
......@@ -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.fallback" approved="yes">
<source>&#160;&#160;&#160;+ or in fallback</source>
<target>&#160;&#160;&#160;+ 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>
......
......@@ -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.fallback">
<source>&#160;&#160;&#160;+ 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">
......
......@@ -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 'translated' NOT NULL,
tx_languagevisibility_defaultvisibilityel varchar(11) DEFAULT 'translated' NOT NULL
);
#
......
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