[!!!][TASK] Prepare richtext configuration 11/51311/11
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 13 Jan 2017 16:55:56 +0000 (17:55 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 17 Jan 2017 08:48:05 +0000 (09:48 +0100)
Configuring a richtext field in TCA with the "defaultExtras"
setting (which was formerly the 5th showitem parameter) has
been ugly ever since: The DataHandler needed a special _TRANSFORM_
field to trigger required RTE transformations, further config
depends on pageTs settings.

The patch gets rid of "defaultExtras" for richtext elements and
adds a new option "enableRichtext=true" within the config section
for type=text TCA fields.
This setting can be set via "columnsOverrides" for specific types, too.

As an intermediate solution, the configuration class "Richtext" is
added to fetch richtext configuration. This will be extended with
another patch to provide ckeditor configuration on TCA level.

Change-Id: I70f4cb26e2a45629b99680e532d376538afd2b90
Resolves: #79341
Releases: master
Reviewed-on: https://review.typo3.org/51311
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
29 files changed:
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaText.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaTextTest.php [new file with mode: 0644]
typo3/sysext/core/Classes/Configuration/Richtext.php [new file with mode: 0644]
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Configuration/TCA/sys_news.php
typo3/sysext/core/Documentation/Changelog/8.0/Breaking-72783-RemovedRTETransformationOptionPreserveTables.rst
typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-MethodsRelatedToRichtextConfiguration.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-TCARichtextConfigurationInDefaultExtrasDropped.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Feature-79341-TCARichtextConfigurationInConfigSection.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Configuration/RichtextTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
typo3/sysext/css_styled_content/Configuration/TCA/Overrides/tt_content.php
typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php
typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php
typo3/sysext/rte_ckeditor/Classes/Form/Resolver/RichTextNodeResolver.php
typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
typo3/sysext/rtehtmlarea/Classes/Controller/ParseHtmlController.php
typo3/sysext/rtehtmlarea/Classes/Controller/SelectImageController.php
typo3/sysext/rtehtmlarea/Classes/Controller/UserElementsController.php
typo3/sysext/rtehtmlarea/Classes/Extension/SelectFont.php
typo3/sysext/rtehtmlarea/Classes/Extension/Typo3Link.php
typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
typo3/sysext/rtehtmlarea/Classes/Form/Resolver/RichTextNodeResolver.php
typo3/sysext/rtehtmlarea/Classes/ImageHandler/EditImageHandler.php

diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaText.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaText.php
new file mode 100644 (file)
index 0000000..7f5e908
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Backend\Form\FormDataProvider;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
+use TYPO3\CMS\Core\Configuration\Richtext;
+use TYPO3\CMS\Core\Html\RteHtmlParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Resolve databaseRow field content for type=text, especially handle
+ * richtext transformations "from db to rte"
+ */
+class TcaText implements FormDataProviderInterface
+{
+    /**
+     * Handle text field content, especially richtext transformation
+     *
+     * @param array $result Given result array
+     * @return array Modified result array
+     */
+    public function addData(array $result)
+    {
+        foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
+            if (empty($fieldConfig['config']['type']) || $fieldConfig['config']['type'] !== 'text') {
+                continue;
+            }
+
+            if (isset($fieldConfig['config']['enableRichtext']) && $fieldConfig['config']['enableRichtext'] === true) {
+                $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+                $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+                    $result['tableName'],
+                    $fieldName,
+                    $result['effectivePid'],
+                    (string)$result['recordTypeValue'],
+                    $fieldConfig['config']
+                );
+                // Add final resolved configuration to TCA array
+                $result['processedTca']['columns'][$fieldName]['config']['richtextConfiguration'] = $richtextConfiguration;
+
+                // If eval=null is set for field, value might be null ... don't transform anything in this case.
+                if ($result['databaseRow'][$fieldName] !== null) {
+                    // Process "from-db-to-rte" on current value
+                    $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class);
+                    $parseHTML->init($result['tableName'] . ':' . $fieldName, $result['effectivePid']);
+                    $result['databaseRow'][$fieldName] = $parseHTML->RTE_transform(
+                        $result['databaseRow'][$fieldName],
+                        [],
+                        'rte',
+                        $richtextConfiguration
+                    );
+                }
+            }
+        }
+
+        return $result;
+    }
+}
index 15e1216..4682295 100644 (file)
@@ -910,9 +910,11 @@ class BackendUtility
      *
      * @param array $pArr Array of "[key] = [value]" strings to convert.
      * @return array
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
      */
     public static function getSpecConfParametersFromArray($pArr)
     {
+        GeneralUtility::logDeprecatedFunction();
         $out = [];
         if (is_array($pArr)) {
             foreach ($pArr as $k => $v) {
@@ -4059,9 +4061,11 @@ class BackendUtility
      * @param string $type Type value of the current record (like from CType of tt_content)
      * @return array Array with the configuration for the RTE
      * @internal
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9.
      */
     public static function RTEsetup($RTEprop, $table, $field, $type = '')
     {
+        GeneralUtility::logDeprecatedFunction();
         $thisConfig = is_array($RTEprop['default.']) ? $RTEprop['default.'] : [];
         $thisFieldConf = $RTEprop['config.'][$table . '.'][$field . '.'];
         if (is_array($thisFieldConf)) {
diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaTextTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaTextTest.php
new file mode 100644 (file)
index 0000000..342d6fd
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\FormDataProvider\TcaText;
+use TYPO3\CMS\Core\Configuration\Richtext;
+use TYPO3\CMS\Core\Html\RteHtmlParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Test case
+ */
+class TcaTextTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function addDataSetsRichtextConfigurationAndTransformsContent()
+    {
+        $input = [
+            'tableName' => 'aTable',
+            'effectivePid' => 42,
+            'recordTypeValue' => 23,
+            'databaseRow' => [
+                'aField' => 'notProcessedContent',
+            ],
+            'processedTca' => [
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'text',
+                            'enableRichtext' => true,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+        $expected = [
+            'tableName' => 'aTable',
+            'effectivePid' => 42,
+            'recordTypeValue' => 23,
+            'databaseRow' => [
+                'aField' => 'processedContent',
+            ],
+            'processedTca' => [
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'text',
+                            'enableRichtext' => true,
+                            'richtextConfiguration' => [
+                                'aConfig' => 'option',
+                            ],
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $richtextConfigurationProphecy = $this->prophesize(Richtext::class);
+        GeneralUtility::addInstance(Richtext::class, $richtextConfigurationProphecy->reveal());
+        $rteHtmlParserPropehy = $this->prophesize(RteHtmlParser::class);
+        GeneralUtility::addInstance(RteHtmlParser::class, $rteHtmlParserPropehy->reveal());
+
+        $richtextConfigurationProphecy
+            ->getConfiguration(
+                'aTable',
+                'aField',
+                42,
+                23,
+                [
+                    'type' => 'text',
+                    'enableRichtext' => true,
+                ]
+            )
+            ->willReturn([ 'aConfig' => 'option' ]);
+        $rteHtmlParserPropehy->init('aTable:aField', 42)->shouldBeCalled();
+        $rteHtmlParserPropehy
+            ->RTE_transform(
+                'notProcessedContent',
+                [],
+                'rte',
+                [ 'aConfig' => 'option']
+            )
+            ->willReturn('processedContent');
+
+        $this->assertSame($expected, (new TcaText())->addData($input));
+    }
+}
diff --git a/typo3/sysext/core/Classes/Configuration/Richtext.php b/typo3/sysext/core/Classes/Configuration/Richtext.php
new file mode 100644 (file)
index 0000000..a120b24
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Core\Configuration;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
+/**
+ * Prepare richtext configuration. Used in DataHandler and FormEngine
+ *
+ * @internal Internal class for the time being - may change / vanish any time
+ * @todo When I grow up, I want to become a data provider
+ */
+class Richtext
+{
+    /**
+     * This is an intermediate class / method to retrieve RTE
+     * configuration until all core places use data providers to do that.
+     *
+     * @param string $table The table the field is in
+     * @param string $field Field name
+     * @param int $pid Real page id
+     * @param string $recordType Record type value
+     * @param array $tcaFieldConf ['config'] section of TCA field
+     * @return array
+     */
+    public function getConfiguration(string $table, string $field, int $pid, string $recordType, array $tcaFieldConf): array
+    {
+        // if (isset($tcaFieldConf['richtextConfiguration'])) {
+            // @todo with yaml parser
+            // create instance of NodeFactory, ask for "text" element
+            //
+            // If text element is instanceof "old" rtehtmlarea, do nothing, or if rtehtml should support ,yml, too
+            // unpack extConf settings, see if "demo", "normal" or whatever is configured, let rtehtmlarea register
+            // these three as possible configuration options in typo3_conf_vars, then yaml parse config. if "richtextConfiguration"
+            // is already set for rtehtmlarea and is "default" then fetch the config that is selected in extConf, else pick
+            // configured one.
+            //
+            // If text element is instanceof "new" ckeditor, and richtextConfiguration is not set, the "default", else
+            // look up in typo3_conf_vars.
+            //
+            // As soon an the Data handler starts using FormDataProviders, this class can vanish again, and the hack to
+            // test for specific rich text instances can be dropped: Split the "TcaText" data provider into multiple parts, each
+            // RTE should register and own data provider that does the transformation / configuration providing. This way,
+            // the explicit check for different RTE classes is removed from core and "hooked in" by the RTE's.
+        // }
+
+        $rtePageTs = $this->getRtePageTsConfigOfPid($pid);
+        $configuration = $rtePageTs['properties'];
+        unset($configuration['default.']);
+        unset($configuration['config.']);
+        if (is_array($rtePageTs['properties']['default.'])) {
+            ArrayUtility::mergeRecursiveWithOverrule($configuration, $rtePageTs['properties']['default.']);
+        }
+        $rtePageTsField = $rtePageTs['properties']['config.'][$table . '.'][$field . '.'];
+        if (is_array($rtePageTsField)) {
+            unset($rtePageTsField['types.']);
+            ArrayUtility::mergeRecursiveWithOverrule($configuration, $rtePageTsField);
+        }
+        if ($recordType && is_array($rtePageTs['properties']['config.'][$table . '.'][$field . '.']['types.'][$recordType . '.'])) {
+            ArrayUtility::mergeRecursiveWithOverrule(
+                $configuration,
+                $rtePageTs['properties']['config.'][$table . '.'][$field . '.']['types.'][$recordType . '.']
+            );
+        }
+
+        // Handle "mode" / "transformation" config for RteHtmlParser
+        if (!isset($configuration['proc.']['overruleMode'])) {
+            // Fall back to 'default' transformations
+            $configuration['proc.']['overruleMode'] = 'default';
+        }
+        if ($configuration['proc.']['overruleMode'] === 'ts_css') {
+            // Change legacy 'ts_css' to 'default'
+            $configuration['proc.']['overruleMode'] = 'default';
+        }
+
+        return $configuration;
+    }
+
+    /**
+     * Return RTE section of page TS
+     *
+     * @param int $pid Page ts of given pid
+     * @return array RTE section of pageTs of given pid
+     */
+    protected function getRtePageTsConfigOfPid(int $pid): array
+    {
+        // Override with pageTs if needed
+        $backendUser = $this->getBackendUser();
+        return $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($pid));
+    }
+
+    /**
+     * @return BackendUserAuthentication
+     */
+    protected function getBackendUser() : BackendUserAuthentication
+    {
+        return $GLOBALS['BE_USER'];
+    }
+}
index 0608b50..68da2db 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
+use TYPO3\CMS\Core\Configuration\Richtext;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@@ -1520,56 +1521,10 @@ class DataHandler
             // If the field is set it would probably be because of an undo-operation - in which case we should not update the field of course...
             $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
         }
-        // Checking for RTE-transformations of fields:
-        $types_fieldConfig = BackendUtility::getTCAtypes($table, $this->checkValue_currentRecord);
-        $theTypeString = null;
-        if (is_array($types_fieldConfig)) {
-            foreach ($types_fieldConfig as $vconf) {
-                // RTE transformations:
-                if ($this->dontProcessTransformations || !isset($fieldArray[$vconf['field']])) {
-                    continue;
-                }
-
-                // Look for transformation flag:
-                if ((string)$incomingFieldArray['_TRANSFORM_' . $vconf['field']] === 'RTE') {
-                    if ($theTypeString === null) {
-                        $theTypeString = BackendUtility::getTCAtypeValue($table, $this->checkValue_currentRecord);
-                    }
-                    $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
-                    $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
-                    $fieldArray[$vconf['field']] = $this->transformRichtextContentToDatabase(
-                        $fieldArray[$vconf['field']], $table, $vconf['field'], $vconf['spec'], $thisConfig, $this->checkValue_currentRecord['pid']
-                    );
-                }
-            }
-        }
         // Return fieldArray
         return $fieldArray;
     }
 
-    /**
-     * Performs transformation of content from richtext element to database.
-     *
-     * @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"
-     * @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
-     */
-    protected function transformRichtextContentToDatabase($value, $table, $field, $defaultExtras, $thisConfig, $pid)
-    {
-        if ($defaultExtras['rte_transform']) {
-            // Initialize transformation:
-            $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class);
-            $parseHTML->init($table . ':' . $field, $pid);
-            // Perform transformation:
-            $value = $parseHTML->RTE_transform($value, $defaultExtras, 'db', $thisConfig);
-        }
-        return $value;
-    }
-
     /*********************************************
      *
      * Evaluation of input values
@@ -1677,7 +1632,7 @@ class DataHandler
 
         switch ($tcaFieldConf['type']) {
             case 'text':
-                $res = $this->checkValueForText($value, $tcaFieldConf);
+                $res = $this->checkValueForText($value, $tcaFieldConf, $table, $id, $realPid, $field);
                 break;
             case 'passthrough':
             case 'imageManipulation':
@@ -1717,21 +1672,45 @@ class DataHandler
      *
      * @param string $value The value to set.
      * @param array $tcaFieldConf Field configuration from TCA
+     * @param string $table Table name
+     * @param int $id UID of record
+     * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
+     * @param string $field Field name
      * @return array $res The result array. The processed value (if any!) is set in the "value" key.
      */
-    protected function checkValueForText($value, $tcaFieldConf)
+    protected function checkValueForText($value, $tcaFieldConf, $table, $id, $realPid, $field)
     {
-        if (!isset($tcaFieldConf['eval']) || $tcaFieldConf['eval'] === '') {
-            return ['value' => $value];
-        }
-        $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
-        if ($this->runtimeCache->has($cacheId)) {
-            $evalCodesArray = $this->runtimeCache->get($cacheId);
+        if (isset($tcaFieldConf['eval']) && !$tcaFieldConf['eval'] === '') {
+            $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
+            if ($this->runtimeCache->has($cacheId)) {
+                $evalCodesArray = $this->runtimeCache->get($cacheId);
+            } else {
+                $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
+                $this->runtimeCache->set($cacheId, $evalCodesArray);
+            }
+            $valueArray = $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
         } else {
-            $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
-            $this->runtimeCache->set($cacheId, $evalCodesArray);
+            $valueArray = ['value' => $value];
+        }
+
+        // Handle richtext transformations
+        if ($this->dontProcessTransformations) {
+            return $valueArray;
+        }
+        $recordType = BackendUtility::getTCAtypeValue($table, $this->checkValue_currentRecord);
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? null;
+        if ($columnsOverridesConfigOfField) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaFieldConf, $columnsOverridesConfigOfField);
+        }
+        if (isset($tcaFieldConf['enableRichtext']) && $tcaFieldConf['enableRichtext'] === true) {
+            $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+            $richtextConfiguration = $richtextConfigurationProvider->getConfiguration($table, $field, $realPid, $recordType, $tcaFieldConf);
+            $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class);
+            $parseHTML->init($table . ':' . $field, $realPid);
+            $valueArray['value'] = $parseHTML->RTE_transform($value, [], 'db', $richtextConfiguration);
         }
-        return $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
+
+        return $valueArray;
     }
 
     /**
@@ -3019,23 +2998,6 @@ class DataHandler
                         ];
 
                         $res = $this->checkValue_SW([], $dataValues[$key][$vKey], $dsConf['TCEforms']['config'], $CVtable, $CVid, $dataValues_current[$key][$vKey], $CVstatus, $CVrealPid, $CVrecFID, '', $uploadedFiles[$key][$vKey], $CVtscPID, $additionalData);
-                        // Look for RTE transformation of field:
-                        if ($dataValues[$key]['_TRANSFORM_' . $vKey] == 'RTE' && !$this->dontProcessTransformations) {
-                            // Unsetting trigger field - we absolutely don't want that into the data storage!
-                            unset($dataValues[$key]['_TRANSFORM_' . $vKey]);
-                            if (isset($res['value'])) {
-                                // Calculating/Retrieving some values here:
-                                list(, , $recFieldName) = explode(':', $CVrecFID);
-                                $theTypeString = BackendUtility::getTCAtypeValue($CVtable, $this->checkValue_currentRecord);
-                                $specConf = BackendUtility::getSpecConfParts($dsConf['TCEforms']['defaultExtras']);
-                                // Find, thisConfig:
-                                $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($CVtscPID));
-                                $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $CVtable, $recFieldName, $theTypeString);
-                                $res['value'] = $this->transformRichtextContentToDatabase(
-                                    $res['value'], $CVtable, $recFieldName, $specConf, $thisConfig, $CVrealPid
-                                );
-                            }
-                        }
                     }
                     // Adding the value:
                     if (isset($res['value'])) {
index 9f35aa9..d715cee 100644 (file)
@@ -154,12 +154,12 @@ class RteHtmlParser extends HtmlParser
      * This is the main function called from DataHandler and transfer data classes
      *
      * @param string $value Input value
-     * @param array $specConf Special configuration for a field; This is coming from the types-configuration of the field in the TCA. In the types-configuration you can setup features for the field rendering and in particular the RTE takes al its major configuration options from there!
+     * @param array $specConf deprecated old "defaultExtras" parsed as array
      * @param string $direction Direction of the transformation. Two keywords are allowed; "db" or "rte". If "db" it means the transformation will clean up content coming from the Rich Text Editor and goes into the database. The other direction, "rte", is of course when content is coming from database and must be transformed to fit the RTE.
      * @param array $thisConfig Parsed TypoScript content configuring the RTE, probably coming from Page TSconfig.
      * @return string Output value
      */
-    public function RTE_transform($value, $specConf, $direction = 'rte', $thisConfig = [])
+    public function RTE_transform($value, $specConf = [], $direction = 'rte', $thisConfig = [])
     {
         $this->tsConfig = $thisConfig;
         $this->procOptions = (array)$thisConfig['proc.'];
@@ -184,6 +184,10 @@ class RteHtmlParser extends HtmlParser
             $modes = GeneralUtility::trimExplode(',', $this->procOptions['overruleMode']);
         } else {
             // Get parameters for rte_transformation:
+            // @deprecated since TYPO3 v8, will be removed in TYPO3 v9 - the else{} part can be removed in v9
+            GeneralUtility::deprecationLog(
+                'Argument 2 of RteHtmlParser::RTE_transform() is deprecated. Transformations should be given in $thisConfig[\'proc.\'][\'overruleMode\']'
+            );
             $specialFieldConfiguration = BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
             $modes = GeneralUtility::trimExplode('-', $specialFieldConfiguration['mode']);
         }
@@ -274,7 +278,10 @@ class RteHtmlParser extends HtmlParser
     {
         $modeList = implode(',', $modes);
 
+        // Replace the shortcut "default" with all custom modes
+        $modeList = str_replace('default', 'detectbrokenlinks,css_transform,ts_images,ts_links', $modeList);
         // Replace the shortcut "ts_css" with all custom modes
+        // @deprecated since TYPO3 v8, will be removed in TYPO3 v9 - NEXT line can be removed in v9
         $modeList = str_replace('ts_css', 'detectbrokenlinks,css_transform,ts_images,ts_links', $modeList);
 
         // Make list unique
index 7307c3f..172606c 100644 (file)
@@ -685,18 +685,21 @@ class TcaMigration
             }
             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'] . '"';
+                    $originalValue = $fieldConfig['defaultExtras'];
+                    $defaultExtrasArray = GeneralUtility::trimExplode(':', $originalValue, true);
+                    $isRichtextField = false;
+                    foreach ($defaultExtrasArray as $defaultExtrasField) {
+                        if (substr($defaultExtrasField, 0, 8) === 'richtext') {
+                            $isRichtextField = true;
+                            $fieldConfig['config']['enableRichtext'] = true;
+                            $fieldConfig['config']['richtextConfiguration'] = 'default';
+                        }
+                    }
+                    if ($isRichtextField) {
+                        unset($fieldConfig['defaultExtras']);
+                        $this->messages[] = 'rte configuration via \'defaultExtras\' options are deprecated. String "' . $originalValue . '" in TCA'
+                            . ' ' . $table . '[\'columns\'][\'' . $fieldName . '\'][\'defaultExtras\'] was changed to'
+                            . ' options in [\'config\']';
                     }
                 }
             }
