[FEATURE] RTE: Use HTML5-compliant custom attribute for external url's
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 20 Feb 2012 15:29:50 +0000 (10:29 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 27 Feb 2012 17:07:18 +0000 (18:07 +0100)
htmlArea RTE sets custom attribute "external" on links to external
url's so that they are preserved as external by the RTE
transformation, even though they may look internal.

Use custom attribute "data-htmlarea-external" instead in order to be
HTML5-compliant.

Change-Id: I840f32bc6929debbe92d82731b8afdbec638dc07
Resolves: #34114
Releases: 4.7
Reviewed-on: http://review.typo3.org/9124
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Steffen Ritter
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
t3lib/class.t3lib_parsehtml_proc.php
typo3/sysext/rtehtmlarea/extensions/TYPO3Link/class.tx_rtehtmlarea_typo3link.php
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

index 2843f93..8046c1c 100644 (file)
@@ -567,7 +567,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                unset($attribArray_copy['target']);
                                unset($attribArray_copy['class']);
                                unset($attribArray_copy['title']);
-                               unset($attribArray_copy['external']);
+                               unset($attribArray_copy['data-htmlarea-external']);
                                if ($attribArray_copy['rteerror']) { // Unset "rteerror" and "style" attributes if "rteerror" is set!
                                        unset($attribArray_copy['style']);
                                        unset($attribArray_copy['rteerror']);
@@ -590,8 +590,8 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        $attribArray['class'] = preg_match('/ /', $attribArray['class']) ? '"' . $attribArray['class'] . '"' : $attribArray['class'];
                                        $attribArray['title'] = preg_match('/ /', $attribArray['title']) ? '"' . $attribArray['title'] . '"' : $attribArray['title'];
                                                // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
-                                               // If external attribute is set, keep the href unchanged
-                                       $href = $attribArray['external'] ? $attribArray['href'] : $info['url'] . ($info['query'] ? ',0,' . $info['query'] : '');
+                                               // If data-htmlarea-external attribute is set, keep the href unchanged
+                                       $href = $attribArray['data-htmlarea-external'] ? $attribArray['href'] : $info['url'] . ($info['query'] ? ',0,' . $info['query'] : '');
                                        $bTag = '<link ' . $href . ($attribArray['target'] ? ' ' . $attribArray['target'] : (($attribArray['class'] || $attribArray['title']) ? ' -' : '')) . ($attribArray['class'] ? ' ' . $attribArray['class'] : ($attribArray['title'] ? ' -' : '')) . ($attribArray['title'] ? ' ' . $attribArray['title'] : '') . '>';
                                        $eTag = '</link>';
 
@@ -613,14 +613,14 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                } else { // ... otherwise store the link as a-tag.
                                                // Unsetting 'rtekeep' attribute if that had been set.
                                        unset($attribArray['rtekeep']);
-                                       if (!$attribArray['external']) {
+                                       if (!$attribArray['data-htmlarea-external']) {
                                                        // If the url is local, remove url-prefix
                                                $siteURL = $this->siteUrl();
                                                if ($siteURL && substr($attribArray['href'], 0, strlen($siteURL)) == $siteURL) {
                                                        $attribArray['href'] = $this->relBackPath . substr($attribArray['href'], strlen($siteURL));
                                                }
                                        }
-                                       unset($attribArray['external']);
+                                       unset($attribArray['data-htmlarea-external']);
                                        $bTag = '<a ' . t3lib_div::implodeAttributes($attribArray, 1) . '>';
                                        $eTag = '</a>';
                                        $blockSplit[$k] = $bTag . $this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])) . $eTag;
@@ -709,7 +709,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                                ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') .
                                                ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') .
                                                ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') .
-                                               ($external ? ' external="1"' : '') .
+                                               ($external ? ' data-htmlarea-external="1"' : '') .
                                                ($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>';
@@ -1632,7 +1632,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        if (!$uP['scheme']) {
                                                $attribArray['href'] = $this->siteUrl() . substr($attribArray['href'], strlen($this->relBackPath));
                                        } elseif ($uP['scheme'] != 'mailto') {
-                                               $attribArray['external'] = 1;
+                                               $attribArray['data-htmlarea-external'] = 1;
                                        }
                                } else {
                                        $attribArray['rtekeep'] = 1;
index 091e610..5b8a252 100644 (file)
@@ -104,7 +104,7 @@ class tx_rtehtmlarea_typo3link extends tx_rtehtmlarea_api {
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.classesAnchorUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', 'classesAnchor_'.$this->htmlAreaRTE->contentLanguageUid, 'js', $this->buildJSClassesAnchorArray(), TRUE) . '";';
                        }
                        $registerRTEinJavascriptString .= '
-                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.additionalAttributes = "external' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? (',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes']) : '') . '";';
+                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.additionalAttributes = "data-htmlarea-external' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? (',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes']) : '') . '";';
                }
                return $registerRTEinJavascriptString;
        }
index ae1ec4b..41200be 100644 (file)
@@ -249,7 +249,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                }
                        // Note: parseCurUrl will invoke the hooks
                $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
-               if (isset($this->curUrlArray['external']) && $this->curUrlInfo['act'] != 'mail') {
+               if (isset($this->curUrlArray['data-htmlarea-external']) && $this->curUrlInfo['act'] != 'mail') {
                        $this->curUrlInfo['act'] = 'url';
                        $this->curUrlInfo['info'] = $this->curUrlArray['href'];
                }
@@ -533,7 +533,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
                                if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
                                if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
-                               browse_links_setAdditionalValue("external", "");
+                               browse_links_setAdditionalValue("data-htmlarea-external", "");
                                plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
                                return false;
                        }
@@ -543,7 +543,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
                                if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
                                if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
-                               browse_links_setAdditionalValue("external", "");
+                               browse_links_setAdditionalValue("data-htmlarea-external", "");
                                plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
                                return false;
                        }
@@ -551,7 +551,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
                                if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
                                if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
-                               browse_links_setAdditionalValue("external", "");
+                               browse_links_setAdditionalValue("data-htmlarea-external", "");
                                plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
                                return false;
                        }
@@ -710,7 +710,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        <tr>
                                                                <td>'.$LANG->getLL('emailAddress',1).':</td>
                                                                <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
-                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value);browse_links_setAdditionalValue(\'external\', \'\');return link_current();" /></td>
+                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value);browse_links_setAdditionalValue(\'data-htmlarea-external\', \'\');return link_current();" /></td>
                                                        </tr>
                                                </table>
                                        </form>';
@@ -727,7 +727,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        <tr>
                                                                <td>URL:</td>
                                                                <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
-                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.lurlform.lurl.value)) { browse_links_setHref(document.lurlform.lurl.value); } else { browse_links_setHref(\'http://\'+document.lurlform.lurl.value); }; browse_links_setAdditionalValue(\'external\', \'1\'); return link_current();" /></td>
+                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.lurlform.lurl.value)) { browse_links_setHref(document.lurlform.lurl.value); } else { browse_links_setHref(\'http://\'+document.lurlform.lurl.value); }; browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); return link_current();" /></td>
                                                        </tr>
                                                </table>
                                        </form>';
@@ -935,7 +935,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        <td>
                                                        </td>
                                                        <td colspan="3">
-                                                               <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="' . (($this->act == 'url') ? 'browse_links_setAdditionalValue(\'external\', \'1\'); ' : '') .'return link_current();" />
+                                                               <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="' . (($this->act == 'url') ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '') .'return link_current();" />
                                                        </td>
                                                </tr>';
                }
@@ -1173,4 +1173,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
 }
 
-?>
\ No newline at end of file
+?>