Implemented Gremlin #1660: <link> tags now supports a fourth parameter,
authorJan-Erik Revsbech <jer@moccompany.com>
Sun, 27 Nov 2005 13:36:10 +0000 (13:36 +0000)
committerJan-Erik Revsbech <jer@moccompany.com>
Sun, 27 Nov 2005 13:36:10 +0000 (13:36 +0000)
the title of the resulting link.

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@885 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
t3lib/class.t3lib_parsehtml_proc.php
typo3/browse_links.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/lang/locallang_browse_links.xml

index d0646d9..aea4abc 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2005-11-27  Jan-Erik Revsbech  <jer@moccompany.com
+       * Implemented Gremlin 1660: typolink now supports the title attribute (With stdWrap). Additionally the <link> tag used in conjunction with the rte now supports a fourth parameter. In addition to pageid target and class, the fourth parameter is the title of the resulting link.
+
 2005-11-25  Martin Kutschker   <martin.t.kutschker@blackbox.net>
 
        * Fixed PHP 5.0.5 compability issue with end() in class.t3lib_timetrack.php
index 916391b..abc7cb3 100755 (executable)
@@ -3866,9 +3866,10 @@ class t3lib_div {
         * Explode a string (normally a list of filenames) with whitespaces by considering quotes in that string. This is mostly needed by the imageMagickCommand function above.
         *
         * @param       string          The whole parameters string
+        * @param       boolean         If set, the elements of the resulting array are unquoted.
         * @return      array           Exploded parameters
         */
-       function unQuoteFilenames($parameters)  {
+       function unQuoteFilenames($parameters,$unQuote=FALSE)   {
                $paramsArr = explode(' ', trim($parameters));
 
                $quoteActive = -1;      // Whenever a quote character (") is found, $quoteActive is set to the element number inside of $params. A value of -1 means that there are not open quotes at the current position.
@@ -3886,6 +3887,11 @@ class t3lib_div {
                        }
                }
 
+               if($unQuote) {
+                       foreach($paramsArr as $key=>$val) {
+                               $paramsArr[$key]=preg_replace('/(^"|"$)/','',$val);
+                       }
+               }
                return $paramsArr;
        }
 }
index 768399e..55670fe 100755 (executable)
@@ -617,13 +617,14 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                unset($attribArray_copy['href']);
                                unset($attribArray_copy['target']);
                                unset($attribArray_copy['class']);
