diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 485269c97307c3d0b8b296c154fb24066c4c6786..260fca1843bbc719e90ce6050d15c7c66568eb4b 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -1552,7 +1552,7 @@ class DataHandler * @param string $value Value to transform. * @param string $table The table name * @param string $field The field name - * @param array $defaultExtras Default extras configuration of this field - typically "richtext:rte_transform[mode=ts_css]" + * @param array $defaultExtras Default extras configuration of this field - typically "richtext:rte_transform" * @param array $thisConfig Configuration for RTEs; A mix between TSconfig and others. Configuration for additional transformation information * @param int $pid PID value of record (true parent page id) * @return string Transformed content @@ -1560,15 +1560,11 @@ class DataHandler protected function transformRichtextContentToDatabase($value, $table, $field, $defaultExtras, $thisConfig, $pid) { if ($defaultExtras['rte_transform']) { - $parameters = BackendUtility::getSpecConfParametersFromArray($defaultExtras['rte_transform']['parameters']); - // There must be a mode set for transformation, this is typically 'ts_css' - if ($parameters['mode']) { - // Initialize transformation: - $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); - $parseHTML->init($table . ':' . $field, $pid); - // Perform transformation: - $value = $parseHTML->RTE_transform($value, $defaultExtras, 'db', $thisConfig); - } + // Initialize transformation: + $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); + $parseHTML->init($table . ':' . $field, $pid); + // Perform transformation: + $value = $parseHTML->RTE_transform($value, $defaultExtras, 'db', $thisConfig); } return $value; } diff --git a/typo3/sysext/core/Classes/Migrations/TcaMigration.php b/typo3/sysext/core/Classes/Migrations/TcaMigration.php index 86a0b04cb05d5e989ff9c4ffcd16ad00839122bb..24016185edb6d1960c22f15357f4d0c5712b2523 100644 --- a/typo3/sysext/core/Classes/Migrations/TcaMigration.php +++ b/typo3/sysext/core/Classes/Migrations/TcaMigration.php @@ -52,6 +52,7 @@ class TcaMigration $tca = $this->migrateSelectFieldRenderType($tca); $tca = $this->migrateSelectFieldIconTable($tca); $tca = $this->migrateElementBrowserWizardToLinkHandler($tca); + $tca = $this->migrateDefaultExtrasRteTransFormOptions($tca); // @todo: if showitem/defaultExtras wizards[xy] is migrated to columnsOverrides here, enableByTypeConfig could be dropped return $tca; } @@ -643,4 +644,70 @@ class TcaMigration } return $tca; } + + /** + * Migrate defaultExtras "richtext:rte_transform[mode=ts_css]" and similar stuff like + * "richtext:rte_transform[mode=ts_css]" to "richtext:rte_transform" + * + * @param array $tca + * @return array Migrated TCA + */ + protected function migrateDefaultExtrasRteTransFormOptions(array $tca) + { + foreach ($tca as $table => &$tableDefinition) { + if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) { + continue; + } + foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) { + if (isset($fieldConfig['defaultExtras'])) { + $oldValue = $fieldConfig['defaultExtras']; + $fieldConfig['defaultExtras'] = preg_replace( + '/richtext(\[([^\]]*)\])*:rte_transform(\[([^\]]*)\])/', + 'richtext${1}:rte_transform', + $fieldConfig['defaultExtras'], + -1, + $replacementCount + ); + if ($replacementCount) { + $this->messages[] = 'rte_transform options are deprecated. String "' . $oldValue . '" in TCA' + . ' ' . $table . '[\'columns\'][\'' . $fieldName . '\'][\'defaultExtras\'] was changed to "' + . $fieldConfig['defaultExtras'] . '"'; + } + } + } + } + + foreach ($tca as $table => &$tableDefinition) { + if (!isset($tableDefinition['types']) || !is_array($tableDefinition['types'])) { + continue; + } + foreach ($tableDefinition['types'] as $typeName => &$typeArray) { + if (!isset($typeArray['columnsOverrides']) || !is_array($typeArray['columnsOverrides'])) { + continue; + } + foreach ($typeArray['columnsOverrides'] as $fieldName => &$fieldConfig) { + if (isset($fieldConfig['defaultExtras'])) { + $oldValue = $fieldConfig['defaultExtras']; + $fieldConfig['defaultExtras'] = preg_replace( + '/richtext(\[([^\]]*)\])*:rte_transform(\[([^\]]*)\])/', + 'richtext${1}:rte_transform', + $fieldConfig['defaultExtras'], + -1, + $replacementCount + ); + if ($replacementCount) { + $this->messages[] = 'rte_transform options are deprecated. String "' + . $oldValue . '" in TCA' + . ' ' . $table . '[\'types\'][\'' . $typeName + . '\'][\'columnsOverrides\'][\'' . $fieldName + . '\'][\'defaultExtras\']' . + ' was changed to "' . $fieldConfig['defaultExtras'] . '"'; + } + } + } + } + } + + return $tca; + } } diff --git a/typo3/sysext/core/Configuration/TCA/sys_news.php b/typo3/sysext/core/Configuration/TCA/sys_news.php index 6fa930f48164d2fc30a066c4f3c933da6afeb548..23a55f8b9f4152f4328144f6baafe41c2af03823 100644 --- a/typo3/sysext/core/Configuration/TCA/sys_news.php +++ b/typo3/sysext/core/Configuration/TCA/sys_news.php @@ -79,7 +79,7 @@ return array( ) ) ), - 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]', + 'defaultExtras' => 'richtext:rte_transform', ) ), 'types' => array( diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-72856-RemovedRTEModesOption.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-72856-RemovedRTEModesOption.rst new file mode 100644 index 0000000000000000000000000000000000000000..e059febfdc695532a5b678ad2b047f3b4bdcffee --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-72856-RemovedRTEModesOption.rst @@ -0,0 +1,22 @@ +================================================ +Deprecation: #72856 - Removed RTE "modes" option +================================================ + +Description +=========== + +The RTE "modes" option that was added to a RTE enabled TCA field in the "defaultExtras" section was removed. + +The RTE is now loaded via the configuration from TSconfig, usually set by the "modes" or the "overruleMode" (used by default), and loaded even without the RTE mode set in the TCA field defaultExtras section. + + +Impact +====== + +Extension authors do not need to set the defaultExtras "mode=ts_css" parameter explicitly. + + +Migration +========= + +When configuring a RTE field in a TYPO3 extension the defaultExtras part should bet set to ``richtext:rte_transform`` instead of ``richtext:rte_transform[mode=ts_css]`` in order to render the RTE. \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php b/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php index 2d97eb3b203ce7927c5b207fe4d5a83c3a429623..f3fab06664ab1b80bc69d2210218d62f85f1184b 100644 --- a/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php +++ b/typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php @@ -1025,4 +1025,362 @@ class TcaMigrationTest extends UnitTestCase $subject = new TcaMigration(); $this->assertEquals($expected, $subject->migrate($input)); } + + /** + * @return array + */ + public function migrateRemovesRteTransformOptionsDataProvider() + { + return [ + 'remove empty options in columns' => [ + [ + // Given config section + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[]' + ] + ] + ] + ], + [ + // Expected config section + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ], + ], + 'remove nothing in columns' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ], + ], + 'remove mode in columns' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ], + ], + 'remove flag and mode in columns' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ], + ], + 'remove flag and mode in columns with array notation' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[]:rte_transform' + ] + ] + ] + ], + ], + 'remove flag and mode in columns with array notation and index' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[*]:rte_transform' + ] + ] + ] + ], + ], + 'remove flag and mode in columns with array notation and index and option list' => [ + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[cut|copy|paste]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ], + [ + 'aTable' => [ + 'columns' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[cut|copy|paste]:rte_transform' + ] + ] + ] + ], + ], + 'remove empty options in columnsOverrides' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove nothing in columnsOverrides' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove mode in columnsOverrides' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove flag and mode in columnsOverrides' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove flag and mode in columnsOverrides with array notation' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[]:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove flag and mode in columnsOverrides with array notation and index' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[*]:rte_transform' + ] + ] + ] + ] + ] + ], + ], + 'remove flag and mode in columnsOverrides with array notation and index and option list' => [ + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[copy|cut|paste]:rte_transform[flag=rte_enabled|mode=ts_css]' + ] + ] + ] + ] + ] + ], + [ + 'aTable' => [ + 'types' => [ + 'aType' => [ + 'columnsOverrides' => [ + 'aField' => [ + 'defaultExtras' => 'richtext[copy|cut|paste]:rte_transform' + ] + ] + ] + ] + ] + ], + ], + ]; + } + + /** + * @test + * @dataProvider migrateRemovesRteTransformOptionsDataProvider + * @param array $givenConfig + * @param array $expectedConfig + */ + public function migrateRemovesRteTransformOptions(array $givenConfig, array $expectedConfig) { + $subject = new TcaMigration(); + $this->assertEquals($expectedConfig, $subject->migrate($givenConfig)); + } } diff --git a/typo3/sysext/css_styled_content/Configuration/TCA/Overrides/tt_content.php b/typo3/sysext/css_styled_content/Configuration/TCA/Overrides/tt_content.php index 2e2f01f7bd8796b81bd1d9e34a1f73a78b7f0087..692a402c735c3080efb7905af1c3436ee4d7e432 100644 --- a/typo3/sysext/css_styled_content/Configuration/TCA/Overrides/tt_content.php +++ b/typo3/sysext/css_styled_content/Configuration/TCA/Overrides/tt_content.php @@ -502,7 +502,7 @@ $baseDefaultExtrasOfBodytext = ''; if (!empty($GLOBALS['TCA']['tt_content']['columns']['bodytext']['defaultExtras'])) { $baseDefaultExtrasOfBodytext = $GLOBALS['TCA']['tt_content']['columns']['bodytext']['defaultExtras'] . ':'; } -$GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform[mode=ts_css]'; +$GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform'; // Field arrangement for CE "textpic" $GLOBALS['TCA']['tt_content']['types']['textpic']['showitem'] = ' @@ -527,7 +527,7 @@ if (!is_array($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverride if (!is_array($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext'])) { $GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext'] = array(); } -$GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform[mode=ts_css]'; +$GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform'; // Field arrangement for CE "image" $GLOBALS['TCA']['tt_content']['types']['image']['showitem'] = ' diff --git a/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php b/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php index c26f059030c94cb8c5efc0cbea5e5b59cddea2c0..b075653124f234795e0e1878e603d13950a13a64 100644 --- a/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php +++ b/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php @@ -52,7 +52,7 @@ call_user_func(function () { --palette--;' . $frontendLanguageFilePrefix . 'palette.access;access, --div--;' . $frontendLanguageFilePrefix . 'tabs.extended ', - 'columnsOverrides' => ['bodytext' => ['defaultExtras' => 'richtext:rte_transform[mode=ts_css]']] + 'columnsOverrides' => ['bodytext' => ['defaultExtras' => 'richtext:rte_transform']] ]; // Add category tab when categories column exits diff --git a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php index 28ae79909105260dd132caee0831275337e5b478..c58ada8977116967a2f00a6882bd02fc6cdd8c41 100644 --- a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php +++ b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php @@ -1296,14 +1296,10 @@ class RichTextElement extends AbstractFormElement $value = preg_replace('/<(\\/?)em([^b>]*>)/i', '<$1i$2', $value); if ($this->defaultExtras['rte_transform']) { - $parameters = BackendUtility::getSpecConfParametersFromArray($this->defaultExtras['rte_transform']['parameters']); - // There must be a mode set for transformation - if ($parameters['mode']) { - /** @var RteHtmlParser $parseHTML */ - $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); - $parseHTML->init($this->data['table'] . ':' . $this->data['fieldName'], $this->pidOfVersionedMotherRecord); - $value = $parseHTML->RTE_transform($value, $this->defaultExtras, 'rte', $this->processedRteConfiguration); - } + /** @var RteHtmlParser $parseHTML */ + $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class); + $parseHTML->init($this->data['table'] . ':' . $this->data['fieldName'], $this->pidOfVersionedMotherRecord); + $value = $parseHTML->RTE_transform($value, $this->defaultExtras, 'rte', $this->processedRteConfiguration); } return $value; }