[BUGFIX] Refactor CKEditor to be inline with the AbstractLinkBrowser 60/51760/3
authorFrans Saris <franssaris@gmail.com>
Sun, 19 Feb 2017 20:28:30 +0000 (21:28 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 21 Feb 2017 07:44:37 +0000 (08:44 +0100)
The internals of the LinkBrowser and LinkHandler depend on all the
field specific info to be in the P parameter.

Further the DatabaseBrowser used by the RecordBrowser fetches the table
parameter form global url query scope what collides with the params set
by the CKEditor RichTextElement.

To prevent the parameter collision the params set by the RichTextElement
are moved to the P prefix what is also more inline with the other
LinkBrowser implementations.

This patch also resolves the lasts issues related to the new
recordHandler + CKEditor.

Resolves: #79645
Releases: master
Change-Id: Id7cab0f0a012c5de11a2038e1d579d87599d47cd
Reviewed-on: https://review.typo3.org/51760
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php

index e259fc1..8b411c1 100644 (file)
@@ -58,13 +58,6 @@ class BrowseLinksController extends AbstractLinkBrowserController
     protected $thisConfig = [];
 
     /**
-     * Used with the Rich Text Editor.
-     *
-     * @var array
-     */
-    protected $editorDetails = [];
-
-    /**
      * @var array
      */
     protected $classesAnchorDefault = [];
@@ -125,28 +118,20 @@ class BrowseLinksController extends AbstractLinkBrowserController
 
         $this->siteUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
 
-        $currentLinkParts = isset($queryParameters['curUrl']) ? $queryParameters['curUrl'] : [];
-        $this->currentLinkParts = $currentLinkParts;
-        $this->editorId = GeneralUtility::_GP('editorId');
-        $this->contentsLanguage = GeneralUtility::_GP('contentsLanguage');
-        $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
+        $this->currentLinkParts = $queryParameters['curUrl'] ?? [];
+        $this->editorId = $queryParameters['editorId'];
+        $this->contentsLanguage = $queryParameters['contentsLanguage'];
+        $this->RTEtsConfigParams = $queryParameters['RTEtsConfigParams'] ?? null;
 
         $this->contentLanguageService->init($this->contentsLanguage);
 
-        $this->editorDetails = [
-            'table' => $queryParameters['table'],
-            'uid' => $queryParameters['uid'],
-            'fieldName' => $queryParameters['fieldName'],
-            'pid' => $queryParameters['pid'],
-            'recordType' => $queryParameters['recordType'],
-        ];
-
+        /** @var Richtext $richtextConfigurationProvider */
         $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
         $this->thisConfig = $richtextConfigurationProvider->getConfiguration(
-            $queryParameters['table'],
-            $queryParameters['fieldName'],
-            (int)$queryParameters['pid'],
-            $queryParameters['recordType'],
+            $this->parameters['table'],
+            $this->parameters['fieldName'],
+            (int)$this->parameters['pid'],
+            $this->parameters['recordType'],
             ['richtext' => true]
         );
         $this->buttonConfig = $this->thisConfig['buttons.']['link.'] ?? [];
@@ -530,7 +515,7 @@ class BrowseLinksController extends AbstractLinkBrowserController
      */
     protected function getCurrentPageId()
     {
-        return (int)$this->editorDetails['pid'];
+        return (int)$this->parameters['pid'];
     }
 
     /**
@@ -565,10 +550,11 @@ class BrowseLinksController extends AbstractLinkBrowserController
      */
     public function getUrlParameters(array $overrides = null)
     {
-        return array_merge($this->editorDetails, [
+        return [
             'act' => isset($overrides['act']) ? $overrides['act'] : $this->displayedLinkHandlerId,
             'editorId' => $this->editorId,
             'contentsLanguage' => $this->contentsLanguage,
-        ]);
+            'P' => $this->parameters
+        ];
     }
 }
index 89f1344..4906b4e 100644 (file)
@@ -196,11 +196,13 @@ class RichTextElement extends AbstractFormElement
     protected function getExtraPlugins(): array
     {
         $urlParameters = [
-            'table'      => $this->data['tableName'],
-            'uid'        => $this->data['databaseRow']['uid'],
-            'fieldName'  => $this->data['fieldName'],
-            'recordType' => $this->data['recordTypeValue'],
-            'pid'        => $this->data['effectivePid'],
+            'P' => [
+                'table'      => $this->data['tableName'],
+                'uid'        => $this->data['databaseRow']['uid'],
+                'fieldName'  => $this->data['fieldName'],
+                'recordType' => $this->data['recordTypeValue'],
+                'pid'        => $this->data['effectivePid'],
+            ]
         ];
 
         $pluginConfiguration = [];