@@ -712,21 +715,24 @@ class TcaMigration
                 }
                 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'
+                        $originalValue = $fieldConfig['defaultExtras'];
+                        $defaultExtrasArray = GeneralUtility::trimExplode(':', $originalValue, true);
+                        $isRichtextField = false;
+                        foreach ($defaultExtrasArray as $defaultExtrasField) {
+                            if (substr($defaultExtrasField, 0, 8) === 'richtext') {
+                                $isRichtextField = true;
+                                $fieldConfig['config']['enableRichtext'] = true;
+                                $fieldConfig['config']['richtextConfiguration'] = 'default';
+                            }
+                        }
+                        if ($isRichtextField) {
+                            unset($fieldConfig['defaultExtras']);
+                            $this->messages[] = 'rte configuration via \'defaultExtras\' options are deprecated.. String "'
+                                . $originalValue . '" in TCA'
                                 . ' ' . $table . '[\'types\'][\'' . $typeName
                                 . '\'][\'columnsOverrides\'][\'' . $fieldName
                                 . '\'][\'defaultExtras\']' .
-                                ' was changed to "' . $fieldConfig['defaultExtras'] . '"';
+                                ' was changed to config options.';
                         }
                     }
                 }
index 7eb8664..e8e0c54 100644 (file)
@@ -483,12 +483,18 @@ return [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare::class,
                         ],
                     ],
