From 22922b00bcf1b1e7ecbbc467782d4c7724b4ce88 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 13 Apr 2006 02:57:25 +0000 Subject: [PATCH] Thwart the browser cache by versioning tinyMCE. Props to that Andy guy. fixes #2658 git-svn-id: http://svn.automattic.com/wordpress/trunk@3703 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 4 +- .../plugins/inlinepopups/editor_plugin.js | 2 + wp-includes/js/tinymce/tiny_mce_config.php | 1 + wp-includes/js/tinymce/tiny_mce_gzip.php | 68 +++++++++++++++---- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index cbf415057..f71405896 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -1033,8 +1033,8 @@ function do_all_pings() { * Places two script links in : one to get tinyMCE (big), one to configure and start it (small) */ function tinymce_include() { - $src1 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_gzip.php'; - $src2 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_config.php'; + $src1 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=04122006'; + $src2 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_config.php?ver=04122006'; echo "\n"; echo "\n"; diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js index 0cda51545..74d18059c 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js @@ -74,6 +74,8 @@ TinyMCE_Engine.prototype.openWindow = function(template, args) { pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2)); pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); + url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; + mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop); }; diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php index 7b1b1c475..651165abc 100644 --- a/wp-includes/js/tinymce/tiny_mce_config.php +++ b/wp-includes/js/tinymce/tiny_mce_config.php @@ -72,6 +72,7 @@ initArray = { content_css : "", valid_elements : "", save_callback : 'TinyMCE_wordpressPlugin.saveCallback', + imp_version : "", plugins : "" }; diff --git a/wp-includes/js/tinymce/tiny_mce_gzip.php b/wp-includes/js/tinymce/tiny_mce_gzip.php index 28ec1df43..e975389ec 100644 --- a/wp-includes/js/tinymce/tiny_mce_gzip.php +++ b/wp-includes/js/tinymce/tiny_mce_gzip.php @@ -4,9 +4,9 @@ * $Revision: $ * $Date: $ * - * @version 1.07 + * @version 1.08 * @author Moxiecode - * @copyright Copyright © 20052006, Moxiecode Systems AB, All rights reserved. + * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved. * * This file compresses the TinyMCE JavaScript using GZip and * enables the browser to do two requests instead of one for each .js file. @@ -15,7 +15,7 @@ @require_once('../../../wp-config.php'); -gzip_compression(); +// gzip_compression(); function wp_tinymce_lang($path) { global $language; @@ -119,7 +119,7 @@ function TinyMCE_echo($str) { else echo $str; } -/* WP + // Only gzip the contents if clients and server support it $encodings = array(); @@ -127,10 +127,12 @@ if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))); // Check for gzip header or northon internet securities -if ((in_array('gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) { +if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) { + $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip"; + // Use cached file if it exists but not in debug mode if (file_exists($cacheFile) && !$debug) { - header("Content-Encoding: gzip"); + header("Content-Encoding: " . $enc); echo file_get_contents($cacheFile); die; } @@ -139,11 +141,12 @@ if ((in_array('gzip', $encodings) || isset($_SERVER['---------------'])) && func ob_start("ob_gzhandler"); } else $diskCache = false; -WP */ + if ($index > -1) { // Write main script and patch some things if ($index == 0) { TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("tiny_mce" . $suffix . ".js")))); // WP + TinyMCE_echo('TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;'); TinyMCE_echo('TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;'); } else TinyMCE_echo('tinyMCE = realTinyMCE;'); @@ -151,14 +154,18 @@ if ($index > -1) { // Do init based on index TinyMCE_echo("tinyMCE.init(tinyMCECompressed.configs[" . $index . "]);"); + // Load external plugins + if ($index == 0) + TinyMCE_echo("tinyMCECompressed.loadPlugins();"); + // Load theme, language pack and theme language packs if ($theme) { - TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template" . $suffix . ".js")))); + TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template" . $suffix . ".js")))); // WP TinyMCE_echo(wp_tinymce_lang("themes/" . $theme . "/langs/%s.js")); // WP } /* WP if ($language) WP */ - TinyMCE_echo(wp_tinymce_lang("langs/%s.js")); + TinyMCE_echo(wp_tinymce_lang("langs/%s.js")); // WP // Load all plugins and their language packs $plugins = explode(",", $plugins); @@ -194,7 +201,7 @@ if ($index > -1) { } // Output - header("Content-Encoding: gzip"); + header("Content-Encoding: " . $enc); echo $cacheData; } @@ -205,6 +212,7 @@ if ($index > -1) { function TinyMCECompressed() { this.configs = new Array(); this.loadedFiles = new Array(); + this.externalPlugins = new Array(); this.loadAdded = false; this.isLoaded = false; } @@ -227,7 +235,8 @@ TinyMCECompressed.prototype.init = function(settings) { this.configs[this.configs.length] = settings; this.settings = settings; - scriptURL += "?theme=" + escape(this.getOnce(settings["theme"])) + "&language=" + escape(this.getOnce(settings["language"])) + "&plugins=" + escape(this.getOnce(settings["plugins"])) + "&lang=" + settings["language"] + "&index=" + escape(this.configs.length-1); + scriptURL += (scriptURL.indexOf('?') == -1) ? '?' : '&'; + scriptURL += "theme=" + escape(this.getOnce(settings["theme"])) + "&language=" + escape(this.getOnce(settings["language"])) + "&plugins=" + escape(this.getOnce(settings["plugins"])) + "&lang=" + settings["language"] + "&index=" + escape(this.configs.length-1); document.write(''); if (!this.loadAdded) { @@ -244,6 +253,7 @@ TinyMCECompressed.prototype.onLoad = function() { tinyMCE = realTinyMCE; TinyMCE_Engine.prototype.onLoad(); tinyMCE._addUnloadEvents(); + tinyMCE.isLoaded = true; } @@ -255,11 +265,13 @@ TinyMCECompressed.prototype.addEvent = function(o, n, h) { } TinyMCECompressed.prototype.getOnce = function(str) { - var ar = str.split(','); + var ar = str.replace(/\s+/g, '').split(','); for (var i=0; i