[BUGFIX] RTE cannot run in IE 11+ with ExtJS 3.4.1
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Hook / Frontend / Controller / TypoScriptFrontendControllerHook.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Hook\Frontend\Controller;
3 /***************************************************************
4 * Copyright notice
5 *
6 * (c) 2014 Stanislas Rolland <stanislas.rolland@typo3.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the text file GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Frontend hook to add meta tag when rtehtmlarea is present and user agent is IE 11+
30 *
31 */
32 class TypoScriptFrontendControllerHook {
33
34 /**
35 * Add meta tag when rtehtmlarea is present and user agent is IE 11+
36 *
37 * @param array $params
38 * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $controller
39 * @return void
40 */
41 public function contentPostProcOutput(array $params, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $controller) {
42 if (strpos($controller->content, 'textarea id="RTEarea') !== FALSE) {
43 $userAgent = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_USER_AGENT');
44 $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgent);
45 if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] > 10) {
46 $controller->content = preg_replace('/<head([^>]*)>/', '<head$1>' . LF . '<meta http-equiv="X-UA-Compatible" content="IE=10" />', $controller->content);
47 }
48 }
49 }
50 }