Make WordPress Core


Ignore:
Timestamp:
02/09/2008 06:43:15 AM (19 years ago)
Author:
ryan
Message:

gettext for tinymce strings. Props azaozz. see #5769

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/tinymce/tiny_mce_gzip.php

    r6726 r6765  
    11<?php
    2 /**
     2/** Based on:
    33 * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
    44 *
    … …  
    1111 */
    1212
    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().
     14cache_javascript_headers();
    2115
    2216if ( isset($_GET['load']) ) {
    2317
    24     function getParam( $name, $def = false ) {
     18        function getParam( $name, $def = false ) {
    2519                if ( ! isset($_GET[$name]) )
    2620                        return $def;
    … …  
    3226                $path = realpath($path);
    3327
    34                 if ( !$path || !@is_file($path) )
     28                if ( ! $path || !@is_file($path) )
    3529                        return '';
    3630
    … …  
    5347        function putFileContents( $path, $content ) {
    5448                if ( function_exists('file_put_contents') )
    55                         return @file_put_contents($path, $content);
     49                        return @file_put_contents( $path, $content );
    5650
    5751                $fp = @fopen($path, 'wb');
    … …  
    6256        }
    6357
    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
    6664        $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' : '';
    7465        $cachePath = realpath('.'); // Cache path, this is where the .gz files will be stored
    7566
    76         $content = '';
    7767        $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 = '';
    9871
    9972        // Custom extra javascripts to pack
    … …  
    10477        */);
    10578
    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
    11480        if ( $diskCache ) {
    11581                if ( ! $cachePath )
    … …  
    13096
    13197        // 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') ) {
    136102                $enc = in_array( 'x-gzip', $encodings ) ? 'x-gzip' : 'gzip';
    137103                $supportsGzip = true;
    … …  
    143109                        header('Content-Encoding: ' . $enc);
    144110
    145                 echo getFileContents($cacheFile);
     111                echo getFileContents( $cacheFile );
    146112                die();
    147113        }
    … …  
    149115        // Add core
    150116        if ( $core == 'true' ) {
    151                 $content .= getFileContents('tiny_mce' . $suffix . '.js');
     117                $content .= getFileContents( 'tiny_mce' . $suffix . '.js' );
    152118
    153119                // Patch loading functions
    … …  
    155121        }
    156122
    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;
    166126
    167127        // 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       
    181131        // 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' );
    194134
    195135        // Add custom files
    … …  
    210150
    211151                // Write gz file
    212                 if ( $diskCache && $cacheKey != '' )
     152                if ( $diskCache && '' != $cacheKey )
    213153                        putFileContents( $cacheFile, $cacheData );
    214154
    … …  
    237177        },
    238178
    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 || '';
    251192
    252193                for (i=0; i<nl.length; i++) {
    … …  
    256197                                t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
    257198                }
    258         tinyMCEPreInit.base = t.baseURL;
    259 
     199                tinyMCEPreInit.base = t.baseURL;
     200               
    260201                if (!t.coreLoaded)
    261202                        t.loadScripts(1, s.themes, s.plugins, s.languages);
    … …  
    282223                        t.coreLoaded = 1;
    283224
    284     // Easier to debug with this...
    285225        //      document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + t.baseURL + '/' + s.page_name + '?' + q + '"></script>');
    286226
Note: See TracChangeset for help on using the changeset viewer.