From 6e927aaec4a47f0ca1aa5eb5ddac0f6d747bd319 Mon Sep 17 00:00:00 2001
From: Christer Vindberg <cvi@systime.dk>
Date: Fri, 24 Feb 2017 14:33:34 +0100
Subject: [PATCH] [BUGFIX] Opening links in pop-up windows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Moved the check for if the target is coded as a JS open window link,
to a later stage in the function.

Since Css Styled Content and Fluid Styled Content was refactored,
the target might not be set until later in the typoLink
function. This caused pop links to stop working, moving the check for a
pop up link target to a later stages fixes the problem.

Resolves: #79918
Releases: master
Change-Id: Ie27fa3142df83c33ba3ad465ecb35c0f6e571f86
Reviewed-on: https://review.typo3.org/51830
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anders Kostending <aha@systime.dk>
Reviewed-by: Faton Haliti <fha@systime.dk>
Reviewed-by: Jasmina Ließmann <code@frauliessmann.de>
Tested-by: Jasmina Ließmann <code@frauliessmann.de>
Reviewed-by: Timo Hund <timo.hund@yahoo.com>
Tested-by: Timo Hund <timo.hund@yahoo.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
---
 .../ContentObject/ContentObjectRenderer.php   | 38 +++++++++----------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index cdaf656c7086..99f29b5ee1fe 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -5691,26 +5691,6 @@ class ContentObjectRenderer
             return $linkText;
         }
 
-        // Check, if the target is coded as a JS open window link:
-        $JSwindowParts = [];
-        $JSwindowParams = '';
-        if ($target && preg_match('/^([0-9]+)x([0-9]+)(:(.*)|.*)$/', $target, $JSwindowParts)) {
-            // Take all pre-configured and inserted parameters and compile parameter list, including width+height:
-            $JSwindow_tempParamsArr = GeneralUtility::trimExplode(',', strtolower($conf['JSwindow_params'] . ',' . $JSwindowParts[4]), true);
-            $JSwindow_paramsArr = [];
-            foreach ($JSwindow_tempParamsArr as $JSv) {
-                list($JSp, $JSv) = explode('=', $JSv, 2);
-                $JSwindow_paramsArr[$JSp] = $JSp . '=' . $JSv;
-            }
-            // Add width/height:
-            $JSwindow_paramsArr['width'] = 'width=' . $JSwindowParts[1];
-            $JSwindow_paramsArr['height'] = 'height=' . $JSwindowParts[2];
-            // Imploding into string:
-            $JSwindowParams = implode(',', $JSwindow_paramsArr);
-            // Resetting the target since we will use onClick.
-            $target = '';
-        }
-
         // Detecting kind of link and resolve all necessary parameters
         /** @var LinkService $linkService */
         $linkService = GeneralUtility::makeInstance(LinkService::class);
@@ -6105,6 +6085,24 @@ class ContentObjectRenderer
             }
         }
 
+        // Check, if the target is coded as a JS open window link:
+        $JSwindowParts = [];
+        $JSwindowParams = '';
+        if ($target && preg_match('/^([0-9]+)x([0-9]+)(:(.*)|.*)$/', $target, $JSwindowParts)) {
+            // Take all pre-configured and inserted parameters and compile parameter list, including width+height:
+            $JSwindow_tempParamsArr = GeneralUtility::trimExplode(',', strtolower($conf['JSwindow_params'] . ',' . $JSwindowParts[4]), true);
+            $JSwindow_paramsArr = [];
+            foreach ($JSwindow_tempParamsArr as $JSv) {
+                list($JSp, $JSv) = explode('=', $JSv, 2);
+                $JSwindow_paramsArr[$JSp] = $JSp . '=' . $JSv;
+            }
+            // Add width/height:
+            $JSwindow_paramsArr['width'] = 'width=' . $JSwindowParts[1];
+            $JSwindow_paramsArr['height'] = 'height=' . $JSwindowParts[2];
+            // Imploding into string:
+            $JSwindowParams = implode(',', $JSwindow_paramsArr);
+        }
+
         if ($JSwindowParams) {
             // Create TARGET-attribute only if the right doctype is used
             $xhtmlDocType = $tsfe->xhtmlDoctype;
-- 
GitLab