[BUGFIX] Correctly resolve RTE preset configuration for link browser 09/57109/2
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 29 May 2018 22:40:49 +0000 (00:40 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Fri, 1 Jun 2018 21:44:08 +0000 (23:44 +0200)
Replaces hardcoded RTE configuration in BrowseLinksController
with one resolved by Formengine when rendering a field.
This takes into account e.g. column overrides.

The RTE configuration preset name is now kept by Formengine in
['processedTca']['columns'][$fieldName]['config']['richtextConfigurationName']

Then it's being passed as parameter P[richtextConfigurationName] from RTE field
to the BrowseinksController

Resolves: #84943
Releases: master, 8.7
Change-Id: Id4f1c350f6eb6dfad4d49ec759a23939bbc45eda
Reviewed-on: https://review.typo3.org/57109
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaText.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaTextTest.php
typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php

index c2c95eb..49a45e1 100644 (file)
@@ -48,6 +48,8 @@ class TcaText implements FormDataProviderInterface
                     (string)$result['recordTypeValue'],
                     $fieldConfig['config']
                 );
+                // remember RTE preset name
+                $result['processedTca']['columns'][$fieldName]['config']['richtextConfigurationName'] = $fieldConfig['config']['richtextConfiguration'] ?? '';
                 // Add final resolved configuration to TCA array
                 $result['processedTca']['columns'][$fieldName]['config']['richtextConfiguration'] = $richtextConfiguration;
 
index 03f5cc1..b86c09e 100644 (file)
@@ -61,6 +61,7 @@ class TcaTextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                         'config' => [
                             'type' => 'text',
                             'enableRichtext' => true,
+                            'richtextConfigurationName' => '',
                             'richtextConfiguration' => [
                                 'aConfig' => 'option',
                             ],
index b7411d7..54bc6da 100644 (file)
@@ -125,6 +125,11 @@ class BrowseLinksController extends AbstractLinkBrowserController
 
         $this->contentLanguageService->init($this->contentsLanguage);
 
+        $tcaFieldConf = ['enableRichtext' => true];
+        if (!empty($queryParameters['P']['richtextConfigurationName'])) {
+            $tcaFieldConf['richtextConfiguration'] = $queryParameters['P']['richtextConfigurationName'];
+        }
+
         /** @var Richtext $richtextConfigurationProvider */
         $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
         $this->thisConfig = $richtextConfigurationProvider->getConfiguration(
@@ -132,7 +137,7 @@ class BrowseLinksController extends AbstractLinkBrowserController
             $this->parameters['fieldName'],
             (int)$this->parameters['pid'],
             $this->parameters['recordType'],
-            ['richtext' => true]
+            $tcaFieldConf
         );
         $this->buttonConfig = $this->thisConfig['buttons']['link'] ?? [];
     }
index 572291a..9c99923 100644 (file)
@@ -213,6 +213,7 @@ class RichTextElement extends AbstractFormElement
                 'fieldName'  => $this->data['fieldName'],
                 'recordType' => $this->data['recordTypeValue'],
                 'pid'        => $this->data['effectivePid'],
+                'richtextConfigurationName' => $this->data['parameterArray']['fieldConf']['config']['richtextConfigurationName']
             ]
         ];