Changeset 6765 for trunk/wp-includes/js/tinymce/tiny_mce_gzip.php
- Timestamp:
- 02/09/2008 06:43:15 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/js/tinymce/tiny_mce_gzip.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/tinymce/tiny_mce_gzip.php
r6726 r6765 1 1 <?php 2 /** 2 /** Based on: 3 3 * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $ 4 4 * … … 11 11 */ 12 12 13 //error_reporting(E_ALL); 14 @require_once('../../../wp-config.php'); // For get_bloginfo(). 15 16 // Headers 17 $expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache 18 header("Content-type: text/javascript"); 19 header("Vary: Accept-Encoding"); // Handle proxies 20 header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); 13 @require_once('../../../wp-config.php'); // For get_bloginfo(). 14 cache_javascript_headers(); 21 15 22 16 if ( isset($_GET['load']) ) { 23 17 24 function getParam( $name, $def = false ) {18 function getParam( $name, $def = false ) { 25 19 if ( ! isset($_GET[$name]) ) 26 20 return $def; … … 32 26 $path = realpath($path); 33 27 34 if ( ! $path || !@is_file($path) )28 if ( ! $path || !@is_file($path) ) 35 29 return ''; 36 30 … … 53 47 function putFileContents( $path, $content ) { 54 48 if ( function_exists('file_put_contents') ) 55 return @file_put_contents( $path, $content);49 return @file_put_contents( $path, $content ); 56 50 57 51 $fp = @fopen($path, 'wb'); … … 62 56 } 63 57 64 65 // Get input 58 // WP defaults 59 $themes = explode( ',', getParam('themes', 'advanced') ); 60 61 $language = getParam( 'languages', 'en' ); 62 $language = strtolower( substr($language, 0, 2) ); // only ISO 639-1 63 66 64 $plugins = explode( ',', getParam('plugins', '') ); 67 $languages = explode( ',', getParam('languages', '') );68 $themes = explode( ',', getParam('themes', '') );69 $diskCache = getParam( 'diskcache', '' ) == 'true';70 $isJS = getParam( 'js', '' ) == 'true';71 $compress = getParam( 'compress', 'true' ) == 'true';72 $core = getParam( 'core', 'true' ) == 'true';73 $suffix = getParam( 'suffix', '_src' ) == '_src' ? '_src' : '';74 65 $cachePath = realpath('.'); // Cache path, this is where the .gz files will be stored 75 66 76 $content = '';77 67 $encodings = array(); 78 $supportsGzip = false; 79 $enc = ''; 80 $cacheKey = ''; 81 82 // WP. Language handling could be improved... Concat all translated langs files and store in /wp-content/languages as .mo? 83 $theme = getParam( 'theme', 'advanced' ); 84 $themes = array($theme); 85 86 $language = getParam( 'language', 'en' ); 87 $languages = array($language); 88 89 if ( $language != strtolower($language) ) 90 $languages[] = strtolower($language); 91 92 if ( $language != substr($language, 0, 2) ) 93 $languages[] = substr($language, 0, 2); 94 95 $diskCache = false; 96 $isJS = true; 97 $suffix = ''; 68 $supportsGzip = $diskCache = false; 69 $compress = $core = true; 70 $suffix = $content = $enc = $cacheKey = ''; 98 71 99 72 // Custom extra javascripts to pack … … 104 77 */); 105 78 106 // Is called directly then auto init with default settings 107 if ( ! $isJS ) { 108 echo getFileContents('tiny_mce_gzip.js'); 109 echo 'tinyMCE_GZ.init({});'; 110 die(); 111 } 112 113 // Setup cache info 79 // Setup cache info 114 80 if ( $diskCache ) { 115 81 if ( ! $cachePath ) … … 130 96 131 97 // Check if it supports gzip 132 if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING']) )133 $encodings = explode( ',', strtolower( preg_replace('/\s+/', '', $_SERVER['HTTP_ACCEPT_ENCODING']) ) );134 135 if ( ( in_array('gzip', $encodings ) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------']) ) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') ) {98 if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) 99 $encodings = explode(',', strtolower(preg_replace( '/\s+/', '', $_SERVER['HTTP_ACCEPT_ENCODING']) ) ); 100 101 if ( ( in_array('gzip', $encodings ) || in_array( 'x-gzip', $encodings ) || isset($_SERVER['---------------']) ) && function_exists( 'ob_gzhandler' ) && ! ini_get('zlib.output_compression') ) { 136 102 $enc = in_array( 'x-gzip', $encodings ) ? 'x-gzip' : 'gzip'; 137 103 $supportsGzip = true; … … 143 109 header('Content-Encoding: ' . $enc); 144 110 145 echo getFileContents( $cacheFile);111 echo getFileContents( $cacheFile ); 146 112 die(); 147 113 } … … 149 115 // Add core 150 116 if ( $core == 'true' ) { 151 $content .= getFileContents( 'tiny_mce' . $suffix . '.js');117 $content .= getFileContents( 'tiny_mce' . $suffix . '.js' ); 152 118 153 119 // Patch loading functions … … 155 121 } 156 122 157 // Add core languages 158 $lang_content = ''; 159 foreach ( $languages as $lang ) 160 $lang_content .= getFileContents('langs/' . $lang . '.js'); 161 162 if ( empty($lang_content) && file_exists('langs/en.js') ) 163 $lang_content .= getFileContents('langs/en.js'); 164 165 $content .= $lang_content; 123 // Add all languages (WP) 124 include_once( dirname(__file__).'/langs/wp-langs.php' ); 125 $content .= $strings; 166 126 167 127 // Add themes 168 foreach ( $themes as $theme ) { 169 $content .= getFileContents( 'themes/' . $theme . '/editor_template' . $suffix . '.js'); 170 171 $lang_content = ''; 172 foreach ( $languages as $lang ) 173 $lang_content .= getFileContents( 'themes/' . $theme . '/langs/' . $lang . '.js' ); 174 175 if ( empty($lang_content) && file_exists( 'themes/' . $theme . '/langs/en.js' ) ) 176 $lang_content .= getFileContents( 'themes/' . $theme . '/langs/en.js' ); 177 178 $content .= $lang_content; 179 } 180 128 foreach ( $themes as $theme ) 129 $content .= getFileContents( 'themes/' . $theme . '/editor_template' . $suffix . '.js' ); 130 181 131 // Add plugins 182 foreach ( $plugins as $plugin ) { 183 $content .= getFileContents('plugins/' . $plugin . '/editor_plugin' . $suffix . '.js'); 184 185 $lang_content = ''; 186 foreach ( $languages as $lang ) 187 $lang_content .= getFileContents( 'plugins/' . $plugin . '/langs/' . $lang . '.js' ); 188 189 if ( empty($lang_content) && file_exists( 'plugins/' . $plugin . '/langs/en.js' ) ) 190 $lang_content .= getFileContents( 'plugins/' . $plugin . '/langs/en.js' ); 191 192 $content .= $lang_content; 193 } 132 foreach ( $plugins as $plugin ) 133 $content .= getFileContents( 'plugins/' . $plugin . '/editor_plugin' . $suffix . '.js' ); 194 134 195 135 // Add custom files … … 210 150 211 151 // Write gz file 212 if ( $diskCache && $cacheKey != '')152 if ( $diskCache && '' != $cacheKey ) 213 153 putFileContents( $cacheFile, $cacheData ); 214 154 … … 237 177 }, 238 178 239 opt : {}, 240 241 init : function(arr, cb) { 242 var t = this, n, s, nl = document.getElementsByTagName('script'); 243 244 t.opt = arr; 245 246 t.settings.themes = arr.theme; 247 t.settings.plugins = arr.plugins; 248 t.settings.languages = arr.language; 249 s = t.settings; 250 t.cb = cb || ''; 179 opt : {}, 180 181 init : function(o, cb) { 182 var t = this, n, s = t.settings, nl = document.getElementsByTagName('script'); 183 184 t.opt = o; 185 186 s.themes = o.theme; 187 s.plugins = o.plugins; 188 s.languages = o.language; 189 t.settings = s; 190 191 t.cb = cb || ''; 251 192 252 193 for (i=0; i<nl.length; i++) { … … 256 197 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/')); 257 198 } 258 tinyMCEPreInit.base = t.baseURL;259 199 tinyMCEPreInit.base = t.baseURL; 200 260 201 if (!t.coreLoaded) 261 202 t.loadScripts(1, s.themes, s.plugins, s.languages); … … 282 223 t.coreLoaded = 1; 283 224 284 // Easier to debug with this...285 225 // document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + t.baseURL + '/' + s.page_name + '?' + q + '"></script>'); 286 226
Note: See TracChangeset
for help on using the changeset viewer.