[FOLLOWUP][TASK] Restructure typolink tag generation 77/52277/2
authorBenni Mack <benni@typo3.org>
Thu, 30 Mar 2017 23:20:11 +0000 (01:20 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 31 Mar 2017 00:15:42 +0000 (02:15 +0200)
The JSwindowParams was not initialized anymore at right place and is moved.

Additionally, the overhead for recurring aTagParams and URL has been moved outside
of the switch/case statement, as it was a leftover of the restructuring.

Resolves: #80586
Releases: master
Change-Id: Id8566227bb0884c7e487b236fbac534a2f15f550
Reviewed-on: https://review.typo3.org/52277
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index b1e919c..959bc7b 100644 (file)
@@ -5590,7 +5590,6 @@ class ContentObjectRenderer
             // If it's a mail address
             case LinkService::TYPE_EMAIL:
                 list($this->lastTypoLinkUrl, $linkText) = $this->getMailTo($linkDetails['email'], $linkText);
-                $finalTagParts['url'] = $this->lastTypoLinkUrl;
             break;
 
             // URL (external)
@@ -5606,11 +5605,8 @@ class ContentObjectRenderer
                     }
                 }
                 $linkText = $this->parseFallbackLinkTextIfLinkTextIsEmpty($linkText, $linkDetails['url']);
-
                 $this->lastTypoLinkUrl = $this->processUrl(UrlProcessorInterface::CONTEXT_EXTERNAL, $linkDetails['url'], $conf);
                 $this->lastTypoLinkTarget = $target;
-                $finalTagParts['url'] = $this->lastTypoLinkUrl;
-                $finalTagParts['aTagParams'] .= $this->extLinkATagParams($finalTagParts['url'], LinkService::TYPE_URL);
             break;
 
             // File (internal)
@@ -5633,8 +5629,6 @@ class ContentObjectRenderer
                         }
                     }
                     $this->lastTypoLinkTarget = $target;
-                    $finalTagParts['url'] = $this->lastTypoLinkUrl;
-                    $finalTagParts['aTagParams'] .= $this->extLinkATagParams($finalTagParts['url'], LinkService::TYPE_FILE);
                 } else {
                     $this->getTimeTracker()->setTSlogMessage('typolink(): File "' . $linkParameter . '" did not exist, so "' . $linkText . '" was not linked.', 1);
                     return $linkText;
@@ -5880,8 +5874,6 @@ class ContentObjectRenderer
                         $this->lastTypoLinkLD['totalUrl'] = $this->lastTypoLinkUrl;
                         $LD = $this->lastTypoLinkLD;
                     }
-                    // Rendering the tag.
-                    $finalTagParts['url'] = $this->lastTypoLinkUrl;
                 } else {
                     $this->getTimeTracker()->setTSlogMessage('typolink(): Page id "' . $linkParameter . '" was not found, so "' . $linkText . '" was not linked.', 1);
                     return $linkText;
@@ -5924,6 +5916,7 @@ class ContentObjectRenderer
             // Legacy files or something else
             case LinkService::TYPE_UNKNOWN:
                 if ($linkDetails['file']) {
+                    $linkDetails['type'] = LinkService::TYPE_FILE;
                     $linkLocation = $linkDetails['file'];
                     // Setting title if blank value to link
                     $linkText = $this->parseFallbackLinkTextIfLinkTextIsEmpty($linkText, rawurldecode($linkLocation));
@@ -5937,9 +5930,8 @@ class ContentObjectRenderer
                         }
                     }
                     $this->lastTypoLinkTarget = $target;
-                    $finalTagParts['url'] = $this->lastTypoLinkUrl;
-                    $finalTagParts['aTagParams'] .= $this->extLinkATagParams($finalTagParts['url'], LinkService::TYPE_FILE);
                 } elseif ($linkDetails['url']) {
+                    $linkDetails['type'] = LinkService::TYPE_URL;
                     if (empty($target)) {
                         if (isset($conf['extTarget'])) {
                             $target = $conf['extTarget'];
@@ -5954,22 +5946,17 @@ class ContentObjectRenderer
 
                     $this->lastTypoLinkUrl = $this->processUrl(UrlProcessorInterface::CONTEXT_EXTERNAL, $linkDetails['url'], $conf);
                     $this->lastTypoLinkTarget = $target;
-                    $finalTagParts['url'] = $this->lastTypoLinkUrl;
-                    $finalTagParts['aTagParams'] .= $this->extLinkATagParams($finalTagParts['url'], LinkService::TYPE_URL);
                 }
                 break;
         }
 
+        $finalTagParts['url'] = $this->lastTypoLinkUrl;
         $finalTagParts['TYPE'] = $linkDetails['type'];
+        $finalTagParts['aTagParams'] .= $this->extLinkATagParams($this->lastTypoLinkUrl, $linkDetails['type']);
         $this->lastTypoLinkLD = $LD;
 
         // Building the final <a href=".."> tag
         $tagAttributes = [];
-        if (!$JSwindowParams && $linkDetails['type'] === LinkService::TYPE_EMAIL && $tsfe->spamProtectEmailAddresses === 'ascii') {
-            $tagAttributes['href'] = $finalTagParts['url'];
-        } else {
-            $tagAttributes['href'] = htmlspecialchars($finalTagParts['url']);
-        }
 
         // Title attribute
         if (empty($title)) {
@@ -5996,6 +5983,11 @@ class ContentObjectRenderer
             // Imploding into string:
             $JSwindowParams = implode(',', $JSwindow_paramsArr);
         }
+        if (!$JSwindowParams && $linkDetails['type'] === LinkService::TYPE_EMAIL && $tsfe->spamProtectEmailAddresses === 'ascii') {
+            $tagAttributes['href'] = $finalTagParts['url'];
+        } else {
+            $tagAttributes['href'] = htmlspecialchars($finalTagParts['url']);
+        }
         if (!empty($title)) {
             $tagAttributes['title'] = htmlspecialchars($title);
         }