[BUGFIX] RTE cannot run in IE 11+ with ExtJS 3.4.1 76/27776/4
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 21 Feb 2014 15:54:53 +0000 (10:54 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 21 Feb 2014 19:02:22 +0000 (20:02 +0100)
Solution: Configure a hook in frontend to add a meta tag just after
the head tag whenever rtehtmlarea is in use on the page and the user
agent is IE 11+. The meta tag instructs IE to emulate IE 10.

Resolves: #56192
Releases: 6.2
Change-Id: Icc81f14c107360a47a34403032e5fe7890f1d784
Reviewed-on: https://review.typo3.org/27776
Reviewed-by: Markus Klein
Reviewed-by: Wouter Wolters
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/Classes/Hook/Frontend/Controller/TypoScriptFrontendControllerHook.php [new file with mode: 0644]
typo3/sysext/rtehtmlarea/Configuration/Hook/Frontend/Controller/ext_localconf.php [new file with mode: 0644]
typo3/sysext/rtehtmlarea/ext_localconf.php

diff --git a/typo3/sysext/rtehtmlarea/Classes/Hook/Frontend/Controller/TypoScriptFrontendControllerHook.php b/typo3/sysext/rtehtmlarea/Classes/Hook/Frontend/Controller/TypoScriptFrontendControllerHook.php
new file mode 100644 (file)
index 0000000..04f63ef
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+namespace TYPO3\CMS\Rtehtmlarea\Hook\Frontend\Controller;
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 Stanislas Rolland <stanislas.rolland@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the text file GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Frontend hook to add meta tag when rtehtmlarea is present and user agent is IE 11+
+ *
+ */
+class TypoScriptFrontendControllerHook {
+
+       /**
+        * Add meta tag when rtehtmlarea is present and user agent is IE 11+
+        *
+        * @param array $params
+        * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $controller
+        * @return void
+        */
+       public function contentPostProcOutput(array $params, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $controller) {
+               if (strpos($controller->content, 'textarea id="RTEarea') !== FALSE) {
+                       $userAgent = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_USER_AGENT');
+                       $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgent);
+                       if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] > 10) {
+                               $controller->content = preg_replace('/<head([^>]*)>/', '<head$1>' . LF . '<meta http-equiv="X-UA-Compatible" content="IE=10" />', $controller->content);
+                       }
+               }
+       }
+}
diff --git a/typo3/sysext/rtehtmlarea/Configuration/Hook/Frontend/Controller/ext_localconf.php b/typo3/sysext/rtehtmlarea/Configuration/Hook/Frontend/Controller/ext_localconf.php
new file mode 100644 (file)
index 0000000..bd35116
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+if (!defined('TYPO3_MODE')) {
+       die('Access denied.');
+}
+if (TYPO3_MODE === 'FE') {
+       // Register frontend hook to add meta tag when rtehtmlarea is present and user agent is IE 11+
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output']['rtehtmlarea'] = 'TYPO3\\CMS\\Rtehtmlarea\\Hook\\Frontend\\Controller\\TypoScriptFrontendControllerHook->contentPostProcOutput';
+}
index 32e8d5d..4b5d655 100644 (file)
@@ -67,6 +67,8 @@ if (strstr($_EXTCONF['defaultConfiguration'], 'Minimal')) {
 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'hooks/softref/ext_localconf.php';
 // Add Status Report about Conflicting Extensions
 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'hooks/statusreport/ext_localconf.php';
+// Add frontend hook to add meta tag when rtehtmlarea is present and user agent is IE 11+
+require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/Hook/Frontend/Controller/ext_localconf.php';
 
 // Configure Lorem Ipsum hook to insert nonsense in wysiwyg mode
 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('lorem_ipsum') && TYPO3_MODE == 'BE') {