[BUGFIX] additionalParameters for TCEMAIN.preview must handle arrays
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / EditDocumentController.php
index 911b6ac..15adce1 100644 (file)
@@ -815,7 +815,9 @@ class EditDocumentController {
 
                // add/override parameters by configuration
                if (isset($previewConfiguration['additionalGetParameters.'])) {
-                       $linkParameters = array_replace($linkParameters, $previewConfiguration['additionalGetParameters.']);
+                       $additionalGetParameters = [];
+                       $this->parseAdditionalGetParameters($additionalGetParameters, $previewConfiguration['additionalGetParameters.']);
+                       $linkParameters = array_replace($linkParameters, $additionalGetParameters);
                }
 
                $this->popViewId = $previewPageId;
@@ -835,6 +837,27 @@ class EditDocumentController {
        }
 
        /**
+        * Migrates a set of (possibly nested) GET parameters in TypoScript syntax to a plain array
+        *
+        * This basically removes the trailing dots of sub-array keys in TypoScript.
+        * The result can be used to create a query string with GeneralUtility::implodeArrayForUrl().
+        *
+        * @param array $parameters Should be an empty array by default
+        * @param array $typoScript The TypoScript configuration
+        */
+       protected function parseAdditionalGetParameters(array &$parameters, array $typoScript) {
+               foreach ($typoScript as $key => $value) {
+                       if (is_array($value)) {
+                               $key = rtrim($key, '.');
+                               $parameters[$key] = [];
+                               $this->parseAdditionalGetParameters($parameters[$key], $value);
+                       } else {
+                               $parameters[$key] = $value;
+                       }
+               }
+       }
+
+       /**
         * Main module operation
         *
         * @return void