Commit 19ddbba7 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer

[TASK] Remove inheritance

parent 261f9205
......@@ -440,15 +440,6 @@ abstract class Element {
return 'TYPO3 Element';
}
/**
* By default no element supports inheritance
*
* @return bool
*/
public function supportsInheritance(): bool {
return FALSE;
}
/**
* Gets the cache
*
......
......@@ -105,22 +105,6 @@ class ElementFactory {
return $element;
}
/**
* This method is used to retrieve all parent elements (an parent elements needs to
* have the flag 'tx_languagevisibility_inheritanceflag_original' or
* needs to be orverlayed with a record, that has the field 'tx_languagevisibility_inheritanceflag_overlayed'
* configured or is the first element of the rootline
*
* @param Element $element
* @param SiteLanguage $language
* @return array $elements (collection of tx_languagevisibility_element)
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function getParentElementsFromElement(Element $element, SiteLanguage $language) {
$parentPage = $this->getElementForTable('pages', $element->getRow());
return $this->getParentElementsFromElement($parentPage, $language);
}
/**
* This method is needed because the getRootline method from t3lib_pageSelect causes an error when
* getRootline is called be cause getRootline internally uses languagevisibility to determine the
......
......@@ -254,21 +254,7 @@ class BackendServices extends AbstractServices {
}
/**
* Method to check if the inheritance is enabled or not
*
* @return boolean
*/
protected static function isInheritanceEnabled() {
$confArr = ExtensionUtility::getExtensionConfiguration();
if (is_array($confArr)) {
return (bool) $confArr['inheritanceEnabled'];
}
return FALSE;
}
/**
* Method to check if the inheritance is enabled or not
* Method to check if the translatedAsDefaultEnabled is enabled or not
*
* @return boolean
*/
......@@ -305,29 +291,20 @@ class BackendServices extends AbstractServices {
$element = self::getContextElement('pages', $row ?: []);
}
$elementSupportsInheritance = $element->supportsInheritance();
$uid = $language->getLanguageId();
$select = [];
$useInheritance = ($elementSupportsInheritance && self::isInheritanceEnabled());
if (!$isOverlay) {
if ($uid === 0) {
$select['-'] = '-';
$select['yes'] = 'yes';
$select['no'] = 'no';
if ($useInheritance) {
$select['no+'] = 'no+';
}
} else {
$select['-'] = '-';
$select['yes'] = 'yes';
$select['t'] = 't';
$select['f'] = 'f';
$select['no'] = 'no';
if ($useInheritance) {
$select['no+'] = 'no+';
}
}
//check permissions, if user has no permission only no for the language is allowed
......@@ -353,17 +330,11 @@ class BackendServices extends AbstractServices {
$select['t'] = 't';
}
$select['no'] = 'no';
if ($useInheritance) {
$select['no+'] = 'no+';
}
}
} else {
//overlays elements can only have "force to no" or "force to no inherited"
//overlays elements can only have "force to no"
$select['-'] = '-';
$select['no'] = 'no';
if ($useInheritance) {
$select['no+'] = 'no+';
}
}
/**
......
......@@ -45,11 +45,6 @@ use TYPO3\Languagevisibility\Utility\ExtensionUtility;
*/
class VisibilityService implements SingletonInterface {
/**
* @var boolean holds the state if inheritance is enabled or not
*/
protected static $useInheritance;
/**
* @var array
*/
......@@ -70,35 +65,6 @@ class VisibilityService implements SingletonInterface {
*/
protected $cachedDefaultVisibilityForPages;
/**
* Constructor of the service, used to initialize the service with the usage of the inheritance feature.
*/
public function __construct() {
if (!isset(self::$useInheritance)) {
$confArr = ExtensionUtility::getExtensionConfiguration();
self::setUseInheritance(is_array($confArr) && $confArr['inheritanceEnabled']);
}
}
/**
* This method returns the configuration of the inheritance flag. If an inheritance flag is set
* this method can be used to read it.
*
* @return boolean
*/
public static function getUseInheritance() {
return self::$useInheritance;
}
/**
* Function to configure the visibilityService to use inherited settings.
*
* @param boolean $useInheritance
*/
public static function setUseInheritance($useInheritance = TRUE) {
self::$useInheritance = $useInheritance;
}
/**
* returns relevant languageid for overlay record or FALSE if element is not visible for guven language
*
......@@ -277,55 +243,6 @@ class VisibilityService implements SingletonInterface {
return (boolean) $pageTranslation['hidden'];
}
/**
* This method is used to get all bequeathing elements of an element (makes only sence for pages)
* it checks if there is any element in the rootline which has any inherited visibility setting (like no+, yes+) as configured visibility.
*
* @param SiteLanguage $language
* @param Element $element
*
* @return Visibility $visibility
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
protected function getInheritedVisibility(SiteLanguage $language, Element $element) {
$elementfactory = GeneralUtility::makeInstance(ElementFactory::class);
$elements = $elementfactory->getParentElementsFromElement($element, $language);
if (is_array($elements) && count($elements) > 0) {
foreach ($elements as $_element) {
/* @var $_element Element */
$visibility = new Visibility();
$visibility->setVisibilityString(
$_element->getVisibilitySettingForLanguage($language->getLanguageId())
);
$visibilityString = $visibility->getVisibilityString();
// is the setting a inheritable setting:
if ($visibilityString === 'no+' || $visibilityString === 'yes+') {
$visibility->setVisibilityDescription('inherited from uid ' . $_element->getUid());
return $visibility;
}
}
}
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getInheritedVisibility'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getInheritedVisibility'] as $classRef) {
$hookObj = GeneralUtility::makeInstance($classRef);
if (method_exists($hookObj, 'getInheritedVisibility')) {
/** @var Visibility $visibility */
$visibility = $hookObj->getInheritedVisibility($language, $elements, $element);
if (substr($visibility->getVisibilityString(), -1) === '+') {
return $visibility;
}
}
}
}
$visibility = new Visibility();
$visibility->setVisibilityString('-');
return $visibility;
}
/**
* return the accumulated visibility setting: reads default for language then reads local for element and merges them.
* if local is default, then the global is used or it is forced to be "yes" if the language was set to all.
......@@ -402,36 +319,10 @@ class VisibilityService implements SingletonInterface {
}
if ($element->getFieldToUseForDefaultVisibility() === 'page') {
if (self::getUseInheritance()) {
// gibt es in der rootline das visibility setting no+ für die sprache dann return 'no'
$inheritedVisibility = $this->getInheritedVisibility($language, $element);
switch ($inheritedVisibility->getVisibilityString()) {
case 'no+' :
// if no+ is found it means the current element should be threated as if it has no set
$visibility->setVisibilityString('no')->setVisibilityDescription(
'force to no (' . $inheritedVisibility->getVisibilityDescription() . ')'
);
break;
case 'yes+' :
$visibility->setVisibilityString('yes')->setVisibilityDescription(
'force to yes (' . $inheritedVisibility->getVisibilityDescription() . ')'
);
break;
default :
$setting = 'f';
$visibility->setVisibilityString($setting)->setVisibilityDescription(
'default visibility for page (' . $setting . ')'
);
break;
}
} else {
// inheritance is disabled
$setting = $this->getDefaultVisibilityForPagesByLanguage($language->getLanguageId());
$visibility->setVisibilityString($setting)->setVisibilityDescription(
'default visibility for page (' . $setting . ')'
);
}
$setting = $this->getDefaultVisibilityForPagesByLanguage($language->getLanguageId());
$visibility->setVisibilityString($setting)->setVisibilityDescription(
'default visibility for page (' . $setting . ')'
);
} else {
$setting = $this->getDefaultVisibilityForElementsByLanguage($language->getLanguageId());
$visibility->setVisibilityString($setting)->setVisibilityDescription(
......
......@@ -364,9 +364,6 @@ class FieldVisibilityUserFunction {
case 'f' :
$res = $key;
break;
case 'no+' :
$res = 'no_inherited';
break;
}
return $res;
......
......@@ -39,14 +39,6 @@
<source>never</source>
<target>niemals</target>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_inheritanceflag_original" approved="yes">
<source>Inheritance original</source>
<target>Erbe vom Orginal</target>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_inheritanceflag_overlayed" approved="yes">
<source>Inheritance overlayed</source>
<target>Erbe von der Übersetzung</target>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_visibility" approved="yes">
<source>Language visibility:</source>
<target>Sprachsichtbarkeit:</target>
......
......@@ -31,12 +31,6 @@
<trans-unit id="no">
<source>never</source>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_inheritanceflag_original">
<source>Inheritance original</source>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_inheritanceflag_overlayed">
<source>Inheritance overlayed</source>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_visibility">
<source>Language visibility:</source>
</trans-unit>
......
# cat=basic//20; type=boolean; label=Inheritance: Enable inherited settings for pages
inheritanceEnabled = 0
# cat=basic//20; type=boolean; label=Use "if translated" as default: Relevant if user creates a record without having access to the default language - if disabled "no" will be chosen
translatedAsDefaultEnabled = 0
......
......@@ -39,16 +39,6 @@ call_user_func(
// overriding option because this is done by languagevisibility and will not work if set
$GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault'] = 0;
// adding inheriatance flag to the addRootlineField
$rootlineFields = &$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'];
$newRootlineFields = 'tx_languagevisibility_inheritanceflag_original, tx_languagevisibility_inheritanceflag_overlayed';
$rootlineFields .= (empty($rootlineFields)) ? $newRootlineFields : ',' . $newRootlineFields;
// adding the inheritance flag to the pageOverlayFields
$pagesOverlayFields = &$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'];
$newPagesOverlayFields = 'tx_languagevisibility_inheritanceflag_overlayed';
$pagesOverlayFields .= (empty($pagesOverlayFields)) ? $newPagesOverlayFields : ',' . $newPagesOverlayFields;
/**
* Configure TYPO3 Caching Framework
*/
......
......@@ -11,8 +11,6 @@ CREATE TABLE sys_language (
#
CREATE TABLE pages (
tx_languagevisibility_visibility text NOT NULL,
tx_languagevisibility_inheritanceflag_original tinyint(1) DEFAULT '0' NOT NULL,
tx_languagevisibility_inheritanceflag_overlayed tinyint(1) DEFAULT '0' 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