[FEATURE] RTE: Use HTML5-compliant custom attribute for click-enlarge
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 18 Feb 2012 05:25:46 +0000 (00:25 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 18 Feb 2012 05:45:19 +0000 (06:45 +0100)
Problem: htmlArea RTE click-enlarge feature adds custom attribute
"clickenlarge" to trigger click-enlarge rendering.
Solution: Use "data-htmlarea-clickenlarge" instead.

Change-Id: I9479fd971eb9d42168731a74e869b8d23a77d373
Resolves: #34053
Releases: 4.7
Reviewed-on: http://review.typo3.org/9083
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/doc/manual.sxw
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php
typo3/sysext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php
typo3/sysext/rtehtmlarea/static/clickenlarge/setup.txt

index 615be6b..66cf2bb 100644 (file)
Binary files a/typo3/sysext/rtehtmlarea/doc/manual.sxw and b/typo3/sysext/rtehtmlarea/doc/manual.sxw differ
index c853b31..a415767 100644 (file)
@@ -544,7 +544,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                if (plugin.getButton("Language")) {
                                        sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\';
                                }')
-                               .(in_array('clickenlarge', $removedProperties)?'':'
+                               .((in_array('clickenlarge', $removedProperties) || in_array('data-htmlarea-clickenlarge', $removedProperties)) ?'':'
                                sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="0" /></td></tr>\';').'
                                sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
                                sz+=\'</form></table>\';
@@ -644,8 +644,9 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                        }
                                        if (document.imageData.iClickEnlarge) {
                                                if (document.imageData.iClickEnlarge.checked) {
-                                                       selectedImageRef.setAttribute("clickenlarge","1");
+                                                       selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
                                                } else {
+                                                       selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
                                                        selectedImageRef.removeAttribute("clickenlarge");
                                                }
                                        }
@@ -739,7 +740,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                                }
                                        }
                                        if (document.imageData.iClickEnlarge) {
-                                               if (selectedImageRef.getAttribute("clickenlarge") == "1") {
+                                               if (selectedImageRef.getAttribute("data-htmlarea-clickenlarge") == "1" || selectedImageRef.getAttribute("clickenlarge") == "1") {
                                                        document.imageData.iClickEnlarge.checked = 1;
                                                } else {
                                                        document.imageData.iClickEnlarge.checked = 0;
index f0bb591..def1ecd 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2005-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2005-2012 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -25,7 +25,7 @@
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
 /**
- * Render custom attribute clickenlarge
+ * Render custom attribute data-htmlarea-clickenlarge
  *
  * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
  */
@@ -45,7 +45,7 @@ class tx_rtehtmlarea_pi3 extends tslib_pibase {
        var $cObj;
 
        /**
-        * Rendering the "clickenlarge" custom attribute, called from TypoScript
+        * Rendering the "data-htmlarea-clickenlarge" custom attribute, called from TypoScript
         *
         * @param       string          Content input. Not used, ignore.
         * @param       array           TypoScript configuration
@@ -54,7 +54,11 @@ class tx_rtehtmlarea_pi3 extends tslib_pibase {
         */
        function render_clickenlarge($content,$conf) {
 
-               $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
+               $clickenlarge = isset($this->cObj->parameters['datahtmlareaclickenlarge']) ? $this->cObj->parameters['datahtmlareaclickenlarge'] : 0;
+               if (!$clickenlarge) {
+                               // Backward compatibility
+                       $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
+               }
                $path = $this->cObj->parameters['src'];
                $pathPre = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
                if (t3lib_div::isFirstPartOfStr($path,$pathPre)) {
@@ -66,6 +70,8 @@ class tx_rtehtmlarea_pi3 extends tslib_pibase {
                        $file = $this->cObj->parameters['src'];
                }
 
+               unset($this->cObj->parameters['datahtmlareaclickenlarge']);
+                       // Backward compatibility
                unset($this->cObj->parameters['clickenlarge']);
                unset($this->cObj->parameters['allParams']);
                $content = '<img '. t3lib_div::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
@@ -87,9 +93,7 @@ class tx_rtehtmlarea_pi3 extends tslib_pibase {
                return $content;
        }
 }
-
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi3/class.tx_rtehtmlarea_pi3.php']);
 }
-
 ?>
\ No newline at end of file
index d5b0967..d7266ca 100644 (file)
@@ -17,6 +17,8 @@ lib.parseFunc_RTE {
                }
        }
        nonTypoTagStdWrap.HTMLparser.tags.img.fixAttrib {
+               datahtmlareaclickenlarge.unset = 1
+               ## Backward compatibility
                clickenlarge.unset = 1
                clickenlargesrc.unset = 1
        }