Make WordPress Core

Ticket #3857: 3857.diff

File 3857.diff, 31.9 KB (added by Nazgul, 18 years ago)

Upgrade tinyspell to 1.0.3.1

  • wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php

     
    1 <?php
    2 
    3 /* Version 0.9, 6th April 2003 - Simon Willison ( http://simon.incutio.com/ )
    4    Manual: http://scripts.incutio.com/httpclient/
    5 */
    6 
    7 class HttpClient {
    8     // Request vars
    9     var $host;
    10     var $port;
    11     var $path;
    12     var $method;
    13     var $postdata = '';
    14     var $cookies = array();
    15     var $referer;
    16     var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
    17     var $accept_encoding = 'gzip';
    18     var $accept_language = 'en-us';
    19     var $user_agent = 'Incutio HttpClient v0.9';
    20     // Options
    21     var $timeout = 20;
    22     var $use_gzip = true;
    23     var $persist_cookies = true;  // If true, received cookies are placed in the $this->cookies array ready for the next request
    24                                   // Note: This currently ignores the cookie path (and time) completely. Time is not important,
    25                                   //       but path could possibly lead to security problems.
    26     var $persist_referers = true; // For each request, sends path of last request as referer
    27     var $debug = false;
    28     var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found
    29     var $max_redirects = 5;
    30     var $headers_only = false;    // If true, stops receiving once headers have been read.
    31     // Basic authorization variables
    32     var $username;
    33     var $password;
    34     // Response vars
    35     var $status;
    36     var $headers = array();
    37     var $content = '';
    38     var $errormsg;
    39     // Tracker variables
    40     var $redirect_count = 0;
    41     var $cookie_host = '';
    42     function HttpClient($host, $port=80) {
    43         $this->host = $host;
    44         $this->port = $port;
    45     }
    46     function get($path, $data = false) {
    47         $this->path = $path;
    48         $this->method = 'GET';
    49         if ($data) {
    50             $this->path .= '?'.$this->buildQueryString($data);
    51         }
    52         return $this->doRequest();
    53     }
    54     function post($path, $data) {
    55         $this->path = $path;
    56         $this->method = 'POST';
    57         $this->postdata = $this->buildQueryString($data);
    58         return $this->doRequest();
    59     }
    60     function buildQueryString($data) {
    61         $querystring = '';
    62         if (is_array($data)) {
    63             // Change data in to postable data
    64                 foreach ($data as $key => $val) {
    65                         if (is_array($val)) {
    66                                 foreach ($val as $val2) {
    67                                         $querystring .= urlencode($key).'='.urlencode($val2).'&';
    68                                 }
    69                         } else {
    70                                 $querystring .= urlencode($key).'='.urlencode($val).'&';
    71                         }
    72                 }
    73                 $querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
    74         } else {
    75             $querystring = $data;
    76         }
    77         return $querystring;
    78     }
    79     function doRequest() {
    80         // Performs the actual HTTP request, returning true or false depending on outcome
    81                 if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
    82                     // Set error message
    83             switch($errno) {
    84                                 case -3:
    85                                         $this->errormsg = 'Socket creation failed (-3)';
    86                                 case -4:
    87                                         $this->errormsg = 'DNS lookup failure (-4)';
    88                                 case -5:
    89                                         $this->errormsg = 'Connection refused or timed out (-5)';
    90                                 default:
    91                                         $this->errormsg = 'Connection failed ('.$errno.')';
    92                             $this->errormsg .= ' '.$errstr;
    93                             $this->debug($this->errormsg);
    94                         }
    95                         return false;
    96         }
    97         socket_set_timeout($fp, $this->timeout);
    98         $request = $this->buildRequest();
    99         $this->debug('Request', $request);
    100         fwrite($fp, $request);
    101         // Reset all the variables that should not persist between requests
    102         $this->headers = array();
    103         $this->content = '';
    104         $this->errormsg = '';
    105         // Set a couple of flags
    106         $inHeaders = true;
    107         $atStart = true;
    108         // Now start reading back the response
    109         while (!feof($fp)) {
    110             $line = fgets($fp, 4096);
    111             if ($atStart) {
    112                 // Deal with first line of returned data
    113                 $atStart = false;
    114                 if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
    115                     $this->errormsg = "Status code line invalid: ".htmlentities($line);
    116                     $this->debug($this->errormsg);
    117                     return false;
    118                 }
    119                 $http_version = $m[1]; // not used
    120                 $this->status = $m[2];
    121                 $status_string = $m[3]; // not used
    122                 $this->debug(trim($line));
    123                 continue;
    124             }
    125             if ($inHeaders) {
    126                 if (trim($line) == '') {
    127                     $inHeaders = false;
    128                     $this->debug('Received Headers', $this->headers);
    129                     if ($this->headers_only) {
    130                         break; // Skip the rest of the input
    131                     }
    132                     continue;
    133                 }
    134                 if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
    135                     // Skip to the next header
    136                     continue;
    137                 }
    138                 $key = strtolower(trim($m[1]));
    139                 $val = trim($m[2]);
    140                 // Deal with the possibility of multiple headers of same name
    141                 if (isset($this->headers[$key])) {
    142                     if (is_array($this->headers[$key])) {
    143                         $this->headers[$key][] = $val;
    144                     } else {
    145                         $this->headers[$key] = array($this->headers[$key], $val);
    146                     }
    147                 } else {
    148                     $this->headers[$key] = $val;
    149                 }
    150                 continue;
    151             }
    152             // We're not in the headers, so append the line to the contents
    153             $this->content .= $line;
    154         }
    155         fclose($fp);
    156         // If data is compressed, uncompress it
    157         if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
    158             $this->debug('Content is gzip encoded, unzipping it');
    159             $this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php
    160             $this->content = gzinflate($this->content);
    161         }
    162         // If $persist_cookies, deal with any cookies
    163         if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
    164             $cookies = $this->headers['set-cookie'];
    165             if (!is_array($cookies)) {
    166                 $cookies = array($cookies);
    167             }
    168             foreach ($cookies as $cookie) {
    169                 if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
    170                     $this->cookies[$m[1]] = $m[2];
    171                 }
    172             }
    173             // Record domain of cookies for security reasons
    174             $this->cookie_host = $this->host;
    175         }
    176         // If $persist_referers, set the referer ready for the next request
    177         if ($this->persist_referers) {
    178             $this->debug('Persisting referer: '.$this->getRequestURL());
    179             $this->referer = $this->getRequestURL();
    180         }
    181         // Finally, if handle_redirects and a redirect is sent, do that
    182         if ($this->handle_redirects) {
    183             if (++$this->redirect_count >= $this->max_redirects) {
    184                 $this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
    185                 $this->debug($this->errormsg);
    186                 $this->redirect_count = 0;
    187                 return false;
    188             }
    189             $location = isset($this->headers['location']) ? $this->headers['location'] : '';
    190             $uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
    191             if ($location || $uri) {
    192                 $url = parse_url($location.$uri);
    193                 // This will FAIL if redirect is to a different site
    194                 return $this->get($url['path']);
    195             }
    196         }
    197         return true;
    198     }
    199     function buildRequest() {
    200         $headers = array();
    201         $headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding
    202         $headers[] = "Host: {$this->host}";
    203         $headers[] = "User-Agent: {$this->user_agent}";
    204         $headers[] = "Accept: {$this->accept}";
    205         if ($this->use_gzip) {
    206             $headers[] = "Accept-encoding: {$this->accept_encoding}";
    207         }
    208         $headers[] = "Accept-language: {$this->accept_language}";
    209         if ($this->referer) {
    210             $headers[] = "Referer: {$this->referer}";
    211         }
    212         // Cookies
    213         if ($this->cookies) {
    214             $cookie = 'Cookie: ';
    215             foreach ($this->cookies as $key => $value) {
    216                 $cookie .= "$key=$value; ";
    217             }
    218             $headers[] = $cookie;
    219         }
    220         // Basic authentication
    221         if ($this->username && $this->password) {
    222             $headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
    223         }
    224         // If this is a POST, set the content type and length
    225         if ($this->postdata) {
    226             $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    227             $headers[] = 'Content-Length: '.strlen($this->postdata);
    228         }
    229         $request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
    230         return $request;
    231     }
    232     function getStatus() {
    233         return $this->status;
    234     }
    235     function getContent() {
    236         return $this->content;
    237     }
    238     function getHeaders() {
    239         return $this->headers;
    240     }
    241     function getHeader($header) {
    242         $header = strtolower($header);
    243         if (isset($this->headers[$header])) {
    244             return $this->headers[$header];
    245         } else {
    246             return false;
    247         }
    248     }
    249     function getError() {
    250         return $this->errormsg;
    251     }
    252     function getCookies() {
    253         return $this->cookies;
    254     }
    255     function getRequestURL() {
    256         $url = 'http://'.$this->host;
    257         if ($this->port != 80) {
    258             $url .= ':'.$this->port;
    259         }           
    260         $url .= $this->path;
    261         return $url;
    262     }
    263     // Setter methods
    264     function setUserAgent($string) {
    265         $this->user_agent = $string;
    266     }
    267     function setAuthorization($username, $password) {
    268         $this->username = $username;
    269         $this->password = $password;
    270     }
    271     function setCookies($array) {
    272         $this->cookies = $array;
    273     }
    274     // Option setting methods
    275     function useGzip($boolean) {
    276         $this->use_gzip = $boolean;
    277     }
    278     function setPersistCookies($boolean) {
    279         $this->persist_cookies = $boolean;
    280     }
    281     function setPersistReferers($boolean) {
    282         $this->persist_referers = $boolean;
    283     }
    284     function setHandleRedirects($boolean) {
    285         $this->handle_redirects = $boolean;
    286     }
    287     function setMaxRedirects($num) {
    288         $this->max_redirects = $num;
    289     }
    290     function setHeadersOnly($boolean) {
    291         $this->headers_only = $boolean;
    292     }
    293     function setDebug($boolean) {
    294         $this->debug = $boolean;
    295     }
    296     // "Quick" static methods
    297     function quickGet($url) {
    298         $bits = parse_url($url);
    299         $host = $bits['host'];
    300         $port = isset($bits['port']) ? $bits['port'] : 80;
    301         $path = isset($bits['path']) ? $bits['path'] : '/';
    302         if (isset($bits['query'])) {
    303             $path .= '?'.$bits['query'];
    304         }
    305         $client = new HttpClient($host, $port);
    306         if (!$client->get($path)) {
    307             return false;
    308         } else {
    309             return $client->getContent();
    310         }
    311     }
    312     function quickPost($url, $data) {
    313         $bits = parse_url($url);
    314         $host = $bits['host'];
    315         $port = isset($bits['port']) ? $bits['port'] : 80;
    316         $path = isset($bits['path']) ? $bits['path'] : '/';
    317         $client = new HttpClient($host, $port);
    318         if (!$client->post($path, $data)) {
    319             return false;
    320         } else {
    321             return $client->getContent();
    322         }
    323     }
    324     function debug($msg, $object = false) {
    325         if ($this->debug) {
    326             print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
    327             if ($object) {
    328                 ob_start();
    329                     print_r($object);
    330                     $content = htmlentities(ob_get_contents());
    331                     ob_end_clean();
    332                     print '<pre>'.$content.'</pre>';
    333                 }
    334                 print '</div>';
    335         }
    336     }   
    337 }
    338 
    339 ?>
    340  No newline at end of file
  • wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php

     
    22/* *
    33 * Tiny Spelling Interface for TinyMCE Spell Checking.
    44 *
    5  * Copyright © 2006 Moxiecode Systems AB
     5 * Copyright © 2006 Moxiecode Systems AB
    66 */
    77
    8 require_once("HttpClient.class.php");
    9 
    108class TinyGoogleSpell {
    119        var $lang;
    1210
     
    2220                $matches = $this->_getMatches($wordstr);
    2321
    2422                for ($i=0; $i<count($matches); $i++)
    25                         $words[] = substr($wordstr, $matches[$i][1], $matches[$i][2]);
     23                        $words[] = $this->unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8"));
    2624
    2725                return $words;
    2826        }
    2927
     28        function unhtmlentities($string) {
     29                $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
     30                $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
     31
     32                $trans_tbl = get_html_translation_table(HTML_ENTITIES);
     33                $trans_tbl = array_flip($trans_tbl);
     34
     35                return strtr($string, $trans_tbl);
     36        }
     37
    3038        // Returns array with suggestions or false if failed.
    3139        function getSuggestion($word) {
    3240                $sug = array();
     
    3442                $matches = $this->_getMatches($word);
    3543
    3644                if (count($matches) > 0)
    37                         $sug = explode("\t", $matches[0][4]);
     45                        $sug = explode("\t", utf8_encode($this->unhtmlentities($matches[0][4])));
    3846
    3947                return $sug;
    4048        }
    4149
     50        function _xmlChars($string) {
     51           $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
     52       
     53           foreach ($trans as $k => $v)
     54                        $trans[$k] = "&#".ord($k).";";
     55
     56           return strtr($string, $trans);
     57        }
     58
    4259        function _getMatches($word_list) {
    43                 $xml = "";
     60                $server = "www.google.com";
     61                $port = 443;
     62                $path = "/tbproxy/spell?lang=" . $this->lang . "&hl=en";
     63                $host = "www.google.com";
     64                $url = "https://" . $server;
    4465
    45                 // Setup HTTP Client
    46                 $client = new HttpClient('www.google.com');
    47                 $client->setUserAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR');
    48                 $client->setHandleRedirects(false);
    49                 $client->setDebug(false);
    50 
    5166                // Setup XML request
    52                 $xml .= '<?xml version="1.0" encoding="utf-8" ?>';
    53                 $xml .= '<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">';
    54                 $xml .= '<text>' . htmlentities($word_list) . '</text></spellrequest>';
     67                $xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $word_list . '</text></spellrequest>';
    5568
    56                 // Execute HTTP Post to Google
    57                 if (!$client->post('/tbproxy/spell?lang=' . $this->lang, $xml)) {
    58                         $this->errorMsg[] = 'An error occurred: ' . $client->getError();
    59                         return array();
     69                $header  = "POST ".$path." HTTP/1.0 \r\n";
     70                $header .= "MIME-Version: 1.0 \r\n";
     71                $header .= "Content-type: application/PTI26 \r\n";
     72                $header .= "Content-length: ".strlen($xml)." \r\n";
     73                $header .= "Content-transfer-encoding: text \r\n";
     74                $header .= "Request-number: 1 \r\n";
     75                $header .= "Document-type: Request \r\n";
     76                $header .= "Interface-Version: Test 1.4 \r\n";
     77                $header .= "Connection: close \r\n\r\n";
     78                $header .= $xml;
     79                //$this->_debugData($xml);
     80
     81                // Use raw sockets
     82                $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30);
     83                if ($fp) {
     84                        // Send request
     85                        fwrite($fp, $header);
     86
     87                        // Read response
     88                        $xml = "";
     89                        while (!feof($fp))
     90                                $xml .= fgets($fp, 128);
     91
     92                        fclose($fp);
     93                } else {
     94                        // Use curl
     95                        $ch = curl_init();
     96                        curl_setopt($ch, CURLOPT_URL,$url);
     97                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     98                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
     99                        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     100                        $xml = curl_exec($ch);
     101                        curl_close($ch);
    60102                }
    61103
     104                //$this->_debugData($xml);
     105
    62106                // Grab and parse content
    63                 $xml = $client->getContent();
    64107                preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER);
    65108
    66109                return $matches;
    67110        }
     111
     112        function _debugData($data) {
     113                $fh = @fopen("debug.log", 'a+');
     114                @fwrite($fh, $data);
     115                @fclose($fh);
     116        }
    68117}
    69118
    70119// Setup classname, should be the same as the name of the spellchecker class
  • wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php

     
    2727                $this->errorMsg = array();
    2828
    2929                $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell");
    30                 $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang;
     30
     31                if(preg_match("#win#i",php_uname()))
     32                        $this->cmd = $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang." --encoding=utf-8 -H < $this->tmpfile 2>&1";
     33                else
     34                        $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --encoding=utf-8 -H --lang=". $this->lang;
    3135        }
    3236
    3337        // Returns array with bad words or false if failed.
     
    6670
    6771        // Returns array with suggestions or false if failed.
    6872        function getSuggestion($word) {
     73                if (function_exists("mb_convert_encoding"))
     74                        $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8"));
     75                else
     76                        $word = utf8_encode($word);
     77
    6978                if ($fh = fopen($this->tmpfile, "w")) {
    7079                        fwrite($fh, "!\n");
    7180                        fwrite($fh, "^$word\n");
     
    94103                }
    95104                return $returnData;
    96105        }
     106
     107        function _debugData($data) {
     108                $fh = @fopen("debug.log", 'a+');
     109                @fwrite($fh, $data);
     110                @fclose($fh);
     111        }
    97112}
    98113
    99114// Setup classname, should be the same as the name of the spellchecker class
  • wp-includes/js/tinymce/plugins/spellchecker/css/content.css

     
    11.mceItemHiddenSpellWord {
    22        background: url('../images/wline.gif') repeat-x bottom left;
    3         bo2rder-bottom: 1px dashed red;
    43        cursor: default;
    54}
  • wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css

     
    3131        font-family: Arial, Verdana, Tahoma, Helvetica;
    3232        font-weight: bold;
    3333        font-size: 11px;
     34        background-color: #FFF;
    3435}
  • wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js

     
    11/**
    2  * $RCSfile: editor_plugin_src.js,v $
    3  * $Revision: 1.4 $
    4  * $Date: 2006/03/24 17:24:50 $
     2 * $Id: editor_plugin_src.js 177 2007-01-10 13:23:14Z spocke $
    53 *
    64 * @author Moxiecode
    75 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
    86 */
    97
    10 tinyMCE.importPluginLanguagePack('spellchecker', 'en,sv,nn,nb');
     8tinyMCE.importPluginLanguagePack('spellchecker', 'en,fr,sv,nn,nb');
    119
    1210// Plucin static class
    1311var TinyMCE_SpellCheckerPlugin = {
    1412        _contextMenu : new TinyMCE_Menu(),
    1513        _menu : new TinyMCE_Menu(),
    1614        _counter : 0,
     15        _ajaxPage : '/tinyspell.php',
    1716
    1817        getInfo : function() {
    1918                return {
    20                         longname : 'Spellchecker',
     19                        longname : 'Spellchecker PHP',
    2120                        author : 'Moxiecode Systems AB',
    2221                        authorurl : 'http://tinymce.moxiecode.com',
    2322                        infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',
    24                         version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
     23                        version : "1.0.3"
    2524                };
    2625        },
    2726
     
    4039
    4140                                        // Setup arguments
    4241                                        args += 'id=' + inst.editorId + "|" + (++self._counter);
    43                                         args += '&cmd=suggest&check=' + escape(elm.innerHTML);
     42                                        args += '&cmd=suggest&check=' + encodeURIComponent(elm.innerHTML);
    4443                                        args += '&lang=' + escape(inst.spellCheckerLang);
    4544
    4645                                        elm = inst.spellCheckerElm;
     
    5958
    6059                                        inst.selection.selectNode(elm, false, false);
    6160
    62                                         self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);
     61                                        self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args);
    6362
    6463                                        tinyMCE.cancelEvent(e);
    6564                                        return false;
     
    138137        },
    139138
    140139        setupContent : function(editor_id, body, doc) {
    141                 TinyMCE_SpellCheckerPlugin._removeWords(doc);
     140                TinyMCE_SpellCheckerPlugin._removeWords(doc, null, true);
    142141        },
    143142
    144143        getControlHTML : function(cn) {
     
    201200        },
    202201
    203202        _menuButtonEvent : function(e, o) {
     203                var t = this;
     204
     205                // Give IE some time since it's buggy!! :(
     206                window.setTimeout(function() {
     207                        t._menuButtonEvent2(e, o);
     208                }, 1);
     209        },
     210
     211        _menuButtonEvent2 : function(e, o) {
    204212                if (o.className == 'mceMenuButtonFocus')
    205213                        return;
    206214
     
    241249        },
    242250
    243251        execCommand : function(editor_id, element, command, user_interface, value) {
    244                 var inst = tinyMCE.getInstanceById(editor_id), self = TinyMCE_SpellCheckerPlugin, args = '', co, bb, mb, nl, i, e;
     252                var inst = tinyMCE.getInstanceById(editor_id), self = TinyMCE_SpellCheckerPlugin, args = '', co, bb, mb, nl, i, e, mbs;
    245253
    246254                // Handle commands
    247255                switch (command) {
     
    249257                                if (!inst.spellcheckerOn) {
    250258                                        inst.spellCheckerBookmark = inst.selection.getBookmark();
    251259
     260                                        // Fix for IE bug: #1610184
     261                                        if (tinyMCE.isRealIE)
     262                                                tinyMCE.setInnerHTML(inst.getBody(), inst.getBody().innerHTML);
     263
    252264                                        // Setup arguments
    253265                                        args += 'id=' + inst.editorId + "|" + (++self._counter);
    254                                         args += '&cmd=spell&check=' + escape(self._getWordList(inst.getBody())).replace(/%20/g, '+');
     266                                        args += '&cmd=spell&check=' + encodeURIComponent(self._getWordList(inst.getBody())).replace(/\'/g, '%27');
    255267                                        args += '&lang=' + escape(inst.spellCheckerLang);
    256268
    257269                                        co = document.getElementById(inst.editorId + '_parent').firstChild;
     
    263275                                        // Setup message box
    264276                                        mb = self._getMsgBoxLayer(inst);
    265277                                        e = mb.getElement();
    266                                         e.innerHTML = '<span>' + tinyMCE.getLang('lang_spellchecker_swait', '', true) + '</span>';
     278                                        if (e.childNodes[0])
     279                                                e.removeChild(e.childNodes[0]);
     280
     281                                        mbs = document.createElement("span");
     282                                        mbs.innerHTML = '<span>' + tinyMCE.getLang('lang_spellchecker_swait', '', true) + '</span>';
     283                                        e.appendChild(mbs);
     284
    267285                                        mb.show();
    268286                                        mb.moveRelativeTo(co, 'cc');
    269287
     
    276294                                        inst.spellcheckerOn = true;
    277295                                        tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonSelected');
    278296
    279                                         self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);
     297                                        self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args);
    280298                                } else {
    281299                                        self._removeWords(inst.getDoc());
    282300                                        inst.spellcheckerOn = false;
     
    329347        cleanup : function(type, content, inst) {
    330348                switch (type) {
    331349                        case "get_from_editor_dom":
    332                                 TinyMCE_SpellCheckerPlugin._removeWords(content);
     350                                TinyMCE_SpellCheckerPlugin._removeWords(content, null, true);
    333351                                inst.spellcheckerOn = false;
    334352                                break;
    335353                }
     
    389407                switch (cmd) {
    390408                        case "spell":
    391409                                if (xml.documentElement.firstChild) {
    392                                         self._markWords(inst.getDoc(), inst.getBody(), el.firstChild.nodeValue.split(' '));
     410                                        self._markWords(inst.getDoc(), inst.getBody(), decodeURIComponent(el.firstChild.nodeValue).split('+'));
    393411                                        inst.selection.moveToBookmark(inst.spellCheckerBookmark);
     412
     413                                        if(tinyMCE.getParam('spellchecker_report_misspellings', false))
     414                                                alert(tinyMCE.getLang('lang_spellchecker_mpell_found', '', true, {words : self._countWords(inst)}));
    394415                                } else
    395416                                        alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true));
    396417
    397418                                self._checkDone(inst);
    398419
     420                                // Odd stuff FF removed useCSS, disable state for it
     421                                inst.useCSS = false;
     422
    399423                                break;
    400424
    401425                        case "suggest":
    402                                 self._buildMenu(el.firstChild ? el.firstChild.nodeValue.split(' ') : null, 10);
     426                                self._buildMenu(el.firstChild ? decodeURIComponent(el.firstChild.nodeValue).split('+') : null, 10);
    403427                                self._contextMenu.show();
    404428                                break;
    405429                }
     
    418442                var i, x, s, nv = '', nl = tinyMCE.getNodeTree(n, new Array(), 3), wl = new Array();
    419443                var re = TinyMCE_SpellCheckerPlugin._getWordSeparators();
    420444
    421                 for (i=0; i<nl.length; i++)
    422                         nv += nl[i].nodeValue + " ";
     445                for (i=0; i<nl.length; i++) {
     446                        if (!new RegExp('/SCRIPT|STYLE/').test(nl[i].parentNode.nodeName))
     447                                nv += nl[i].nodeValue + " ";
     448                }
    423449
    424450                nv = nv.replace(new RegExp('([0-9]|[' + re + '])', 'g'), ' ');
    425451                nv = tinyMCE.trim(nv.replace(/(\s+)/g, ' '));
     
    434460                                }
    435461                        }
    436462
    437                         if (!s)
     463                        if (!s && nl[i].length > 0)
    438464                                wl[wl.length] = nl[i];
    439465                }
    440466
    441467                return wl.join(' ');
    442468        },
    443469
    444         _removeWords : function(doc, word) {
     470        _removeWords : function(doc, word, cleanup) {
    445471                var i, c, nl = doc.getElementsByTagName("span");
    446472                var self = TinyMCE_SpellCheckerPlugin;
    447473                var inst = tinyMCE.selectedInstance, b = inst ? inst.selection.getBookmark() : null;
     
    455481                                self._removeWord(nl[i]);
    456482                }
    457483
    458                 if (b)
     484                if (b && !cleanup)
    459485                        inst.selection.moveToBookmark(b);
    460486        },
    461487
    462488        _checkDone : function(inst) {
    463                 var i, w = 0, nl = inst.getDoc().getElementsByTagName("span")
    464489                var self = TinyMCE_SpellCheckerPlugin;
     490                var w = self._countWords(inst);
    465491
     492                if (w == 0) {
     493                        self._removeWords(inst.getDoc());
     494                        inst.spellcheckerOn = false;
     495                        tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton');
     496                }
     497        },
     498
     499        _countWords : function(inst) {
     500                var i, w = 0, nl = inst.getDoc().getElementsByTagName("span"), c;
     501                var self = TinyMCE_SpellCheckerPlugin;
     502
    466503                for (i=nl.length-1; i>=0; i--) {
    467504                        c = tinyMCE.getAttrib(nl[i], 'class');
    468505
     
    470507                                w++;
    471508                }
    472509
    473                 if (w == 0) {
    474                         self._removeWords(inst.getDoc());
    475                         inst.spellcheckerOn = false;
    476                         tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton');
    477                 }
     510                return w;
    478511        },
    479512
    480513        _removeWord : function(e) {
    481                 tinyMCE.setOuterHTML(e, e.innerHTML);
     514                if (e != null)
     515                        tinyMCE.setOuterHTML(e, e.innerHTML);
    482516        },
    483517
    484518        _markWords : function(doc, n, wl) {
     
    486520                var r1, r2, r3, r4, r5, w = '';
    487521                var re = TinyMCE_SpellCheckerPlugin._getWordSeparators();
    488522
    489                 for (i=0; i<wl.length; i++)
    490                         w += wl[i] + ((i == wl.length-1) ? '' : '|');
     523                for (i=0; i<wl.length; i++) {
     524                        if (wl[i].length > 0)
     525                                w += wl[i] + ((i == wl.length-1) ? '' : '|');
     526                }
    491527
    492                 r1 = new RegExp('([' + re + '])(' + w + ')([' + re + '])', 'g');
    493                 r2 = new RegExp('^(' + w + ')', 'g');
    494                 r3 = new RegExp('(' + w + ')([' + re + ']?)$', 'g');
    495                 r4 = new RegExp('^(' + w + ')([' + re + ']?)$', 'g');
    496                 r5 = new RegExp('(' + w + ')([' + re + '])', 'g');
    497 
    498528                for (i=0; i<nl.length; i++) {
    499529                        nv = nl[i].nodeValue;
     530                        r1 = new RegExp('([' + re + '])(' + w + ')([' + re + '])', 'g');
     531                        r2 = new RegExp('^(' + w + ')', 'g');
     532                        r3 = new RegExp('(' + w + ')([' + re + ']?)$', 'g');
     533                        r4 = new RegExp('^(' + w + ')([' + re + ']?)$', 'g');
     534                        r5 = new RegExp('(' + w + ')([' + re + '])', 'g');
     535
    500536                        if (r1.test(nv) || r2.test(nv) || r3.test(nv) || r4.test(nv)) {
    501537                                nv = tinyMCE.xmlEncode(nv);
    502538                                nv = nv.replace(r5, '<span class="mceItemHiddenSpellWord">$1</span>$2');
     
    524560                                cm.addItem(sg[i], 'tinyMCE.execCommand("mceSpellCheckReplace",false,"' + sg[i] + '");');
    525561
    526562                        cm.addSeparator();
    527                         cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnore\');');
    528                         cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');');
    529563                } else
    530564                        cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug', '', true));
    531565
     566                cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnore\');');
     567                cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');');
     568
    532569                cm.update();
    533570        },
    534571
  • wp-includes/js/tinymce/plugins/spellchecker/langs/en.js

     
    1010        swait : 'Spellchecking, please wait...',
    1111        sug : 'Suggestions',
    1212        no_sug : 'No suggestions',
    13         no_mpell : 'No misspellings found.'
     13        no_mpell : 'No misspellings found.',
     14        mpell_found : 'Found {$words} misspellings.'
    1415});
  • wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php

     
    55 * $Date: 2006/03/14 17:33:47 $
    66 *
    77 * @author Moxiecode
    8  * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     8 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
    99 */
    1010
     11        // Ignore the Notice errors for now.
     12        error_reporting(E_ALL ^ E_NOTICE);
     13
    1114        require_once("config.php");
    1215
    1316        $id = sanitize($_POST['id'], "loose");
     
    3033
    3134        // Get input parameters.
    3235
    33         $check = $_POST['check'];
    34         $cmd = sanitize($_POST['cmd']);
    35         $lang = sanitize($_POST['lang'], "strict");
    36         $mode = sanitize($_POST['mode'], "strict");
    37         $spelling = sanitize($_POST['spelling'], "strict");
    38         $jargon = sanitize($_POST['jargon'], "strict");
    39         $encoding = sanitize($_POST['encoding'], "strict");
    40         $sg = sanitize($_POST['sg'], "bool");
     36        $check = urldecode($_REQUEST['check']);
     37        $cmd = sanitize($_REQUEST['cmd']);
     38        $lang = sanitize($_REQUEST['lang'], "strict");
     39        $mode = sanitize($_REQUEST['mode'], "strict");
     40        $spelling = sanitize($_REQUEST['spelling'], "strict");
     41        $jargon = sanitize($_REQUEST['jargon'], "strict");
     42        $encoding = sanitize($_REQUEST['encoding'], "strict");
     43        $sg = sanitize($_REQUEST['sg'], "bool");
    4144        $words = array();
    4245
    4346        $validRequest = true;
     
    109112        switch($outputType) {
    110113                case "xml":
    111114                        header('Content-type: text/xml; charset=utf-8');
    112                         echo '<?xml version="1.0" encoding="utf-8" ?>';
    113                         echo "\n";
     115                        $body  = '<?xml version="1.0" encoding="utf-8" ?>';
     116                        $body .= "\n";
     117
    114118                        if (count($result) == 0)
    115                                 echo '<res id="' . $id . '" cmd="'. $cmd .'" />';
     119                                $body .= '<res id="' . $id . '" cmd="'. $cmd .'" />';
    116120                        else
    117                                 echo '<res id="' . $id . '" cmd="'. $cmd .'">'. utf8_encode(implode(" ", $result)) .'</res>';
     121                                $body .= '<res id="' . $id . '" cmd="'. $cmd .'">'. urlencode(implode(" ", $result)) .'</res>';
    118122
     123                        echo $body;
    119124                break;
    120125                case "xmlerror";
    121126                        header('Content-type: text/xml; charset=utf-8');
    122                         echo '<?xml version="1.0" encoding="utf-8" ?>';
    123                         echo "\n";
    124                         echo '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. implode(" ", $tinyspell->errorMsg) .'" />';
     127                        $body  = '<?xml version="1.0" encoding="utf-8" ?>';
     128                        $body .= "\n";
     129                        $body .= '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. implode(" ", $tinyspell->errorMsg) .'" />';
     130                        echo $body;
    125131                break;
    126132                case "html":
    127133                        var_dump($result);