-                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaRadioItems::class => [
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaText::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess::class,
                         ],
                     ],
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaRadioItems::class => [
+                        'depends' => [
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\TcaText::class,
+                        ],
+                    ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\TcaCheckboxItems::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
@@ -555,6 +561,11 @@ return [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldLabels::class,
                         ],
                     ],
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaText::class => [
+                        'depends' => [
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class,
+                        ],
+                    ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\TcaRadioItems::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class,
@@ -625,11 +636,16 @@ return [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordTypeValue::class,
                         ],
                     ],
-                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaRadioItems::class => [
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaText::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsRemoveUnused::class,
                         ],
                     ],
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaRadioItems::class => [
+                        'depends' => [
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\TcaText::class
+                        ],
+                    ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\TcaCheckboxItems::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsRemoveUnused::class,
index 4eab1e7..c7deb97 100644 (file)
@@ -66,6 +66,8 @@ return [
                 'type' => 'text',
                 'cols' => 48,
                 'rows' => 5,
+                'enableRichtext' => true,
+                'richtextConfiguration' => 'default',
                 'wizards' => [
                     'RTE' => [
                         'notNewRecords' => true,
@@ -79,7 +81,6 @@ return [
                     ]
                 ]
             ],
-            'defaultExtras' => 'richtext:rte_transform',
         ]
     ],
     'types' => [
index ddb870f..cca909a 100644 (file)
@@ -20,7 +20,8 @@ without substitution.
 Impact
 ======
 
-When the RTE is configured to use `overruleMode = ts` instead of the default "ts_css" the option `RTE.default.proc.preserveTables = 1` will have no effect anymore.
+When the RTE is configured to use `overruleMode = ts` instead of the default "ts_css" the
+option `RTE.default.proc.preserveTables = 1` will have no effect anymore.
 
 Calling `RteHtmlParser->removeTables` or `HtmlParser->getAllParts` inside a custom extension will result in a fatal PHP error.
 
@@ -28,7 +29,8 @@ Calling `RteHtmlParser->removeTables` or `HtmlParser->getAllParts` inside a cust
 Affected Installations
 ======================
 
-Any TYPO3 instance with a legacy-mode (overruleMode = ts) from TYPO3 3.x or an extension doing custom transformations by using `RteHtmlParser->removeTables`.
+Any TYPO3 instance with a legacy-mode (overruleMode = ts) from TYPO3 3.x or an extension doing custom transformations
+by using `RteHtmlParser->removeTables`.
 
 
 Migration
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-MethodsRelatedToRichtextConfiguration.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-MethodsRelatedToRichtextConfiguration.rst
new file mode 100644 (file)
index 0000000..24f4550
--- /dev/null
@@ -0,0 +1,37 @@
+.. include:: ../../Includes.txt
+
+===============================================================
+Deprecation: #79341 - Methods related to richtext configuration
+===============================================================
+
+See :issue:`79341`
+
+Description
+===========
+
+The following methods and method arguments have been deprecated:
+
+* Method :php:`\TYPO3\CMS\Backend\UtilityBackendUtility::getSpecConfParametersFromArray()`
+* Method :php:`\TYPO3\CMS\Backend\UtilityBackendUtility::RTEsetup()`
+* Second argument :php:`$specConf` of :php:`\TYPO3\CMS\Core\Html\RteHtmlParser->RTE_transform()`
+
+
+Impact
+======
+
+Using above methods or arguments throws deprecation log entries, the according methods will vanish with TYPO3 v9.
+
+
+Affected Installations
+======================
+
+Loaded extensions using one of the above methods.
+
+
+Migration
+=========
+
+If not otherwise possible, class :php:`\TYPO3\CMS\Core\Configuration\Richtext` can be used to fetch richtext configuration.
+Be aware this class is marked @internal and is likely to change or vanish in TYPO3 v9 again.
+
+.. index:: Backend, RTE
\ No newline at end of file
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-TCARichtextConfigurationInDefaultExtrasDropped.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-79341-TCARichtextConfigurationInDefaultExtrasDropped.rst
new file mode 100644 (file)
index 0000000..1ee6ca1
--- /dev/null
@@ -0,0 +1,102 @@
+.. include:: ../../Includes.txt
+
+=========================================================================
+Deprecation: #79341 - TCA richtext configuration in defaultExtras dropped
+=========================================================================
+
+See :issue:`79341`
+
+Description
+===========
+
+Enabling richtext rendering for fields in the Backend record editor has been simplified.
+
+In the past, a typical :php:`TCA` configuration of a richtext field looked like:
+
+.. code-block:: php
+    'columns' => [
+        'content' => [
+            'config' => [
+                'type' => 'text',
+            ],
+            'defaultExtras' => 'richtext:rte_transform',
+        ],
+    ];
+
+The :php:`defaultExtras` is obsolete and substituted with :php:`enableRichtext` within the :php:`config` section:
+
+.. code-block:: php
+    'columns' => [
+        'content' => [
+            'config' => [
+                'type' => 'text',
+                'enableRichtext' => true,
+            ],
+        ],
+    ];
+
+
+If the RTE was enabled for a specific type only, it looked like this:
+
+.. code-block:: php
+    'columns' => [
+        'content' => [
+            'config' => [
+                'type' => 'text',
+            ],
+        ],
+    ],
+    'types' => [
+        'myType' => [
+            'columnsOverrides' => [
+                'aField' => [
+                    'defaultExtras' => 'richtext:rte_transform',
+                ],
+            ],
+        ],
+    ],
+
+This is now:
+
+.. code-block:: php
+
+    'columns' => [
+        'content' => [
+            'config' => [
+                'type' => 'text',
+            ],
+        ],
+    ],
+    'types' => [
+        'myType' => [
+            'columnsOverrides' => [
+                'aField' => [
+                    'config' => [
+                        'enableRichtext' => true,
+                    ],
+                ],
+            ],
+        ],
+    ],
+
+
+Impact
+======
+
+Using defaultExtras to enable richtext editor will stop working in TYPO3 v9. An automatic :php:`TCA` migration
+transfers to the new syntax in TYPO3 v8 and logs deprecations.
+
+
+Affected Installations
+======================
+
+All installations using :php:`defaultExtras` for richtext configuration.
+
+
+Migration
+=========
+
+Remove the defaultExtras line and set :php:`'enableRichtext' => true,` within the config section of the field.
+This is allowed in :php:`columnsOverrides` for specific record types, too.
+
+.. index:: Backend, FlexForm, RTE, TCA
\ No newline at end of file
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-79341-TCARichtextConfigurationInConfigSection.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-79341-TCARichtextConfigurationInConfigSection.rst
new file mode 100644 (file)
index 0000000..7655192
--- /dev/null
@@ -0,0 +1,30 @@
+.. include:: ../../Includes.txt
+
+==============================================================
+Feature: #79341 - TCA richtext configuration in config section
+==============================================================
+
+See :issue:`79341`
+
+Description
+===========
+
+A new config item "enableRichtext" has been introduced. It enables richtext editing on the text field and replaces the old setting under "defaultExtras".
+
+
+Impact
+======
+
+Setting enableRichtext will result in the text field being rendered with a richtext editor. Config example:
+
+.. code-block:: php
+    'columns' => [
+        'content' => [
+            'config' => [
+                'type' => 'text',
+                'enableRichtext' => true,
+            ],
+        ],
+    ];
+
+.. index:: Backend, FlexForm, RTE, TCA
diff --git a/typo3/sysext/core/Tests/Unit/Configuration/RichtextTest.php b/typo3/sysext/core/Tests/Unit/Configuration/RichtextTest.php
new file mode 100644 (file)
index 0000000..90c72cb
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Core\Tests\Unit\Configuration;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Configuration\Richtext;
+
+/**
+ * Test case
+ */
+class RichtextTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function getConfigurationUsesOverruleModeFromType()
+    {
+        $fieldConfig = [
+            'type' => 'text',
+            'enableRichtext' => true,
+        ];
+        $pageTsConfig = [
+            'classes.' => [
+                'aClass.' => 'aConfig',
+            ],
+            'properties' => [
+                'default.' => [
+                    'removeComments' => '1',
+                ],
+                'config.' => [
+                    'aTable.' => [
+                        'aField.' => [
+                            'types.' => [
+                                'textmedia.' => [
+                                    'proc.' => [
+                                        'overruleMode' => 'myTransformation',
+                                    ],
+                                ]
+                            ]
+                        ]
+                    ]
+                ]
+            ]
+        ];
+        $expected = [
+            'removeComments' => '1',
+            'proc.' => [
+                'overruleMode' => 'myTransformation',
+            ],
+        ];
+        // Accessible mock to $subject since getRtePageTsConfigOfPid calls BackendUtility::getPagesTSconfig()
+        // which can't be mocked in a sane way
+        $subject = $this->getAccessibleMock(Richtext::class, ['getRtePageTsConfigOfPid'], [], '', false);
+        $subject->expects($this->once())->method('getRtePageTsConfigOfPid')->with(42)->willReturn($pageTsConfig);
+        $output = $subject->getConfiguration('aTable', 'aField', 42, 'textmedia', $fieldConfig);
+        $this->assertSame($expected, $output);
+    }
+
+    /**
+     * @test
+     */
+    public function getConfigurationUsesOverruleModeFromConfig()
+    {
+        $fieldConfig = [
+            'type' => 'text',
+            'enableRichtext' => true,
+        ];
+        $pageTsConfig = [
+            'classes.' => [
+                'aClass.' => 'aConfig',
+            ],
+            'properties' => [
+                'default.' => [
+                    'removeComments' => '1',
+                ],
+                'config.' => [
+                    'aTable.' => [
+                        'aField.' => [
+                            'proc.' => [
+                                'overruleMode' => 'myTransformation',
+                            ],
+                        ]
+                    ]
+                ]
+            ]
+        ];
+        $expected = [
+            'removeComments' => '1',
+            'proc.' => [
+                'overruleMode' => 'myTransformation',
+            ],
+        ];
+        // Accessible mock to $subject since getRtePageTsConfigOfPid calls BackendUtility::getPagesTSconfig()
+        // which can't be mocked in a sane way
+        $subject = $this->getAccessibleMock(Richtext::class, ['getRtePageTsConfigOfPid'], [], '', false);
+        $subject->expects($this->once())->method('getRtePageTsConfigOfPid')->with(42)->willReturn($pageTsConfig);
+        $output = $subject->getConfiguration('aTable', 'aField', 42, 'textmedia', $fieldConfig);
+        $this->assertSame($expected, $output);
+    }
+
+    /**
+     * @test
+     */
+    public function getConfigurationSetsOverruleModeIfMissing()
+    {
+        $fieldConfig = [
+            'type' => 'text',
+            'enableRichtext' => true,
+        ];
+        $pageTsConfig = [
+            'classes.' => [
+                'aClass.' => 'aConfig',
+            ],
+            'properties' => [
+                'default.' => [
+                    'removeComments' => '1',
+                ],
+            ]
+        ];
+        $expected = [
+            'removeComments' => '1',
+            'proc.' => [
+                'overruleMode' => 'default',
+            ],
+        ];
+        // Accessible mock to $subject since getRtePageTsConfigOfPid calls BackendUtility::getPagesTSconfig()
+        // which can't be mocked in a sane way
+        $subject = $this->getAccessibleMock(Richtext::class, ['getRtePageTsConfigOfPid'], [], '', false);
+        $subject->expects($this->once())->method('getRtePageTsConfigOfPid')->with(42)->willReturn($pageTsConfig);
+        $output = $subject->getConfiguration('aTable', 'aField', 42, 'textmedia', $fieldConfig);
+        $this->assertSame($expected, $output);
+    }
+
+    /**
+     * @test
+     */
+    public function getConfigurationMigratesTsCss()
+    {
+        $fieldConfig = [
+            'type' => 'text',
+            'enableRichtext' => true,
+        ];
+        $pageTsConfig = [
+            'classes.' => [
+                'aClass.' => 'aConfig',
+            ],
+            'properties' => [
+                'default.' => [
+                    'proc.' => [
+                        'overruleMode' => 'ts_css',
+                    ],
+                ],
+            ],
+        ];
+        $expected = [
+            'proc.' => [
+                'overruleMode' => 'default',
+            ],
+        ];
+        // Accessible mock to $subject since getRtePageTsConfigOfPid calls BackendUtility::getPagesTSconfig()
+        // which can't be mocked in a sane way
+        $subject = $this->getAccessibleMock(Richtext::class, ['getRtePageTsConfigOfPid'], [], '', false);
+        $subject->expects($this->once())->method('getRtePageTsConfigOfPid')->with(42)->willReturn($pageTsConfig);
+        $output = $subject->getConfiguration('aTable', 'aField', 42, 'textmedia', $fieldConfig);
+        $this->assertSame($expected, $output);
+    }
+}
index c7411f8..e79aa58 100644 (file)
@@ -1066,12 +1066,15 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
     public function migrateRemovesRteTransformOptionsDataProvider()
     {
         return [
-            'remove empty options in columns' => [
+            'columns richtext configuration' => [
                 [
                     // Given config section
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext:rte_transform[]'
                             ]
                         ]
@@ -1082,17 +1085,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove nothing in columns' => [
+            'columns richtext configuration without bracket' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext:rte_transform'
                             ]
                         ]
@@ -1102,17 +1112,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove mode in columns' => [
+            'columns richtext with mode' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]'
                             ]
                         ]