+                               unset($attribArray_copy['title']);
                                if ($attribArray_copy['rteerror'])      {       // Unset "rteerror" and "style" attributes if "rteerror" is set!
                                        unset($attribArray_copy['style']);
                                        unset($attribArray_copy['rteerror']);
                                }
                                if (!count($attribArray_copy))  {       // Only if href, target and class are the only attributes, we can alter the link!
                                                // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
-                                       $bTag='<LINK '.$info['url'].($attribArray['target']?' '.$attribArray['target']:($attribArray['class']?' -':'')).($attribArray['class']?' '.$attribArray['class']:'').'>';
+                                       $bTag='<LINK '.$info['url'].($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' "'.$attribArray['title'].'"':'').'>';
                                        $eTag='</LINK>';
                                        $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
                                } else {        // ... otherwise store the link as a-tag.
@@ -659,7 +660,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                foreach($blockSplit as $k => $v)        {
                        $error = '';
                        if ($k%2)       {       // block:
-                               $tagCode = t3lib_div::trimExplode(' ',trim(substr($this->getFirstTag($v),0,-1)),1);
+                               $tagCode = t3lib_div::unQuoteFilenames(trim(substr($this->getFirstTag($v),0,-1)),true);
                                $link_param = $tagCode[1];
                                $href = '';
                                $siteUrl = $this->siteUrl();
@@ -714,7 +715,8 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                // Setting the A-tag:
                                $bTag = '<a href="'.htmlspecialchars($href).'"'.
                                                        ($tagCode[2]&&$tagCode[2]!='-' ? ' target="'.htmlspecialchars($tagCode[2]).'"' : '').
-                                                       ($tagCode[3] ? ' class="'.htmlspecialchars($tagCode[3]).'"' : '').
+                                                       ($tagCode[3]&&$tagCode[3]!='-' ? ' class="'.htmlspecialchars($tagCode[3]).'"' : '').
+                                                       ($tagCode[4] ? ' title="'.htmlspecialchars($tagCode[4]).'"' : '').
                                                        ($error ? ' rteerror="'.htmlspecialchars($error).'" style="background-color: yellow; border:2px red solid; color: black;"' : '').       // Should be OK to add the style; the transformation back to databsae will remove it...
                                                        '>';
                                $eTag = '</a>';
index f519c34..6501fb6 100755 (executable)
@@ -639,6 +639,7 @@ class SC_browse_links {
        var $siteURL;                   // Current site URL (Frontend)
        var $thisConfig;                // RTE specific TSconfig
        var $setTarget;                 // Target (RTE specific)
+       var $setTitle;                  // title (RTE specific)
        var $doc;                               // Backend template object
 
                // GPvars:      (Input variables from outside)
@@ -707,7 +708,7 @@ class SC_browse_links {
 
 
        /**
-        * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href" and "target" keys. This information is passed around in links.
+        * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href", "target" and "title" keys. This information is passed around in links.
         */
        var $curUrlArray;
 
@@ -783,6 +784,9 @@ class SC_browse_links {
                        $this->setTarget=$this->thisConfig['defaultLinkTarget'];
                }
 
+                       // Initializing the title value (RTE)
+               $this->setTitle = $this->curUrlArray['title'];
+
 
 
                        // Creating backend template object:
@@ -796,15 +800,21 @@ class SC_browse_links {
                                // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
                        var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
                        var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
+                       var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
                        var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
 
                        var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
                        var cur_target="'.($this->setTarget?$this->setTarget:'').'";
+                       var cur_title="'.($this->setTitle?$this->setTitle:'').'";
 
                        function setTarget(target)      {       //
                                cur_target=target;
                                add_target="&curUrl[target]="+escape(target);
                        }
+                       function setTitle(title)        {       //
+                               cur_title=title;
+                               add_title="&curUrl[title]="+escape(title);
+                       }
                        function setValue(value)        {       //
                                cur_href=value;
                                add_href="&curUrl[href]="+value;
@@ -840,7 +850,7 @@ class SC_browse_links {
                                }
                                function link_current() {       //
                                        if (cur_href!="http://" && cur_href!="mailto:") {
-                                               var setValue = cur_href+" "+cur_target;
+                                               var setValue = cur_href+" "+cur_target+" "+cur_title;
                                                if (setValue.substr(0,7)=="http://")    setValue = setValue.substr(7);
                                                if (setValue.substr(0,7)=="mailto:")    setValue = setValue.substr(7);
                                                updateValueInMainForm(setValue);
@@ -867,21 +877,21 @@ class SC_browse_links {
                        $JScode.='
                                function link_typo3Page(id,anchor)      {       //
                                        var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
-                                       self.parent.parent.renderPopup_addLink(theLink,cur_target);
+                                       self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
                                        return false;
                                }
                                function link_folder(folder)    {       //
                                        var theLink = \''.$this->siteURL.'\'+folder;
-                                       self.parent.parent.renderPopup_addLink(theLink,cur_target);
+                                       self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
                                        return false;
                                }
                                function link_spec(theLink)     {       //
-                                       self.parent.parent.renderPopup_addLink(theLink,cur_target);
+                                       self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
                                        return false;
                                }
                                function link_current() {       //
                                        if (cur_href!="http://" && cur_href!="mailto:") {
-                                               self.parent.parent.renderPopup_addLink(cur_href,cur_target);
+                                               self.parent.parent.renderPopup_addLink(cur_href,cur_target,cur_title);
                                        }
                                        return false;
                                }
@@ -893,7 +903,7 @@ class SC_browse_links {
                        function jumpToUrl(URL,anchor)  {       //
                                var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
                                var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
-                               var theLocation = URL+add_act+add_mode+add_href+add_target+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
+                               var theLocation = URL+add_act+add_mode+add_href+add_target+add_title+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
                                document.location = theLocation;
                                return false;
                        }
@@ -1252,11 +1262,30 @@ class SC_browse_links {
                        break;
                }
 
+               $content .= '
+
+
+
+                       <!--
+                               Selecting title for link:
+                       -->
+                               <form action="" name="ltitleform" id="ltargetform">
+                                       <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
+                                               <tr>
+                                                       <td>'.$GLOBALS['LANG']->getLL('title',1).'</td>
+                                                       <td><input type="text" name="ltitle" onchange="setTitle(this.value);" value="'.htmlspecialchars($this->setTitle).'"'.$this->doc->formWidth(10).' /></td>
+                                                       <td><input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" /></td>
+                                               </tr>
+                                       </table>
+                               </form>
+';
+
                        // Target:
                if ($this->act!='mail') {
                        $ltarget='
 
 
+
                        <!--
                                Selecting target for link:
                        -->
@@ -1283,6 +1312,7 @@ class SC_browse_links {
                                if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0)     {
                                        document.ltargetform.ltarget.value = document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value+"x"+document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value;
                                        setTarget(document.ltargetform.ltarget.value);
+          setTitle(document.ltitleform.ltitle.value);
                                        document.ltargetform.popup_width.selectedIndex=0;
                                        document.ltargetform.popup_height.selectedIndex=0;
                                }
index 9f82464..a9c69ab 100755 (executable)
@@ -4003,7 +4003,7 @@ class tslib_cObj {
         * @see _parseFunc()
         */
        function parseFunc($theValue, $conf, $ref='') {
-
+               
                        // Fetch / merge reference, if any
                if ($ref)       {
                        $temp_conf = array(
@@ -4938,16 +4938,19 @@ class tslib_cObj {
                $finalTagParts['aTagParams'] = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:'');
 
                $link_param = trim($this->stdWrap($conf['parameter'],$conf['parameter.']));
+
                $sectionMark = trim($this->stdWrap($conf['section'],$conf['section.']));
                $sectionMark = $sectionMark ? '#c'.$sectionMark : '';
                $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
                $this->lastTypoLinkUrl = '';
                $this->lastTypoLinkTarget = '';
                if ($link_param)        {
-                       $link_paramA = t3lib_div::trimExplode(' ',$link_param,1);
+                       $link_paramA = t3lib_div::unQuoteFilenames($link_param,true);
                        $link_param = trim($link_paramA[0]);    // Link parameter value
                        $linkClass = trim($link_paramA[2]);             // Link class
+                       if ($linkClass=='-')    $linkClass = '';        // The '-' character means 'no class'. Necessary in order to specify a title as fourth parameter without setting the target or class!
                        $forceTarget = trim($link_paramA[1]);   // Target value
+                       $forceTitle = trim($link_paramA[3]);    // Title value
                        if ($forceTarget=='-')  $forceTarget = '';      // The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target!
                                // Check, if the target is coded as a JS open window link:
                        $JSwindowParts = array();
@@ -4973,6 +4976,10 @@ class tslib_cObj {
                        $target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget;
                        if ($conf['target.'])   {$target=$this->stdWrap($target, $conf['target.']);}
 
+                               // Title tag
+                       $title = $conf['title'];
+                       if ($conf['title.'])    {$title=$this->stdWrap($title, $conf['title.']);}
+
                                // Parse URL:
                        $pU = parse_url($link_param);
 
@@ -5164,6 +5171,8 @@ class tslib_cObj {
                                }
                        }
 
+                       if ($forceTitle)        {$title=$forceTitle;}
+
                        if ($JSwindowParams)    {
 
                                        // Create TARGET-attribute only if the right doctype is used
@@ -5174,12 +5183,12 @@ class tslib_cObj {
                                }
 
                                $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;";
-                               $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'. $target .' onclick="'.htmlspecialchars($onClick).'"'.($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'. $target .' onclick="'.htmlspecialchars($onClick).'"'.($title?' title="'.$title.'"':'').($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
                        } else {
                                if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii' && $finalTagParts['TYPE'] === 'mailto') {
-                                       $res = '<a href="'.$finalTagParts['url'].'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                                       $res = '<a href="'.$finalTagParts['url'].'"'.($title?' title="'.$title.'"':'').$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
                                } else {
-                                       $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                                       $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.($title?' title="'.$title.'"':'').$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
                                }
                        }
 
index 36dfcb8..9542404 100755 (executable)
@@ -23,6 +23,7 @@
                        <label index="folderTree">Folder Tree</label>
                        <label index="files">Files</label>
                        <label index="target">Target</label>
+                       <label index="title">Title</label>
                        <label index="target_popUpWindow">Open in window</label>
                        <label index="target_popUpWindow_width">Width</label>
                        <label index="target_popUpWindow_height">Height</label>