diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-12-16 13:52:20 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-12-16 13:52:20 +0100 |
commit | 7e788e435286db30a7d1dd9fe14fcef12ad911b0 (patch) | |
tree | 5ca66bc3002ed3c71c3ec4ce54e1029f54274e5c | |
parent | 7259529fad909c51bd412135827af08155f72e19 (diff) |
Fix legacy_plugin so it works with assets_path/assets_dir
and also when css/js file URLs do not contain cache buster
-rw-r--r-- | plugins/legacy_browser/legacy_browser.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/plugins/legacy_browser/legacy_browser.php b/plugins/legacy_browser/legacy_browser.php index a26167710..346a0ed8e 100644 --- a/plugins/legacy_browser/legacy_browser.php +++ b/plugins/legacy_browser/legacy_browser.php @@ -28,14 +28,26 @@ class legacy_browser extends rcube_plugin function send_page($args) { + $p1 = $this->rc->output->asset_url('program/js'); + $p2 = $this->rc->output->asset_url('plugins/legacy_browser/js'); + + $assets_dir = $this->rc->config->get('assets_dir'); + $ts1 = filemtime($this->home . '/js/jquery.min.js'); $ts2 = filemtime($this->home . '/js/iehacks.js'); + if (!$ts1 && $assets_dir) { + $ts1 = filemtime($assets_dir . '/plugins/legacy_browser/js/jquery.min.js'); + } + if (!$ts2 && $assets_dir) { + $ts2 = filemtime($assets_dir . '/plugins/legacy_browser/js/iehacks.js'); + } + // put iehacks.js after app.js if ($this->rc->output->browser->ie) { $args['content'] = preg_replace( - '|(<script src="program/js/app(\.min)?\.js\?s=[0-9]+" type="text/javascript"></script>)|', - '\\1<script src="plugins/legacy_browser/js/iehacks.js?s=' . $ts2 . '" type="text/javascript"></script>', + '|(<script src="' . preg_quote($p1, '|') . '/app(\.min)?\.js(\?s=[0-9]+)?" type="text/javascript"></script>)|', + '\\1<script src="' . $p2 . '/iehacks.js?s=' . $ts2 . '" type="text/javascript"></script>', $args['content'], 1, $count); } else { @@ -44,10 +56,10 @@ class legacy_browser extends rcube_plugin // replace jQuery 2.x with 1.x $args['content'] = preg_replace( - '|<script src="program/js/jquery\.min\.js\?s=[0-9]+" type="text/javascript"></script>|', - '<script src="plugins/legacy_browser/js/jquery.min.js?s=' . $ts1 . '" type="text/javascript"></script>' + '|<script src="' . preg_quote($p1, '|') . '/jquery\.min\.js(\?s=[0-9]+)?" type="text/javascript"></script>|', + '<script src="' . $p2 . '/jquery.min.js?s=' . $ts1 . '" type="text/javascript"></script>' // add iehacks.js if it is IE and it wasn't added yet - . ($count ? '' : "\n".'<script src="plugins/legacy_browser/js/iehacks.js?s=' . $ts2 . '" type="text/javascript"></script>'), + . ($count ? '' : "\n".'<script src="' . $p2 . '/iehacks.js?s=' . $ts2 . '" type="text/javascript"></script>'), $args['content'], 1); return $args; |