Changeset 7378 for trunk/wp-includes/js/tinymce/tiny_mce_config.php
- Timestamp:
- 03/18/2008 06:59:53 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/tinymce/tiny_mce_config.php
r7270 r7378 54 54 if ( $https ) str_replace('http://', 'https://', $mce_css); 55 55 56 $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 57 56 58 /* 57 59 Setting mce_valid_elements to *[*] skips all of the internal cleanup and can cause problems. … … 70 72 The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu. 71 73 By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server. 72 The + sign marks the default language. 73 More information: 74 The + sign marks the default language. More information: 74 75 http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker 75 76 */ … … 79 80 80 81 /* 81 The following filter takes an associative array of external plugins for TinyMCE in the form "name" => "url".82 The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. 82 83 It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin. 83 The url should be absolute and should include the js file name to be loaded. 84 Example: array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' ). 84 The url should be absolute and should include the js file name to be loaded. Example: 85 array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' ) 85 86 If the plugin uses a button, it should be added with one of the "$mce_buttons" filters. 86 87 */ 87 $mce_external_plugins = apply_filters('mce_external_plugins', array()); 88 $mce_external_plugins = apply_filters('mce_external_plugins', array()); 88 89 89 90 $ext_plugins = "\n"; 90 91 if ( ! empty($mce_external_plugins) ) { 92 93 /* 94 The following filter loads external language files for TinyMCE plugins. 95 It takes an associative array 'plugin_name' => 'path', where path is the 96 include path to the file. The language file should follow the same format as 97 /tinymce/langs/wp-langs.php and should define a variable $strings that 98 holds all translated strings. Example: 99 $strings = 'tinyMCE.addI18n("' . $mce_locale . '.mypluginname_dlg",{tab_general:"General", ... })'; 100 */ 101 $mce_external_languages = apply_filters('mce_external_languages', array()); 102 103 $loaded_langs = array(); 104 $strings = ''; 105 106 if ( ! empty($mce_external_languages) ) { 107 foreach ( $mce_external_languages as $name => $path ) { 108 $loaded_langs[] = $name; 109 110 if ( is_file($path) ) include_once($path); 111 $ext_plugins .= $strings; 112 } 113 } 114 91 115 foreach ( $mce_external_plugins as $name => $url ) { 116 92 117 if ( $https ) str_replace('http://', 'https://', $url); 118 93 119 $plugins[] = '-' . $name; 120 121 if ( in_array($name, $loaded_langs) ) { 122 $plugurl = dirname($url); 123 $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; 124 } 94 125 $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; 95 126 } … … 108 139 $mce_buttons_4 = apply_filters('mce_buttons_4', array()); 109 140 $mce_buttons_4 = implode($mce_buttons_4, ','); 110 111 $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1112 141 113 142 // TinyMCE init settings … … 146 175 147 176 if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements; 148 if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements;177 //if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements; 149 178 if ( $invalid_elements ) $initArray['invalid_elements'] = $invalid_elements; 150 179 … … 179 208 180 209 $cache_ext = '.js'; 181 182 210 $plugins = explode( ',', $initArray['plugins'] ); 183 211 $theme = ( 'simple' == $initArray['theme'] ) ? 'simple' : 'advanced'; 184 212 $language = isset($initArray['language']) ? substr( $initArray['language'], 0, 2 ) : 'en'; 185 $ enc = $cacheKey = $suffix= $mce_options = '';213 $cacheKey = $mce_options = ''; 186 214 187 215 // Check if browser supports gzip 188 216 if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { 189 $encodings = explode( ',', strtolower( preg_replace('/\s+/', '', $_SERVER['HTTP_ACCEPT_ENCODING']) ) ); 190 191 if ( (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------']) ) && function_exists('ob_gzhandler') && (ini_get('zlib.output_compression') == false) ) { 192 $enc = in_array('x-gzip', $encodings) ? 'x-gzip' : 'gzip'; 217 if ( ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') || isset($_SERVER['---------------']) ) && function_exists('gzencode') && ! ini_get('zlib.output_compression') ) { 193 218 $cache_ext = '.gz'; 194 219 } … … 198 223 if ( $disk_cache ) { 199 224 200 $ver = isset($_GET['ver']) ? (int) $_GET['ver'] : ''; 201 $cacheKey = $suffix . $ver; 225 $cacheKey = apply_filters('tiny_mce_version', '20080317'); 202 226 203 227 foreach ( $initArray as $v ) 204 228 $cacheKey .= $v; 205 229 230 if ( ! empty($mce_external_plugins) ) { 231 foreach ( $mce_external_plugins as $n => $v ) 232 $cacheKey .= $n; 233 } 234 206 235 $cacheKey = md5( $cacheKey ); 207 236 $cache_file = $cache_path . '/tinymce_' . $cacheKey . $cache_ext; 208 237 } 209 238 210 cache_javascript_headers(); 239 $expiresOffset = 864000; // 10 days 240 header( 'Content-Type: application/x-javascript; charset=UTF-8' ); 241 header( 'Vary: Accept-Encoding' ); // Handle proxies 242 header( 'Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . ' GMT' ); 211 243 212 244 // Use cached file if exists 213 if ( $disk_cache && file_exists($cache_file) ) { 245 if ( $disk_cache && is_file($cache_file) ) { 246 247 $mtime = gmdate("D, d M Y H:i:s", filemtime($cache_file)) . " GMT"; 248 249 if ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $mtime ) { 250 header('HTTP/1.1 304 Not Modified'); 251 exit; 252 } 253 header("Last-Modified: " . $mtime); 254 header("Cache-Control: must-revalidate", false); 255 256 $content = getFileContents( $cache_file ); 257 214 258 if ( '.gz' == $cache_ext ) 215 header( 'Content-Encoding: ' . $enc ); 216 217 echo getFileContents( $cache_file ); 259 header( 'Content-Encoding: gzip' ); 260 261 header( 'Content-Length: ' . strlen($content) ); 262 263 echo $content; 218 264 exit; 219 265 } … … 225 271 $mce_options = rtrim( trim($mce_options), '\n\r,' ); 226 272 227 $content .= 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "' . $suffix . '" };';273 $content = 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "" };'; 228 274 229 275 // Load patch … … 231 277 232 278 // Add core 233 $content .= getFileContents( 'tiny_mce ' . $suffix . '.js' );279 $content .= getFileContents( 'tiny_mce.js' ); 234 280 235 281 // Patch loading functions … … 241 287 242 288 // Add themes 243 $content .= getFileContents( 'themes/' . $theme . '/editor_template ' . $suffix . '.js' );289 $content .= getFileContents( 'themes/' . $theme . '/editor_template.js' ); 244 290 245 291 // Add plugins 246 292 foreach ( $plugins as $plugin ) 247 $content .= getFileContents( 'plugins/' . $plugin . '/editor_plugin ' . $suffix . '.js' );293 $content .= getFileContents( 'plugins/' . $plugin . '/editor_plugin.js' ); 248 294 249 295 // Add external plugins and init … … 252 298 // Generate GZIP'd content 253 299 if ( '.gz' == $cache_ext ) { 254 header('Content-Encoding: ' . $enc);300 header('Content-Encoding: gzip'); 255 301 $content = gzencode( $content, 9, FORCE_GZIP ); 256 302 } 257 258 // Stream to client259 echo $content;260 303 261 304 // Write file … … 273 316 274 317 krsort($old_cache); 275 if ( 1 >= (int)$old_cache_max ) $del_cache = $old_cache;318 if ( 1 >= $old_cache_max ) $del_cache = $old_cache; 276 319 else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) ); 277 320 … … 281 324 282 325 putFileContents( $cache_file, $content ); 283 } 326 327 $mtime = gmdate( "D, d M Y H:i:s", filemtime($cache_file) ) . " GMT"; 328 header( 'Last-Modified: ' . $mtime ); 329 } 330 331 // Stream to client 332 header( 'Cache-Control: must-revalidate', false ); 333 header( 'Content-Length: ' . strlen($content) ); 334 echo $content; 284 335 ?>
Note: See TracChangeset
for help on using the changeset viewer.