From 1abbb06ee91f1d75acf4638a98bf2fac1398da31 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 19 Jun 2014 12:22:06 +0200 Subject: Support Firefox < 4 via legacy_browser (jQuery 2.x does not work) --- plugins/legacy_browser/legacy_browser.php | 44 ++++++++++++++++++++----------- plugins/legacy_browser/package.xml | 8 +++--- 2 files changed, 33 insertions(+), 19 deletions(-) (limited to 'plugins/legacy_browser') diff --git a/plugins/legacy_browser/legacy_browser.php b/plugins/legacy_browser/legacy_browser.php index 9378cdc3e..a26167710 100644 --- a/plugins/legacy_browser/legacy_browser.php +++ b/plugins/legacy_browser/legacy_browser.php @@ -1,7 +1,7 @@ * @license GNU GPLv3+ @@ -9,12 +9,18 @@ class legacy_browser extends rcube_plugin { public $noajax = true; + private $rc; public function init() { - $rcube = rcube::get_instance(); + $this->rc = $rcube = rcube::get_instance(); - if ($rcube->output->browser->ie && $rcube->output->browser->ver < 9) { + if ( + // IE < 9 + ($rcube->output->browser->ie && $rcube->output->browser->ver < 9) + // Firefox < 4 (Firefox 4 is recognized as 2.0) + || ($rcube->output->browser->mz && $rcube->output->browser->ver < 2) + ) { $this->add_hook('send_page', array($this, 'send_page')); $this->add_hook('render_page', array($this, 'render_page')); } @@ -22,19 +28,25 @@ class legacy_browser extends rcube_plugin function send_page($args) { - // replace jQuery 2.x with 1.x $ts1 = filemtime($this->home . '/js/jquery.min.js'); $ts2 = filemtime($this->home . '/js/iehacks.js'); // put iehacks.js after app.js - $args['content'] = preg_replace( - '|()|', - '\\1', - $args['content'], 1, $count); + if ($this->rc->output->browser->ie) { + $args['content'] = preg_replace( + '|()|', + '\\1', + $args['content'], 1, $count); + } + else { + $count = 1; + } + // replace jQuery 2.x with 1.x $args['content'] = preg_replace( '||', '' + // add iehacks.js if it is IE and it wasn't added yet . ($count ? '' : "\n".''), $args['content'], 1); @@ -43,23 +55,26 @@ class legacy_browser extends rcube_plugin function render_page($args) { - $rcube = rcube::get_instance(); + if (!$this->rc->output->browser->ie) { + return $args; + } + $skin = $this->skin(); if ($skin == 'classic') { $minified = file_exists(INSTALL_PATH . '/plugins/legacy_browser/skins/classic/iehacks.min.css') ? '.min' : ''; - $rcube->output->add_header( + $this->rc->output->add_header( '' ); } else if ($skin == 'larry') { $minified = file_exists(INSTALL_PATH . '/plugins/legacy_browser/skins/larry/iehacks.min.css') ? '.min' : ''; - $rcube->output->add_header( + $this->rc->output->add_header( '' ); - if ($rcube->output->browser->ver < 8) { - $rcube->output->add_header( + if ($this->rc->output->browser->ver < 8) { + $this->rc->output->add_header( '' ); } @@ -68,8 +83,7 @@ class legacy_browser extends rcube_plugin private function skin() { - $rcube = rcube::get_instance(); - $skin = $rcube->config->get('skin'); + $skin = $this->rc->config->get('skin'); // external skin, find if it inherits from other skin if ($skin != 'larry' && $skin != 'classic') { diff --git a/plugins/legacy_browser/package.xml b/plugins/legacy_browser/package.xml index 71a76ef79..06e5fa2ba 100644 --- a/plugins/legacy_browser/package.xml +++ b/plugins/legacy_browser/package.xml @@ -5,17 +5,17 @@ http://pear.php.net/dtd/package-2.0.xsd"> legacy_browser pear.roundcube.net - Legacy browser (IE 7/8) support - This adds support for legacy browsers (IE 7/8). + Legacy browser (IE 7/8, Firefox < 4) support + This adds support for legacy browsers (IE 7/8, Firefox < 4). Aleksander Machniak alec alec@alec.pl yes - 2014-04-12 + 2014-06-19 - 1.0 + 1.1 1.0 -- cgit v1.2.3