Ticket #1485061: tinypatch.diff

File tinypatch.diff, 14.8 kB (added by Javer, 6 months ago)
  • program/js/editor.js

    diff -urN .roundcube.1379/program/js/editor.js .roundcube.new/program/js/editor.js
    old new  
    1515 
    1616// Initialize the message editor 
    1717 
    18 function rcmail_editor_init(skin_path, editor_lang) 
     18function rcmail_editor_init_gzip(editor_lang) 
    1919  { 
     20  tinyMCE_GZ.init({ plugins : "emotions,media,nonbreaking,table,searchreplace,visualchars,directionality", 
     21                    themes : "advanced", 
     22                    languages : editor_lang, 
     23                    disk_cache : true, 
     24                    debug : false 
     25                  }); 
     26  } 
     27 
     28function rcmail_editor_init(skin_path, editor_lang, compact) 
     29  { 
     30  var buttons1 = "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,link,unlink,emotions,charmap,code,forecolor,backcolor,fontselect,fontsizeselect, separator,undo,redo,image,media,ltr,rtl"; 
     31  var buttons2 = ""; 
     32  if(compact) 
     33    { 
     34    buttons1 = "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr"; 
     35    buttons2 = "link,unlink,code,forecolor,fontselect,fontsizeselect"; 
     36    } 
    2037  tinyMCE.init({ mode : "textareas", 
    2138                 editor_selector : "mce_editor", 
    2239                 accessibility_focus : false, 
     
    2441                 theme : "advanced", 
    2542                 language : editor_lang, 
    2643                 plugins : "emotions,media,nonbreaking,table,searchreplace,visualchars,directionality", 
    27                  theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,link,unlink,emotions,charmap,code,forecolor,backcolor,fontselect,fontsizeselect, separator,undo,redo,image,media,ltr,rtl", 
    28                  theme_advanced_buttons2 : "", 
     44                 theme_advanced_buttons1 : buttons1, 
     45                 theme_advanced_buttons2 : buttons2, 
    2946                 theme_advanced_buttons3 : "", 
    3047                 theme_advanced_toolbar_location : "top", 
    3148                 theme_advanced_toolbar_align : "left", 
  • program/js/tiny_mce/tiny_mce_gzip.js

    diff -urN .roundcube.1379/program/js/tiny_mce/tiny_mce_gzip.js .roundcube.new/program/js/tiny_mce/tiny_mce_gzip.js
    old new  
     1var tinyMCE_GZ = { 
     2        settings : { 
     3                themes : '', 
     4                plugins : '', 
     5                languages : '', 
     6                disk_cache : true, 
     7                page_name : 'tiny_mce_gzip.php', 
     8                debug : false, 
     9                suffix : '' 
     10        }, 
     11 
     12        init : function(s, cb, sc) { 
     13                var t = this, n, i, nl = document.getElementsByTagName('script'); 
     14 
     15                for (n in s) 
     16                        t.settings[n] = s[n]; 
     17 
     18                s = t.settings; 
     19 
     20                for (i=0; i<nl.length; i++) { 
     21                        n = nl[i]; 
     22 
     23                        if (n.src && n.src.indexOf('tiny_mce') != -1) 
     24                                t.baseURL = n.src.substring(0, n.src.lastIndexOf('/')); 
     25                } 
     26 
     27                if (!t.coreLoaded) 
     28                        t.loadScripts(1, s.themes, s.plugins, s.languages, cb, sc); 
     29        }, 
     30 
     31        loadScripts : function(co, th, pl, la, cb, sc) { 
     32                var t = this, x, w = window, q, c = 0, ti, s = t.settings; 
     33 
     34                function get(s) { 
     35                        x = 0; 
     36 
     37                        try { 
     38                                x = new ActiveXObject(s); 
     39                        } catch (s) { 
     40                        } 
     41 
     42                        return x; 
     43                }; 
     44 
     45                // Build query string 
     46                q = 'js=true&diskcache=' + (s.disk_cache ? 'true' : 'false') + '&core=' + (co ? 'true' : 'false') + '&suffix=' + escape(s.suffix) + '&themes=' + escape(th) + '&plugins=' + escape(pl) + '&languages=' + escape(la); 
     47 
     48                if (co) 
     49                        t.coreLoaded = 1; 
     50 
     51                // Send request 
     52                x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Msxml2.XMLHTTP') || get('Microsoft.XMLHTTP'); 
     53                x.overrideMimeType && x.overrideMimeType('text/javascript'); 
     54                x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, !!cb); 
     55//              x.setRequestHeader('Content-Type', 'text/javascript'); 
     56                x.send(''); 
     57 
     58                // Handle asyncronous loading 
     59                if (cb) { 
     60                        // Wait for response 
     61                        ti = w.setInterval(function() { 
     62                                if (x.readyState == 4 || c++ > 10000) { 
     63                                        w.clearInterval(ti); 
     64 
     65                                        if (c < 10000 && x.status == 200) { 
     66                                                t.loaded = 1; 
     67                                                t.eval(x.responseText); 
     68                                                tinymce.dom.Event.domLoaded = true; 
     69                                                cb.call(sc || t, x); 
     70                                        } 
     71 
     72                                        ti = x = null; 
     73                                } 
     74                        }, 10); 
     75                } else 
     76                        t.eval(x.responseText); 
     77        }, 
     78 
     79        start : function() { 
     80                var t = this, each = tinymce.each, s = t.settings, sl, ln = s.languages.split(','); 
     81 
     82                tinymce.suffix = s.suffix; 
     83 
     84                // Extend script loader 
     85                tinymce.create('tinymce.compressor.ScriptLoader:tinymce.dom.ScriptLoader', { 
     86                        loadScripts : function(sc, cb, s) { 
     87                                var ti = this, th = [], pl = [], la = []; 
     88 
     89                                each(sc, function(o) { 
     90                                        var u = o.url; 
     91 
     92                                        if ((!ti.lookup[u] || ti.lookup[u].state != 2) && u.indexOf(t.baseURL) === 0) { 
     93                                                // Collect theme 
     94                                                if (u.indexOf('editor_template') != -1) { 
     95                                                        th.push(/\/themes\/([^\/]+)/.exec(u)[1]); 
     96                                                        load(u, 1); 
     97                                                } 
     98 
     99                                                // Collect plugin 
     100                                                if (u.indexOf('editor_plugin') != -1) { 
     101                                                        pl.push(/\/plugins\/([^\/]+)/.exec(u)[1]); 
     102                                                        load(u, 1); 
     103                                                } 
     104 
     105                                                // Collect language 
     106                                                if (u.indexOf('/langs/') != -1) { 
     107                                                        la.push(/\/langs\/([^.]+)/.exec(u)[1]); 
     108                                                        load(u, 1); 
     109                                                } 
     110                                        } 
     111                                }); 
     112 
     113                                if (th.length + pl.length + la.length > 0) { 
     114                                        if (sl.settings.strict_mode) { 
     115                                                // Async 
     116                                                t.loadScripts(0, th.join(','), pl.join(','), la.join(','), cb, s); 
     117                                                return; 
     118                                        } else 
     119                                                t.loadScripts(0, th.join(','), pl.join(','), la.join(','), cb, s); 
     120                                } 
     121 
     122                                return ti.parent(sc, cb, s); 
     123                        } 
     124                }); 
     125 
     126                sl = tinymce.ScriptLoader = new tinymce.compressor.ScriptLoader(); 
     127 
     128                function load(u, sp) { 
     129                        var o; 
     130 
     131                        if (!sp) 
     132                                u = t.baseURL + u; 
     133 
     134                        o = {url : u, state : 2}; 
     135                        sl.queue.push(o); 
     136                        sl.lookup[o.url] = o; 
     137                }; 
     138 
     139                // Add core languages 
     140                each (ln, function(c) { 
     141                        if (c) 
     142                                load('/langs/' + c + '.js'); 
     143                }); 
     144 
     145                // Add themes with languages 
     146                each(s.themes.split(','), function(n) { 
     147                        if (n) { 
     148                                load('/themes/' + n + '/editor_template' + s.suffix + '.js'); 
     149 
     150                                each (ln, function(c) { 
     151                                        if (c) 
     152                                                load('/themes/' + n + '/langs/' + c + '.js'); 
     153                                }); 
     154                        } 
     155                }); 
     156 
     157                // Add plugins with languages 
     158                each(s.plugins.split(','), function(n) { 
     159                        if (n) { 
     160                                load('/plugins/' + n + '/editor_plugin' + s.suffix + '.js'); 
     161 
     162                                each (ln, function(c) { 
     163                                        if (c) 
     164                                                load('/plugins/' + n + '/langs/' + c + '.js'); 
     165                                }); 
     166                        } 
     167                }); 
     168        }, 
     169 
     170        end : function() { 
     171        }, 
     172 
     173        eval : function(co) { 
     174                var w = window; 
     175 
     176                // Evaluate script 
     177                if (!w.execScript) { 
     178                        if (/Gecko/.test(navigator.userAgent)) 
     179                                eval(co, w); // Firefox 3.0 
     180                        else 
     181                                eval.call(w, co); 
     182                } else 
     183                        w.execScript(co); // IE 
     184        } 
     185}; 
  • program/js/tiny_mce/tiny_mce_gzip.php

    diff -urN .roundcube.1379/program/js/tiny_mce/tiny_mce_gzip.php .roundcube.new/program/js/tiny_mce/tiny_mce_gzip.php
    old new  
     1<?php 
     2/** 
     3 * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $ 
     4 * 
     5 * @author Moxiecode 
     6 * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved. 
     7 * 
     8 * This file compresses the TinyMCE JavaScript using GZip and 
     9 * enables the browser to do two requests instead of one for each .js file. 
     10 * Notice: This script defaults the button_tile_map option to true for extra performance. 
     11 */ 
     12 
     13        // Set the error reporting to minimal. 
     14        @error_reporting(E_ERROR | E_WARNING | E_PARSE); 
     15 
     16        // Get input 
     17        $plugins = explode(',', getParam("plugins", "")); 
     18        $languages = explode(',', getParam("languages", "")); 
     19        $themes = explode(',', getParam("themes", "")); 
     20        $diskCache = getParam("diskcache", "") == "true"; 
     21        $isJS = getParam("js", "") == "true"; 
     22        $compress = getParam("compress", "true") == "true"; 
     23        $core = getParam("core", "true") == "true"; 
     24        $suffix = getParam("suffix", "_src") == "_src" ? "_src" : ""; 
     25        $cachePath = realpath("./../../../cache"); // Cache path, this is where the .gz files will be stored 
     26        $expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache 
     27        $content = ""; 
     28        $encodings = array(); 
     29        $supportsGzip = false; 
     30        $enc = ""; 
     31        $cacheKey = ""; 
     32 
     33        // Custom extra javascripts to pack 
     34        $custom = array(/* 
     35                "some custom .js file", 
     36                "some custom .js file" 
     37        */); 
     38 
     39        // Headers 
     40        header("Content-type: text/javascript"); 
     41        header("Vary: Accept-Encoding");  // Handle proxies 
     42        header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); 
     43 
     44        // Is called directly then auto init with default settings 
     45        if (!$isJS) { 
     46                echo getFileContents("tiny_mce_gzip.js"); 
     47                echo "tinyMCE_GZ.init({});"; 
     48                die(); 
     49        } 
     50 
     51        // Setup cache info 
     52        if ($diskCache) { 
     53                if (!$cachePath) 
     54                        die("alert('Real path failed.');"); 
     55 
     56                $cacheKey = getParam("plugins", "") . getParam("languages", "") . getParam("themes", "") . $suffix; 
     57 
     58                foreach ($custom as $file) 
     59                        $cacheKey .= $file; 
     60 
     61                $cacheKey = md5($cacheKey); 
     62 
     63                if ($compress) 
     64                        $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".gz"; 
     65                else 
     66                        $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".js"; 
     67        } 
     68 
     69        // Check if it supports gzip 
     70        if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) 
     71                $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))); 
     72 
     73        if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) { 
     74                $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip"; 
     75                $supportsGzip = true; 
     76        } 
     77 
     78        // Use cached file disk cache 
     79        if ($diskCache && $supportsGzip && file_exists($cacheFile)) { 
     80                if ($compress) 
     81                        header("Content-Encoding: " . $enc); 
     82 
     83                echo getFileContents($cacheFile); 
     84                die(); 
     85        } 
     86 
     87        // Add core 
     88        if ($core == "true") { 
     89                $content .= getFileContents("tiny_mce" . $suffix . ".js"); 
     90 
     91                // Patch loading functions 
     92                $content .= "tinyMCE_GZ.start();"; 
     93        } 
     94 
     95        // Add core languages 
     96        foreach ($languages as $lang) 
     97                $content .= getFileContents("langs/" . $lang . ".js"); 
     98 
     99        // Add themes 
     100        foreach ($themes as $theme) { 
     101                $content .= getFileContents( "themes/" . $theme . "/editor_template" . $suffix . ".js"); 
     102 
     103                foreach ($languages as $lang) 
     104                        $content .= getFileContents("themes/" . $theme . "/langs/" . $lang . ".js"); 
     105        } 
     106 
     107        // Add plugins 
     108        foreach ($plugins as $plugin) { 
     109                $content .= getFileContents("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 
     110 
     111                foreach ($languages as $lang) 
     112                        $content .= getFileContents("plugins/" . $plugin . "/langs/" . $lang . ".js"); 
     113        } 
     114 
     115        // Add custom files 
     116        foreach ($custom as $file) 
     117                $content .= getFileContents($file); 
     118 
     119        // Restore loading functions 
     120        if ($core == "true") 
     121                $content .= "tinyMCE_GZ.end();"; 
     122 
     123        // Generate GZIP'd content 
     124        if ($supportsGzip) { 
     125                if ($compress) { 
     126                        header("Content-Encoding: " . $enc); 
     127                        $cacheData = gzencode($content, 9, FORCE_GZIP); 
     128                } else 
     129                        $cacheData = $content; 
     130 
     131                // Write gz file 
     132                if ($diskCache && $cacheKey != "") 
     133                        putFileContents($cacheFile, $cacheData); 
     134 
     135                // Stream to client 
     136                echo $cacheData; 
     137        } else { 
     138                // Stream uncompressed content 
     139                echo $content; 
     140        } 
     141 
     142        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
     143 
     144        function getParam($name, $def = false) { 
     145                if (!isset($_GET[$name])) 
     146                        return $def; 
     147 
     148                return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]); // Remove anything but 0-9,a-z,-_ 
     149        } 
     150 
     151        function getFileContents($path) { 
     152                $path = realpath($path); 
     153 
     154                if (!$path || !@is_file($path)) 
     155                        return ""; 
     156 
     157                if (function_exists("file_get_contents")) 
     158                        return @file_get_contents($path); 
     159 
     160                $content = ""; 
     161                $fp = @fopen($path, "r"); 
     162                if (!$fp) 
     163                        return ""; 
     164 
     165                while (!feof($fp)) 
     166                        $content .= fgets($fp); 
     167 
     168                fclose($fp); 
     169 
     170                return $content; 
     171        } 
     172 
     173        function putFileContents($path, $content) { 
     174                if (function_exists("file_put_contents")) 
     175                        return @file_put_contents($path, $content); 
     176 
     177                $fp = @fopen($path, "wb"); 
     178                if ($fp) { 
     179                        fwrite($fp, $content); 
     180                        fclose($fp); 
     181                } 
     182        } 
     183?> 
  • program/steps/mail/compose.inc

    diff -urN .roundcube.1379/program/steps/mail/compose.inc .roundcube.new/program/steps/mail/compose.inc
    old new  
    416416    $tinylang = 'en';  
    417417    }  
    418418 
    419   $OUTPUT->include_script('tiny_mce/tiny_mce.js'); 
     419  $OUTPUT->include_script('tiny_mce/tiny_mce_gzip.js'); 
    420420  $OUTPUT->include_script("editor.js"); 
    421   $OUTPUT->add_script('rcmail_editor_init("$__skin_path", "'.$tinylang.'");'); 
     421  $OUTPUT->add_script('rcmail_editor_init_gzip("'.$tinylang.'");'); 
     422  $OUTPUT->add_script('rcmail_editor_init("$__skin_path", "'.$tinylang.'", false);'); 
    422423 
    423424  $out = $form_start ? "$form_start\n" : ''; 
    424425 
  • program/steps/settings/edit_identity.inc

    diff -urN .roundcube.1379/program/steps/settings/edit_identity.inc .roundcube.new/program/steps/settings/edit_identity.inc
    old new  
    4545      $tinylang = 'en'; 
    4646    } 
    4747 
    48   $OUTPUT->include_script('tiny_mce/tiny_mce.js'); 
    49   $OUTPUT->add_script("tinyMCE.init({ mode : 'textareas'," . 
    50                                     "editor_selector : 'mce_editor'," . 
    51                                     "apply_source_formatting : true," . 
    52                                     "language : '$tinylang'," . 
    53                                     "content_css : '\$__skin_path' + '/editor_content.css'," . 
    54                                     "theme : 'advanced'," . 
    55                                     "theme_advanced_toolbar_location : 'top'," . 
    56                                     "theme_advanced_toolbar_align : 'left'," . 
    57                                     "theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," . 
    58                                     "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," . 
    59                                     "theme_advanced_buttons3 : '' });"); 
     48  $OUTPUT->include_script('tiny_mce/tiny_mce_gzip.js'); 
     49  $OUTPUT->include_script("editor.js"); 
     50  $OUTPUT->add_script('rcmail_editor_init_gzip("'.$tinylang.'");'); 
     51  $OUTPUT->add_script('rcmail_editor_init("$__skin_path", "'.$tinylang.'", true);'); 
    6052 
    6153  if (!$IDENTITY_RECORD && $RCMAIL->action != 'add-identity') 
    6254    return rcube_label('notfound');