@@ -1122,17 +1139,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove flag and mode in columns' => [
+            'columns richtext with mode and others' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]'
                             ]
                         ]
@@ -1142,17 +1166,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove flag and mode in columns with array notation' => [
+            'columns richtext with array with mode and others' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext[]:rte_transform[flag=rte_enabled|mode=ts_css]'
                             ]
                         ]
@@ -1162,17 +1193,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext[]:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove flag and mode in columns with array notation and index' => [
+            'columns richtext * with mode and others' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]'
                             ]
                         ]
@@ -1182,17 +1220,24 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext[*]:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove flag and mode in columns with array notation and index and option list' => [
+            'columns richtext cut-copy-paste with mode and others' => [
                 [
                     'aTable' => [
                         'columns' => [
                             'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
                                 'defaultExtras' => 'richtext[cut|copy|paste]:rte_transform[flag=rte_enabled|mode=ts_css]'
                             ]
                         ]
@@ -1202,15 +1247,26 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     'aTable' => [
                         'columns' => [
                             'aField' => [
-                                'defaultExtras' => 'richtext[cut|copy|paste]:rte_transform'
+                                'config' => [
+                                    'type' => 'text',
+                                    'enableRichtext' => true,
+                                    'richtextConfiguration' => 'default',
+                                ],
                             ]
                         ]
                     ]
                 ],
             ],
