Skip to content
Snippets Groups Projects
Commit 1a826802 authored by Hannes Lau's avatar Hannes Lau Committed by Benni Mack
Browse files

[BUGFIX] Allow to override RTE config via PageTS

Fix the merging of YAML and PageTS provided RTE configuration to allow
editor configuration via PageTS

Resolves: #81880
Releases: master, 8.7
Change-Id: Ic06627686b6ee77d79df34a6dda7b5610ccb06cb
Reviewed-on: https://review.typo3.org/53518


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarBenjamin Kluge <b.kluge@neusta.de>
Tested-by: default avatarBenjamin Kluge <b.kluge@neusta.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 63eebe0c
Branches
Tags
No related merge requests found
......@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Core\Configuration;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -72,23 +73,32 @@ class Richtext
unset($fullPageTsConfig['default.'], $fullPageTsConfig['config.']);
// RTE.* (used for RTE.classesAnchor or similar in RTEHtmlArea)
if (!empty($fullPageTsConfig)) {
ArrayUtility::mergeRecursiveWithOverrule($configuration, $fullPageTsConfig);
ArrayUtility::mergeRecursiveWithOverrule(
$configuration,
$this->cleanDotsFromEditorConfigKeys($fullPageTsConfig)
);
}
// RTE.default.*
if (is_array($defaultPageTsConfigOverrides)) {
ArrayUtility::mergeRecursiveWithOverrule($configuration, $defaultPageTsConfigOverrides);
ArrayUtility::mergeRecursiveWithOverrule(
$configuration,
$this->cleanDotsFromEditorConfigKeys($defaultPageTsConfigOverrides)
);
}
// RTE.config.tt_content.bodytext and based on type as well
if (is_array($fieldSpecificPageTsConfigOverrides)) {
$fieldSpecificPageTsConfigOverridesWithoutType = $fieldSpecificPageTsConfigOverrides;
unset($fieldSpecificPageTsConfigOverridesWithoutType['types.']);
ArrayUtility::mergeRecursiveWithOverrule($configuration, $fieldSpecificPageTsConfigOverridesWithoutType);
ArrayUtility::mergeRecursiveWithOverrule(
$configuration,
$this->cleanDotsFromEditorConfigKeys($fieldSpecificPageTsConfigOverridesWithoutType)
);
if ($recordType
&& isset($fieldSpecificPageTsConfigOverrides['types.'][$recordType . '.'])
&& is_array($fieldSpecificPageTsConfigOverrides['types.'][$recordType . '.'])) {
ArrayUtility::mergeRecursiveWithOverrule(
$configuration,
$fieldSpecificPageTsConfigOverrides['types.'][$recordType . '.']
$this->cleanDotsFromEditorConfigKeys($fieldSpecificPageTsConfigOverrides['types.'][$recordType . '.'])
);
}
}
......@@ -173,4 +183,22 @@ class Richtext
{
return $GLOBALS['BE_USER'];
}
/**
* Strip dots from the 'editor.' part of a given TypoScript array
*
* @param array $typoScriptArray TypoScriptArray (with dots) that may contain an 'editor.' subarray
* @return array array with dots stripped from the editor subarray
*/
protected function cleanDotsFromEditorConfigKeys(array $typoScriptArray): array
{
if (isset($typoScriptArray['editor.'])) {
/** @var TypoScriptService $typoScriptService */
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
$typoScriptArray['editor'] = $typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptArray['editor.']);
unset($typoScriptArray['editor.']);
}
return $typoScriptArray;
}
}
......@@ -170,6 +170,11 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'anotherConfig',
],
'editor.' => [
'config.' => [
'contentsCss' => 'my.css'
]
],
],
],
];
......@@ -177,6 +182,11 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'anotherConfig',
],
'editor' => [
'config' => [
'contentsCss' => 'my.css'
]
],
'proc.' => [
'overruleMode' => 'default',
],
......@@ -214,6 +224,11 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'aThirdConfig',
],
'editor.' => [
'config.' => [
'contentsCss' => 'my.css'
]
],
],
],
],
......@@ -223,6 +238,12 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'aThirdConfig',
],
// editor config without pagets dots
'editor' => [
'config' => [
'contentsCss' => 'my.css'
]
],
'proc.' => [
'overruleMode' => 'default',
],
......@@ -260,11 +281,21 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'aThirdConfig',
],
'editor.' => [
'config.' => [
'contentsCss' => 'my.css'
]
],
'types.' => [
'textmedia.' => [
'classes.' => [
'aClass.' => 'aTypeSpecifcConfig',
],
'editor.' => [
'config.' => [
'contentsCss' => 'your.css'
]
],
]
]
],
......@@ -276,6 +307,12 @@ class RichtextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'classes.' => [
'aClass.' => 'aTypeSpecifcConfig',
],
// editor config without pagets dots
'editor' => [
'config' => [
'contentsCss' => 'your.css'
]
],
'proc.' => [
'overruleMode' => 'default',
],
......
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