[BUGFIX] SoftReferenceIndex typolink lacks support for title attributes 71/28171/2
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Fri, 7 Mar 2014 16:51:11 +0000 (17:51 +0100)
committerMarc Bastian Heinrichs <typo3@mbh-software.de>
Tue, 15 Apr 2014 08:16:13 +0000 (10:16 +0200)
The SoftReferenceIndex parses and rebuilds typolink tags, but the
support for the title attributes was missing.
This leads to lost title attributes on typolinks in exports from impexp.

Resolves: #56580
Releases: 6.2, 6.1, 6.0, 4.5
Change-Id: I9bf5c02b79ae4c9024322f0da99dcca37b678daa
Reviewed-on: https://review.typo3.org/28171
Reviewed-by: Wouter Wolters
Reviewed-by: Marc Bastian Heinrichs
Tested-by: Marc Bastian Heinrichs
t3lib/class.t3lib_softrefproc.php

index ac5d2ce..fbceaa7 100644 (file)
@@ -611,25 +611,45 @@ class t3lib_softrefproc {
 
        /**
         * Analyse content as a TypoLink value and return an array with properties.
-        * TypoLinks format is: <link [typolink] [browser target] [css class]>. See tslib_content::typolink()
+        * TypoLinks format is: <link [typolink] [browser target] [css class] [title attribute] [additionalParams]>.
+        * See tslib_cObj::typolink()
         * The syntax of the [typolink] part is: [typolink] = [page id or alias][,[type value]][#[anchor, if integer = tt_content uid]]
         * The extraction is based on how tslib_content::typolink() behaves.
         *
         * @param       string          TypoLink value.
         * @return      array           Array with the properties of the input link specified. The key "LINK_TYPE" will reveal the type. If that is blank it could not be determined.
-        * @see tslib_content::typolink(), setTypoLinkPartsElement()
+        * @see tslib_cObj::typolink(), setTypoLinkPartsElement()
         */
        function getTypoLinkParts($typolinkValue) {
                $finalTagParts = array();
-
-                       // Split by space into link / target / class
-               list($link_param, $browserTarget, $cssClass) = t3lib_div::trimExplode(' ', $typolinkValue, 1);
-               if (strlen($browserTarget)) {
-                       $finalTagParts['target'] = $browserTarget;
+               $browserTarget = '';
+               $cssClass = '';
+               $titleAttribute = '';
+               $additionalParams = '';
+               // Split into link / target / class / title / additionalParams
+               $linkParameter = t3lib_div::unQuoteFilenames($typolinkValue, TRUE);
+               // Link parameter value
+               $link_param = trim($linkParameter[0]);
+               // Target value
+               if (isset($linkParameter[1])) {
+                       $browserTarget = trim($linkParameter[1]);
+               }
+               // Link class
+               if (isset($linkParameter[2])) {
+                       $cssClass = trim($linkParameter[2]);
+               }
+               // Title value
+               if (isset($linkParameter[3])) {
+                       $titleAttribute = trim($linkParameter[3]);
                }
-               if (strlen($cssClass)) {
-                       $finalTagParts['class'] = $cssClass;
+               if (isset($linkParameter[4]) && trim($linkParameter[4]) !== '') {
+                       $additionalParams = trim($linkParameter[4]);
                }
+               // set all tag parts because setTypoLinkPartsElement() rely on them
+               $finalTagParts['target'] = $browserTarget;
+               $finalTagParts['class'] = $cssClass;
+               $finalTagParts['title'] = $titleAttribute;
+               $finalTagParts['additionalParams'] = $additionalParams;
 
                        // Parse URL:
                $pU = @parse_url($link_param);
@@ -803,15 +823,21 @@ class t3lib_softrefproc {
                        break;
                }
 
-                       // Finally, for all entries that was rebuild with tokens, add target and class in the end:
-               if (strlen($content) && strlen($tLP['target'])) {
+               // Finally, for all entries that was rebuild with tokens, add target, class, title and additionalParams in the end:
+               if (strlen($content) && isset($tLP['target']) && $tLP['target'] !== '') {
                        $content .= ' ' . $tLP['target'];
-                       if (strlen($tLP['class'])) {
+                       if (isset($tLP['class']) && $tLP['class'] !== '') {
                                $content .= ' ' . $tLP['class'];
+                               if (isset($tLP['title']) && $tLP['title'] !== '') {
+                                       $content .= ' "' . $tLP['title'] . '"';
+                                       if (isset($tLP['additionalParams']) && $tLP['additionalParams'] !== '') {
+                                               $content .= ' ' . $tLP['additionalParams'];
+                                       }
+                               }
                        }
                }
 
-                       // Return rebuilt typolink value:
+               // Return rebuilt typolink value:
                return $content;
        }