-            'remove empty options in columnsOverrides' => [
+            'columnsOverrides richtext with brackets' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1224,11 +1280,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1236,9 +1302,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove nothing in columnsOverrides' => [
+            'columnsOverrides richtext' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1252,11 +1325,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1264,9 +1347,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove mode in columnsOverrides' => [
+            'columnsOverrides richtext with defalut mode' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1280,11 +1370,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1292,9 +1392,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove flag and mode in columnsOverrides' => [
+            'columnsOverrides richtext with mode and others' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1308,11 +1415,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1320,9 +1437,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove flag and mode in columnsOverrides with array notation' => [
+            'columnsOverrides richtext brackets mode and others' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1336,11 +1460,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext[]:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1348,9 +1482,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove flag and mode in columnsOverrides with array notation and index' => [
+            'columnsOverrides richtext star with mode and others' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1364,11 +1505,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext[*]:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
@@ -1376,9 +1527,16 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                     ]
                 ],
             ],
-            'remove flag and mode in columnsOverrides with array notation and index and option list' => [
+            'columnsOverrides richtext cut-copy-paste ith mode and others' => [
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
@@ -1392,11 +1550,21 @@ class TcaMigrationTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitT
                 ],
                 [
                     'aTable' => [
+                        'columns' => [
+                            'aField' => [
+                                'config' => [
+                                    'type' => 'text',
+                                ],
+                            ],
+                        ],
                         'types' => [
                             'aType' => [
                                 'columnsOverrides' => [
                                     'aField' => [
-                                        'defaultExtras' => 'richtext[copy|cut|paste]:rte_transform'
+                                        'config' => [
+                                            'enableRichtext' => true,
+                                            'richtextConfiguration' => 'default',
+                                        ],
                                     ]
                                 ]
                             ]
index 2d6d06c..ec0e5e5 100644 (file)
@@ -508,17 +508,14 @@ $GLOBALS['TCA']['tt_content']['types']['text']['showitem'] = '
         rowDescription,
     --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
 ';
-if (!is_array($GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides'])) {
-    $GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides'] = [];
-}
-if (!is_array($GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext'])) {
-    $GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext'] = [];
-}
-$baseDefaultExtrasOfBodytext = '';
-if (!empty($GLOBALS['TCA']['tt_content']['columns']['bodytext']['defaultExtras'])) {
-    $baseDefaultExtrasOfBodytext = $GLOBALS['TCA']['tt_content']['columns']['bodytext']['defaultExtras'] . ':';
+
+if (!isset($GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['config'])
+    || !is_array($GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['config'])
+) {
+    $GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['config'] = [];
 }
-$GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform';
+$GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['config']['enableRichtext'] = true;
+$GLOBALS['TCA']['tt_content']['types']['text']['columnsOverrides']['bodytext']['config']['richtextConfiguration'] = 'default';
 
 // Field arrangement for CE "textpic"
 $GLOBALS['TCA']['tt_content']['types']['textpic']['showitem'] = '
@@ -545,13 +542,14 @@ $GLOBALS['TCA']['tt_content']['types']['textpic']['showitem'] = '
         rowDescription,
     --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
 ';
-if (!is_array($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides'])) {
-    $GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides'] = [];
-}
-if (!is_array($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext'])) {
-    $GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext'] = [];
+
+if (!isset($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['config'])
+    || !is_array($GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytextpic']['config'])
+) {
+    $GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['config'] = [];
 }
-$GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'richtext:rte_transform';
+$GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['config']['enableRichtext'] = true;
+$GLOBALS['TCA']['tt_content']['types']['textpic']['columnsOverrides']['bodytext']['config']['richtextConfiguration'] = 'default';
 
 // Field arrangement for CE "image"
 $GLOBALS['TCA']['tt_content']['types']['image']['showitem'] = '
@@ -604,7 +602,7 @@ if (!is_array($GLOBALS['TCA']['tt_content']['types']['bullets']['columnsOverride
 if (!is_array($GLOBALS['TCA']['tt_content']['types']['bullets']['columnsOverrides']['bodytext'])) {
     $GLOBALS['TCA']['tt_content']['types']['bullets']['columnsOverrides']['bodytext'] = [];
 }
-$GLOBALS['TCA']['tt_content']['types']['bullets']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'nowrap';
+$GLOBALS['TCA']['tt_content']['types']['bullets']['columnsOverrides']['bodytext']['defaultExtras'] = 'nowrap';
 
 // Field arrangement for CE "table"
 $GLOBALS['TCA']['tt_content']['types']['table']['showitem'] = '
@@ -634,7 +632,7 @@ if (!is_array($GLOBALS['TCA']['tt_content']['types']['table']['columnsOverrides'
 if (!is_array($GLOBALS['TCA']['tt_content']['types']['table']['columnsOverrides']['bodytext'])) {
     $GLOBALS['TCA']['tt_content']['types']['table']['columnsOverrides']['bodytext'] = [];
 }
-$GLOBALS['TCA']['tt_content']['types']['table']['columnsOverrides']['bodytext']['defaultExtras'] = $baseDefaultExtrasOfBodytext . 'nowrap:wizards[table]';
+$GLOBALS['TCA']['tt_content']['types']['table']['columnsOverrides']['bodytext']['defaultExtras'] = 'nowrap:wizards[table]';
 
 // Field arrangement for CE "uploads"
 $GLOBALS['TCA']['tt_content']['types']['uploads']['showitem'] = '
index 786ec67..145108f 100644 (file)
@@ -58,9 +58,16 @@ call_user_func(function () {
                 rowDescription,
             --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
         ',
-        'columnsOverrides' => ['bodytext' => ['defaultExtras' => 'richtext:rte_transform']]
     ];
 
+    if (!isset($GLOBALS['TCA']['tt_content']['types']['textmedia']['columnsOverrides']['bodytext']['config'])
+        || !is_array($GLOBALS['TCA']['tt_content']['types']['textmedia']['columnsOverrides']['bodytext']['config'])
+    ) {
+        $GLOBALS['TCA']['tt_content']['types']['textmedia']['columnsOverrides']['bodytext']['config'] = [];
+    }
+    $GLOBALS['TCA']['tt_content']['types']['textmedia']['columnsOverrides']['bodytext']['config']['enableRichtext'] = true;
+    $GLOBALS['TCA']['tt_content']['types']['textmedia']['columnsOverrides']['bodytext']['config']['richtextConfiguration'] = 'default';
+
     $GLOBALS['TCA']['tt_content']['columns']['bodytext']['config']['search']['andWhere'] .= ' OR CType=\'textmedia\'';
 
     // Add table wizard
index b475499..3cdca25 100644 (file)
@@ -16,9 +16,10 @@ namespace TYPO3\CMS\RteCKEditor\Controller;
  */
 
 use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Configuration\Richtext;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController;
@@ -58,13 +59,6 @@ class BrowseLinksController extends AbstractLinkBrowserController
     protected $thisConfig = [];
 
     /**
-     * RTE configuration
-     *
-     * @var array
-     */
-    protected $RTEProperties = [];
-
-    /**
      * Used with the Rich Text Editor.
      * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
      *
@@ -141,11 +135,26 @@ class BrowseLinksController extends AbstractLinkBrowserController
 
         $this->contentLanguageService->init($this->contentsLanguage);
 
+        // @todo: This needs refactoring to enable sane config in flex form, either transfer parts of 'config', or use data providers
         $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-        $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-        $this->RTEProperties = $RTEsetup['properties'];
+        $table = $RTEtsConfigParts[0];
+        $field = $RTEtsConfigParts[2];
+        $recordType = $RTEtsConfigParts[3];
+        $tcaConfigOfField = $GLOBALS['TCA'][$table][$field]['config'] ?? [];
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? [];
+        if (!empty($columnsOverridesConfigOfField)) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaConfigOfField, $columnsOverridesConfigOfField);
+        }
+        $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+        $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+            $RTEtsConfigParts[0],
+            $RTEtsConfigParts[2],
+            $RTEtsConfigParts[3],
+            $RTEtsConfigParts[4],
+            $tcaConfigOfField
+        );
+        $this->thisConfig = $richtextConfiguration;
 
-        $this->thisConfig = BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
         $this->buttonConfig = $this->thisConfig['buttons.']['link.'] ?? [];
     }
 
@@ -213,8 +222,8 @@ class BrowseLinksController extends AbstractLinkBrowserController
             ];
             $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly']
                 || $this->buttonConfig[$this->displayedLinkHandlerId . '.']['properties.']['title.']['readOnly'];
-            if (is_array($this->RTEProperties['classesAnchor.'])) {
-                foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
+            if (is_array($this->thisConfig['classesAnchor.'])) {
+                foreach ($this->thisConfig['classesAnchor.'] as $label => $conf) {
                     if (in_array($conf['class'], $classesAnchorArray, true)) {
                         $classesAnchor['all'][] = $conf['class'];
                         if ($conf['type'] === $this->displayedLinkHandlerId) {
@@ -248,11 +257,11 @@ class BrowseLinksController extends AbstractLinkBrowserController
                     if ($this->linkAttributeValues['class'] === $class || !$this->linkAttributeValues['class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) {
                         $selected = 'selected="selected"';
                     }
-                    $classLabel = !empty($this->RTEProperties['classes.'][$class . '.']['name'])
-                        ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0)
+                    $classLabel = !empty($this->thisConfig['classes.'][$class . '.']['name'])
+                        ? $this->getPageConfigLabel($this->thisConfig['classes.'][$class . '.']['name'], 0)
                         : $class;
-                    $classStyle = !empty($this->RTEProperties['classes.'][$class . '.']['value'])
-                        ? $this->RTEProperties['classes.'][$class . '.']['value']
+                    $classStyle = !empty($this->thisConfig['classes.'][$class . '.']['value'])
+                        ? $this->thisConfig['classes.'][$class . '.']['value']
                         : '';
                     $this->classesAnchorJSOptions[$this->displayedLinkHandlerId] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
                 }
index 5813a16..657770a 100644 (file)
@@ -86,13 +86,7 @@ class RichTextElement extends AbstractFormElement
             true
         );
 
-        $vanillaRteTsConfig = $this->getBackendUserAuthentication()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->data['effectivePid']));
-        $this->rteConfiguration = BackendUtility::RTEsetup(
-            $vanillaRteTsConfig['properties'],
-            $table,
-            $this->data['fieldName'],
-            $this->data['recordTypeValue']
-        );
+        $this->rteConfiguration = $parameterArray['fieldConf']['config']['richtextConfiguration'];
 
         $resultArray['requireJsModules'] = [];
         $resultArray['requireJsModules'][] =[
index efb51c8..154fd1c 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\RteCKEditor\Form\Resolver;
 
 use TYPO3\CMS\Backend\Form\NodeFactory;
 use TYPO3\CMS\Backend\Form\NodeResolverInterface;
-use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\RteCKEditor\Form\Element\RichTextElement;
 
@@ -50,36 +49,22 @@ class RichTextNodeResolver implements NodeResolverInterface
      */
     public function resolve()
     {
-        $table = $this->data['tableName'];
-        $fieldName = $this->data['fieldName'];
-        $row = $this->data['databaseRow'];
         $parameterArray = $this->data['parameterArray'];
         $backendUser = $this->getBackendUserAuthentication();
-
         if (// This field is not read only
             !$parameterArray['fieldConf']['config']['readOnly']
             // If RTE is generally enabled by user settings and RTE object registry can return something valid
             && $backendUser->isRTE()
+            // If RTE is enabled for field
+            && isset($parameterArray['fieldConf']['config']['enableRichtext'])
+            && $parameterArray['fieldConf']['config']['enableRichtext'] === true
+            // If RTE config is found (prepared by TcaText data provider)
+            && isset($parameterArray['fieldConf']['config']['richtextConfiguration'])
+            && is_array($parameterArray['fieldConf']['config']['richtextConfiguration'])
+            // If RTE is not disabled on configuration level
+            && !$parameterArray['fieldConf']['config']['richtextConfiguration']['disabled']
         ) {
-            // @todo: Most of this stuff is prepared by data providers within $this->data already
-            $specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
-            // If "richtext" is within defaultExtras
-            if (isset($specialConfiguration['richtext'])) {
-                // Operates by reference on $row! 'pid' is changed ...
-                BackendUtility::fixVersioningPid($table, $row);
-                list($recordPid, $tsConfigPid) = BackendUtility::getTSCpidCached($table, $row['uid'], $row['pid']);
-                // If the pid-value is not negative (that is, a pid could NOT be fetched)
-                if ($tsConfigPid >= 0) {
-                    // Fetch page ts config and do some magic with it to find out if RTE is disabled on TS level.
-                    $rteSetup = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($recordPid));
-                    $rteTcaTypeValue = $this->data['recordTypeValue'];
-                    $rteSetupConfiguration = BackendUtility::RTEsetup($rteSetup['properties'], $table, $fieldName, $rteTcaTypeValue);
-                    if (!$rteSetupConfiguration['disabled']) {
-                        // Finally, we're sure the editor should really be rendered ...
-                        return RichTextElement::class;
-                    }
-                }
-            }
+            return RichTextElement::class;
         }
         return null;
     }
index 0d665f7..e425f81 100644 (file)
@@ -15,9 +15,10 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
  */
 
 use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Configuration\Richtext;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController;
@@ -77,13 +78,6 @@ class BrowseLinksController extends AbstractLinkBrowserController
     protected $thisConfig = [];
 
     /**
-     * RTE configuration
-     *
-     * @var array
-     */
-    protected $RTEProperties = [];
-
-    /**
      * Used with the Rich Text Editor.
      * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
      *
@@ -182,11 +176,26 @@ class BrowseLinksController extends AbstractLinkBrowserController
 
         $this->contentLanguageService->init($this->contentTypo3Language);
 
+        // @todo: This needs refactoring to enable sane config in flex form, either transfer parts of 'config', or use data providers
         $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-        $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-        $this->RTEProperties = $RTEsetup['properties'];
+        $table = $RTEtsConfigParts[0];
+        $field = $RTEtsConfigParts[2];
+        $recordType = $RTEtsConfigParts[3];
+        $tcaConfigOfField = $GLOBALS['TCA'][$table][$field]['config'] ?? [];
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? [];
+        if (!empty($columnsOverridesConfigOfField)) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaConfigOfField, $columnsOverridesConfigOfField);
+        }
+        $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+        $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+            $RTEtsConfigParts[0],
+            $RTEtsConfigParts[2],
+            $RTEtsConfigParts[3],
+            $RTEtsConfigParts[4],
+            $tcaConfigOfField
+        );
+        $this->thisConfig = $richtextConfiguration;
 
-        $this->thisConfig = BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
         $this->buttonConfig = isset($this->thisConfig['buttons.']['link.'])
             ? $this->thisConfig['buttons.']['link.']
             : [];
@@ -250,8 +259,8 @@ class BrowseLinksController extends AbstractLinkBrowserController
             ];
             $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly']
                 || $this->buttonConfig[$this->displayedLinkHandlerId . '.']['properties.']['title.']['readOnly'];
-            if (is_array($this->RTEProperties['classesAnchor.'])) {
-                foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
+            if (is_array($this->thisConfig['classesAnchor.'])) {
+                foreach ($this->thisConfig['classesAnchor.'] as $label => $conf) {
                     if (in_array($conf['class'], $classesAnchorArray)) {
                         $classesAnchor['all'][] = $conf['class'];
                         if ($conf['type'] === $this->displayedLinkHandlerId) {
@@ -285,11 +294,11 @@ class BrowseLinksController extends AbstractLinkBrowserController
                     if ($this->linkAttributeValues['class'] === $class || !$this->linkAttributeValues['class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) {
                         $selected = 'selected="selected"';
                     }
-                    $classLabel = !empty($this->RTEProperties['classes.'][$class . '.']['name'])
-                        ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0)
+                    $classLabel = !empty($this->thisConfig['classes.'][$class . '.']['name'])
+                        ? $this->getPageConfigLabel($this->thisConfig['classes.'][$class . '.']['name'], 0)
                         : $class;
-                    $classStyle = !empty($this->RTEProperties['classes.'][$class . '.']['value'])
-                        ? $this->RTEProperties['classes.'][$class . '.']['value']
+                    $classStyle = !empty($this->thisConfig['classes.'][$class . '.']['value'])
+                        ? $this->thisConfig['classes.'][$class . '.']['value']
                         : '';
                     $this->classesAnchorJSOptions[$this->displayedLinkHandlerId] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
                 }
index 7a7f9ab..20b95bf 100644 (file)
@@ -16,6 +16,8 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Configuration\Richtext;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -106,9 +108,27 @@ class ParseHtmlController
     public function main_parse_html($openKeys)
     {
         $html = GeneralUtility::_GP('content');
+
+        // @todo: This needs refactoring to enable sane config in flex form, either transfer parts of 'config', or use data providers
         $RTEtsConfigParts = explode(':', GeneralUtility::_GP('RTEtsConfigParams'));
-        $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-        $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
+        $table = $RTEtsConfigParts[0];
+        $field = $RTEtsConfigParts[2];
+        $recordType = $RTEtsConfigParts[3];
+        $tcaConfigOfField = $GLOBALS['TCA'][$table][$field]['config'] ?? [];
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? [];
+        if (!empty($columnsOverridesConfigOfField)) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaConfigOfField, $columnsOverridesConfigOfField);
+        }
+        $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+        $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+            $RTEtsConfigParts[0],
+            $RTEtsConfigParts[2],
+            $RTEtsConfigParts[3],
+            $RTEtsConfigParts[4],
+            $tcaConfigOfField
+        );
+        $thisConfig = $richtextConfiguration;
+
         $HTMLParser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
         if (is_array($thisConfig['enableWordClean.'])) {
             $HTMLparserConfig = $thisConfig['enableWordClean.']['HTMLparser.'];
index e0e61f1..77aa333 100644 (file)
@@ -16,10 +16,11 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Configuration\Richtext;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\Service\MagicImageService;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController;
 use TYPO3\CMS\Recordlist\LinkHandler\LinkHandlerInterface;
@@ -126,13 +127,28 @@ class SelectImageController extends AbstractLinkBrowserController
             : '';
         $this->bparams = implode('|', $pArr);
 
+        // @todo: This needs refactoring to enable sane config in flex form, either transfer parts of 'config', or use data providers
         $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-        $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-        $this->RTEProperties = $RTEsetup['properties'];
-
-        $thisConfig = BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
-        $this->buttonConfig = isset($thisConfig['buttons.']['image.'])
-            ? $thisConfig['buttons.']['image.']
+        $table = $RTEtsConfigParts[0];
+        $field = $RTEtsConfigParts[2];
+        $recordType = $RTEtsConfigParts[3];
+        $tcaConfigOfField = $GLOBALS['TCA'][$table][$field]['config'] ?? [];
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? [];
+        if (!empty($columnsOverridesConfigOfField)) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaConfigOfField, $columnsOverridesConfigOfField);
+        }
+        $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+        $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+            $RTEtsConfigParts[0],
+            $RTEtsConfigParts[2],
+            $RTEtsConfigParts[3],
+            $RTEtsConfigParts[4],
+            $tcaConfigOfField
+        );
+        $this->RTEProperties = $richtextConfiguration;
+
+        $this->buttonConfig = isset($this->RTEProperties['buttons.']['image.'])
+            ? $this->RTEProperties['buttons.']['image.']
             : [];
     }
 
@@ -296,7 +312,7 @@ class SelectImageController extends AbstractLinkBrowserController
             if ($this->displayedLinkHandlerId === 'magic') {
                 // Create the magic image service
                 $magicImageService = GeneralUtility::makeInstance(MagicImageService::class);
-                $magicImageService->setMagicImageMaximumDimensions($this->RTEProperties['default.']);
+                $magicImageService->setMagicImageMaximumDimensions($this->RTEProperties);
                 // Create the magic image
                 $imageConfiguration = [
                     'width' => GeneralUtility::_GP('cWidth'),
index 6f48c88..dd25b1d 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
  */
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Configuration\Richtext;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -173,9 +175,27 @@ class UserElementsController
     {
         // Starting content:
         $content = $this->doc->startPage(htmlspecialchars($GLOBALS['LANG']->getLL('Insert Custom Element')));
-        $RTEtsConfigParts = explode(':', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RTEtsConfigParams'));
-        $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-        $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
+
+        // @todo: This needs refactoring to enable sane config in flex form, either transfer parts of 'config', or use data providers
+        $RTEtsConfigParts = explode(':', GeneralUtility::_GP('RTEtsConfigParams'));
+        $table = $RTEtsConfigParts[0];
+        $field = $RTEtsConfigParts[2];
+        $recordType = $RTEtsConfigParts[3];
+        $tcaConfigOfField = $GLOBALS['TCA'][$table][$field]['config'] ?? [];
+        $columnsOverridesConfigOfField = $GLOBALS['TCA'][$table]['types'][$recordType]['columnsOverrides'][$field]['config'] ?? [];
+        if (!empty($columnsOverridesConfigOfField)) {
+            ArrayUtility::mergeRecursiveWithOverrule($tcaConfigOfField, $columnsOverridesConfigOfField);
+        }
+        $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
+        $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
+            $RTEtsConfigParts[0],
+            $RTEtsConfigParts[2],
+            $RTEtsConfigParts[3],
+            $RTEtsConfigParts[4],
+            $tcaConfigOfField
+        );
+        $thisConfig = $richtextConfiguration;
+
         if (is_array($thisConfig['userElements.'])) {
             $categories = [];
             foreach ($thisConfig['userElements.'] as $k => $value) {
index 74cc6c9..7293b38 100644 (file)
@@ -90,7 +90,7 @@ class SelectFont extends RteHtmlAreaApi
     public function main(array $configuration)
     {
         $enabled = parent::main($configuration) && $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['allowStyleAttribute'];
-        $this->RTEProperties = $this->configuration['RTEsetup']['properties'];
+        $this->RTEProperties = $this->configuration['thisConfig'];
         return $enabled;
     }
 
index 48947ab..aaeeded 100644 (file)
@@ -75,7 +75,7 @@ class Typo3Link extends RteHtmlAreaApi
                 $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = new Object();';
             }
             $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.pathLinkModule = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('rtehtmlarea_wizard_browse_links')) . ';';
-            if (is_array($this->configuration['RTEsetup']['properties']['classesAnchor.'])) {
+            if (is_array($this->configuration['thisConfig']['classesAnchor.'])) {
                 $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.classesAnchorUrl = "' . $this->writeTemporaryFile('classesAnchor_' . $this->configuration['contentLanguageUid'], 'js', $this->buildJSClassesAnchorArray()) . '";';
             }
             $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.additionalAttributes = "' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? ',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] : '') . '";';
@@ -92,7 +92,7 @@ class Typo3Link extends RteHtmlAreaApi
     {
         $JSClassesAnchorArray = 'HTMLArea.classesAnchorSetup = [ ' . LF;
         $classesAnchorIndex = 0;
-        foreach ($this->configuration['RTEsetup']['properties']['classesAnchor.'] as $label => $conf) {
+        foreach ($this->configuration['thisConfig']['classesAnchor.'] as $label => $conf) {
             if (is_array($conf) && $conf['class']) {
                 $JSClassesAnchorArray .= ($classesAnchorIndex++ ? ',' : '') . ' { ' . LF;
                 $index = 0;
index cf7fe82..d49e685 100644 (file)
@@ -61,27 +61,7 @@ class RichTextElement extends AbstractFormElement
     protected $pidOfVersionedMotherRecord;
 
     /**
-     * Native, not further processed TsConfig of RTE section for this record on given pid.
-     *
-     * Example:
-     *
-     * RTE = foo
-     * RTE.bar = xy
-     *
-     * array(
-     *         'value' => 'foo',
-     *         'properties' => array(
-     *                 'bar' => 'xy',
-     *         ),
-     * );
-     *
-     * @var array
-     */
-    protected $vanillaRteTsConfig;
-
-    /**
-     * Based on $vanillaRteTsConfig, this property contains "processed" configuration
-     * where table and type specific RTE setup is merged into 'default.' array.
+     * RTE configuration array. Set by TcaText provider.
      *
      * @var array
      */
@@ -223,13 +203,7 @@ class RichTextElement extends AbstractFormElement
         $this->pidOfPageRecord = $this->data['effectivePid'];
         BackendUtility::fixVersioningPid($table, $row);
         $this->pidOfVersionedMotherRecord = (int)$row['pid'];
-        $this->vanillaRteTsConfig = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pidOfPageRecord));
-        $this->processedRteConfiguration = BackendUtility::RTEsetup(
-            $this->vanillaRteTsConfig['properties'],
-            $table,
-            $fieldName,
-            $this->data['recordTypeValue']
-        );
+        $this->processedRteConfiguration = $parameterArray['fieldConf']['config']['richtextConfiguration'];
         $this->client = $this->clientInfo();
         $this->domIdentifier = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $parameterArray['itemFormElName']);
         $this->domIdentifier = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $this->domIdentifier));
@@ -329,16 +303,9 @@ class RichTextElement extends AbstractFormElement
 
         $itemFormElementName = $this->data['parameterArray']['itemFormElName'];
 
-        // This seems to result in:
-        //     _TRANSFORM_bodytext (the handled field name) in case the field is a direct DB field
-        //     _TRANSFORM_vDEF (constant string) in case the RTE is within a flex form
-        $triggerFieldName = preg_replace('/\\[([^]]+)\\]$/', '[_TRANSFORM_\\1]', $itemFormElementName);
-
         $value = $this->transformDatabaseContentToEditor($this->data['parameterArray']['itemFormElValue']);
 
         $result = [];
-        // The hidden field tells the DataHandler that processing should be done on this value.
-        $result[] = '<input type="hidden" name="' . htmlspecialchars($triggerFieldName) . '" value="RTE" />';
         $result[] = '<div id="pleasewait' . $this->domIdentifier . '" class="pleasewait" style="display: block;" >';
         $result[] =    $this->getLanguageService()->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/locallang.xlf:Please wait');
         $result[] = '</div>';
@@ -369,7 +336,6 @@ class RichTextElement extends AbstractFormElement
                         'contentTypo3Language' => $this->contentTypo3Language,
                         'contentISOLanguage' => $this->contentISOLanguage,
                         'contentLanguageUid' => $this->contentLanguageUid,
-                        'RTEsetup' => $this->vanillaRteTsConfig,
                         'client' => $this->client,
                         'thisConfig' => $this->processedRteConfiguration,
                         'specConf' => $this->defaultExtras,
@@ -806,7 +772,7 @@ class RichTextElement extends AbstractFormElement
      */
     protected function buildJSClassesArray()
     {
-        $RTEProperties = $this->vanillaRteTsConfig['properties'];
+        $RTEProperties = $this->processedRteConfiguration;
         // Declare sub-arrays
         $classesArray = [
             'labels' => [],
@@ -1214,7 +1180,6 @@ class RichTextElement extends AbstractFormElement
      */
     protected function RTEtsConfigParams()
     {
-        $parameters = BackendUtility::getSpecConfParametersFromArray($this->defaultExtras['rte_transform']['parameters']);
         $result = [
             $this->data['tableName'],
             $this->data['databaseRow']['uid'],
@@ -1222,7 +1187,6 @@ class RichTextElement extends AbstractFormElement
             $this->pidOfVersionedMotherRecord,
             $this->data['recordTypeValue'],
             $this->pidOfPageRecord,
-            $parameters['imgpath'],
         ];
         return implode(':', $result);
     }
index d7be72d..a5cdc43 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Rtehtmlarea\Form\Resolver;
 
 use TYPO3\CMS\Backend\Form\NodeFactory;
 use TYPO3\CMS\Backend\Form\NodeResolverInterface;
-use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Rtehtmlarea\Form\Element\RichTextElement;
 
@@ -50,36 +49,22 @@ class RichTextNodeResolver implements NodeResolverInterface
      */
     public function resolve()
     {
-        $table = $this->data['tableName'];
-        $fieldName = $this->data['fieldName'];
-        $row = $this->data['databaseRow'];
         $parameterArray = $this->data['parameterArray'];
         $backendUser = $this->getBackendUserAuthentication();
-
         if (// This field is not read only
             !$parameterArray['fieldConf']['config']['readOnly']
             // If RTE is generally enabled by user settings and RTE object registry can return something valid
             && $backendUser->isRTE()
+            // If RTE is enabled for field
+            && isset($parameterArray['fieldConf']['config']['enableRichtext'])
+            && $parameterArray['fieldConf']['config']['enableRichtext'] === true
+            // If RTE config is found (prepared by TcaText data provider)
+            && isset($parameterArray['fieldConf']['config']['richtextConfiguration'])
+            && is_array($parameterArray['fieldConf']['config']['richtextConfiguration'])
+            // If RTE is not disabled on configuration level
+            && !$parameterArray['fieldConf']['config']['richtextConfiguration']['disabled']
         ) {
-            // @todo: Most of this stuff is prepared by data providers within $this->data already
-            $specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
-            // If "richtext" is within defaultExtras
-            if (isset($specialConfiguration['richtext'])) {
-                // Operates by reference on $row! 'pid' is changed ...
-                BackendUtility::fixVersioningPid($table, $row);
-                list($recordPid, $tsConfigPid) = BackendUtility::getTSCpidCached($table, $row['uid'], $row['pid']);
-                // If the pid-value is not negative (that is, a pid could NOT be fetched)
-                if ($tsConfigPid >= 0) {
-                    // Fetch page ts config and do some magic with it to find out if RTE is disabled on TS level.
-                    $rteSetup = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($recordPid));
-                    $rteTcaTypeValue = $this->data['recordTypeValue'];
-                    $rteSetupConfiguration = BackendUtility::RTEsetup($rteSetup['properties'], $table, $fieldName, $rteTcaTypeValue);
-                    if (!$rteSetupConfiguration['disabled']) {
-                        // Finally, we're sure the editor should really be rendered ...
-                        return RichTextElement::class;
-                    }
-                }
-            }
+            return RichTextElement::class;
         }
         return null;
     }
index 185da29..d7d1b17 100644 (file)
@@ -124,8 +124,8 @@ class EditImageHandler implements LinkHandlerInterface, LinkParameterProviderInt
 
         $lockPlainWidth = false;
         $lockPlainHeight = false;
-        if (isset($rteProperties['default.']['proc.']['plainImageMode'])) {
-            $plainImageMode = $rteProperties['default.']['proc.']['plainImageMode'];
+        if (isset($rteProperties['proc.']['plainImageMode'])) {
+            $plainImageMode = $rteProperties['proc.']['plainImageMode'];
             $lockPlainWidth = $plainImageMode === 'lockDimensions';
             $lockPlainHeight = $lockPlainWidth || $plainImageMode === 'lockRatio' || $plainImageMode === 'lockRatioWhenSmaller';
         }