Ticket #3857: 3857.diff
File 3857.diff, 31.9 KB (added by , 18 years ago) |
---|
-
wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php
1 <?php2 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 vars9 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 // Options21 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 request24 // 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 referer27 var $debug = false;28 var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found29 var $max_redirects = 5;30 var $headers_only = false; // If true, stops receiving once headers have been read.31 // Basic authorization variables32 var $username;33 var $password;34 // Response vars35 var $status;36 var $headers = array();37 var $content = '';38 var $errormsg;39 // Tracker variables40 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 data64 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 outcome81 if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {82 // Set error message83 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 requests102 $this->headers = array();103 $this->content = '';104 $this->errormsg = '';105 // Set a couple of flags106 $inHeaders = true;107 $atStart = true;108 // Now start reading back the response109 while (!feof($fp)) {110 $line = fgets($fp, 4096);111 if ($atStart) {112 // Deal with first line of returned data113 $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 used120 $this->status = $m[2];121 $status_string = $m[3]; // not used122 $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 input131 }132 continue;133 }134 if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {135 // Skip to the next header136 continue;137 }138 $key = strtolower(trim($m[1]));139 $val = trim($m[2]);140 // Deal with the possibility of multiple headers of same name141 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 contents153 $this->content .= $line;154 }155 fclose($fp);156 // If data is compressed, uncompress it157 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.php160 $this->content = gzinflate($this->content);161 }162 // If $persist_cookies, deal with any cookies163 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 reasons174 $this->cookie_host = $this->host;175 }176 // If $persist_referers, set the referer ready for the next request177 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 that182 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 site194 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" encoding202 $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 // Cookies213 if ($this->cookies) {214 $cookie = 'Cookie: ';215 foreach ($this->cookies as $key => $value) {216 $cookie .= "$key=$value; ";217 }218 $headers[] = $cookie;219 }220 // Basic authentication221 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 length225 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 methods264 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 methods275 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 methods297 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
2 2 /* * 3 3 * Tiny Spelling Interface for TinyMCE Spell Checking. 4 4 * 5 * Copyright © 2006 Moxiecode Systems AB5 * Copyright © 2006 Moxiecode Systems AB 6 6 */ 7 7 8 require_once("HttpClient.class.php");9 10 8 class TinyGoogleSpell { 11 9 var $lang; 12 10 … … 22 20 $matches = $this->_getMatches($wordstr); 23 21 24 22 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")); 26 24 27 25 return $words; 28 26 } 29 27 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 30 38 // Returns array with suggestions or false if failed. 31 39 function getSuggestion($word) { 32 40 $sug = array(); … … 34 42 $matches = $this->_getMatches($word); 35 43 36 44 if (count($matches) > 0) 37 $sug = explode("\t", $matches[0][4]);45 $sug = explode("\t", utf8_encode($this->unhtmlentities($matches[0][4]))); 38 46 39 47 return $sug; 40 48 } 41 49 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 42 59 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; 44 65 45 // Setup HTTP Client46 $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 51 66 // 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>'; 55 68 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); 60 102 } 61 103 104 //$this->_debugData($xml); 105 62 106 // Grab and parse content 63 $xml = $client->getContent();64 107 preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); 65 108 66 109 return $matches; 67 110 } 111 112 function _debugData($data) { 113 $fh = @fopen("debug.log", 'a+'); 114 @fwrite($fh, $data); 115 @fclose($fh); 116 } 68 117 } 69 118 70 119 // Setup classname, should be the same as the name of the spellchecker class -
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php
27 27 $this->errorMsg = array(); 28 28 29 29 $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; 31 35 } 32 36 33 37 // Returns array with bad words or false if failed. … … 66 70 67 71 // Returns array with suggestions or false if failed. 68 72 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 69 78 if ($fh = fopen($this->tmpfile, "w")) { 70 79 fwrite($fh, "!\n"); 71 80 fwrite($fh, "^$word\n"); … … 94 103 } 95 104 return $returnData; 96 105 } 106 107 function _debugData($data) { 108 $fh = @fopen("debug.log", 'a+'); 109 @fwrite($fh, $data); 110 @fclose($fh); 111 } 97 112 } 98 113 99 114 // Setup classname, should be the same as the name of the spellchecker class -
wp-includes/js/tinymce/plugins/spellchecker/css/content.css
1 1 .mceItemHiddenSpellWord { 2 2 background: url('../images/wline.gif') repeat-x bottom left; 3 bo2rder-bottom: 1px dashed red;4 3 cursor: default; 5 4 } -
wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css
31 31 font-family: Arial, Verdana, Tahoma, Helvetica; 32 32 font-weight: bold; 33 33 font-size: 11px; 34 background-color: #FFF; 34 35 } -
wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js
1 1 /** 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 $ 5 3 * 6 4 * @author Moxiecode 7 5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 8 6 */ 9 7 10 tinyMCE.importPluginLanguagePack('spellchecker', 'en, sv,nn,nb');8 tinyMCE.importPluginLanguagePack('spellchecker', 'en,fr,sv,nn,nb'); 11 9 12 10 // Plucin static class 13 11 var TinyMCE_SpellCheckerPlugin = { 14 12 _contextMenu : new TinyMCE_Menu(), 15 13 _menu : new TinyMCE_Menu(), 16 14 _counter : 0, 15 _ajaxPage : '/tinyspell.php', 17 16 18 17 getInfo : function() { 19 18 return { 20 longname : 'Spellchecker ',19 longname : 'Spellchecker PHP', 21 20 author : 'Moxiecode Systems AB', 22 21 authorurl : 'http://tinymce.moxiecode.com', 23 22 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html', 24 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion23 version : "1.0.3" 25 24 }; 26 25 }, 27 26 … … 40 39 41 40 // Setup arguments 42 41 args += 'id=' + inst.editorId + "|" + (++self._counter); 43 args += '&cmd=suggest&check=' + e scape(elm.innerHTML);42 args += '&cmd=suggest&check=' + encodeURIComponent(elm.innerHTML); 44 43 args += '&lang=' + escape(inst.spellCheckerLang); 45 44 46 45 elm = inst.spellCheckerElm; … … 59 58 60 59 inst.selection.selectNode(elm, false, false); 61 60 62 self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);61 self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args); 63 62 64 63 tinyMCE.cancelEvent(e); 65 64 return false; … … 138 137 }, 139 138 140 139 setupContent : function(editor_id, body, doc) { 141 TinyMCE_SpellCheckerPlugin._removeWords(doc );140 TinyMCE_SpellCheckerPlugin._removeWords(doc, null, true); 142 141 }, 143 142 144 143 getControlHTML : function(cn) { … … 201 200 }, 202 201 203 202 _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) { 204 212 if (o.className == 'mceMenuButtonFocus') 205 213 return; 206 214 … … 241 249 }, 242 250 243 251 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; 245 253 246 254 // Handle commands 247 255 switch (command) { … … 249 257 if (!inst.spellcheckerOn) { 250 258 inst.spellCheckerBookmark = inst.selection.getBookmark(); 251 259 260 // Fix for IE bug: #1610184 261 if (tinyMCE.isRealIE) 262 tinyMCE.setInnerHTML(inst.getBody(), inst.getBody().innerHTML); 263 252 264 // Setup arguments 253 265 args += 'id=' + inst.editorId + "|" + (++self._counter); 254 args += '&cmd=spell&check=' + e scape(self._getWordList(inst.getBody())).replace(/%20/g, '+');266 args += '&cmd=spell&check=' + encodeURIComponent(self._getWordList(inst.getBody())).replace(/\'/g, '%27'); 255 267 args += '&lang=' + escape(inst.spellCheckerLang); 256 268 257 269 co = document.getElementById(inst.editorId + '_parent').firstChild; … … 263 275 // Setup message box 264 276 mb = self._getMsgBoxLayer(inst); 265 277 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 267 285 mb.show(); 268 286 mb.moveRelativeTo(co, 'cc'); 269 287 … … 276 294 inst.spellcheckerOn = true; 277 295 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonSelected'); 278 296 279 self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);297 self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args); 280 298 } else { 281 299 self._removeWords(inst.getDoc()); 282 300 inst.spellcheckerOn = false; … … 329 347 cleanup : function(type, content, inst) { 330 348 switch (type) { 331 349 case "get_from_editor_dom": 332 TinyMCE_SpellCheckerPlugin._removeWords(content );350 TinyMCE_SpellCheckerPlugin._removeWords(content, null, true); 333 351 inst.spellcheckerOn = false; 334 352 break; 335 353 } … … 389 407 switch (cmd) { 390 408 case "spell": 391 409 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('+')); 393 411 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)})); 394 415 } else 395 416 alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true)); 396 417 397 418 self._checkDone(inst); 398 419 420 // Odd stuff FF removed useCSS, disable state for it 421 inst.useCSS = false; 422 399 423 break; 400 424 401 425 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); 403 427 self._contextMenu.show(); 404 428 break; 405 429 } … … 418 442 var i, x, s, nv = '', nl = tinyMCE.getNodeTree(n, new Array(), 3), wl = new Array(); 419 443 var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 420 444 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 } 423 449 424 450 nv = nv.replace(new RegExp('([0-9]|[' + re + '])', 'g'), ' '); 425 451 nv = tinyMCE.trim(nv.replace(/(\s+)/g, ' ')); … … 434 460 } 435 461 } 436 462 437 if (!s )463 if (!s && nl[i].length > 0) 438 464 wl[wl.length] = nl[i]; 439 465 } 440 466 441 467 return wl.join(' '); 442 468 }, 443 469 444 _removeWords : function(doc, word ) {470 _removeWords : function(doc, word, cleanup) { 445 471 var i, c, nl = doc.getElementsByTagName("span"); 446 472 var self = TinyMCE_SpellCheckerPlugin; 447 473 var inst = tinyMCE.selectedInstance, b = inst ? inst.selection.getBookmark() : null; … … 455 481 self._removeWord(nl[i]); 456 482 } 457 483 458 if (b )484 if (b && !cleanup) 459 485 inst.selection.moveToBookmark(b); 460 486 }, 461 487 462 488 _checkDone : function(inst) { 463 var i, w = 0, nl = inst.getDoc().getElementsByTagName("span")464 489 var self = TinyMCE_SpellCheckerPlugin; 490 var w = self._countWords(inst); 465 491 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 466 503 for (i=nl.length-1; i>=0; i--) { 467 504 c = tinyMCE.getAttrib(nl[i], 'class'); 468 505 … … 470 507 w++; 471 508 } 472 509 473 if (w == 0) { 474 self._removeWords(inst.getDoc()); 475 inst.spellcheckerOn = false; 476 tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); 477 } 510 return w; 478 511 }, 479 512 480 513 _removeWord : function(e) { 481 tinyMCE.setOuterHTML(e, e.innerHTML); 514 if (e != null) 515 tinyMCE.setOuterHTML(e, e.innerHTML); 482 516 }, 483 517 484 518 _markWords : function(doc, n, wl) { … … 486 520 var r1, r2, r3, r4, r5, w = ''; 487 521 var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 488 522 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 } 491 527 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 498 528 for (i=0; i<nl.length; i++) { 499 529 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 500 536 if (r1.test(nv) || r2.test(nv) || r3.test(nv) || r4.test(nv)) { 501 537 nv = tinyMCE.xmlEncode(nv); 502 538 nv = nv.replace(r5, '<span class="mceItemHiddenSpellWord">$1</span>$2'); … … 524 560 cm.addItem(sg[i], 'tinyMCE.execCommand("mceSpellCheckReplace",false,"' + sg[i] + '");'); 525 561 526 562 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\');');529 563 } else 530 564 cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug', '', true)); 531 565 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 532 569 cm.update(); 533 570 }, 534 571 -
wp-includes/js/tinymce/plugins/spellchecker/langs/en.js
10 10 swait : 'Spellchecking, please wait...', 11 11 sug : 'Suggestions', 12 12 no_sug : 'No suggestions', 13 no_mpell : 'No misspellings found.' 13 no_mpell : 'No misspellings found.', 14 mpell_found : 'Found {$words} misspellings.' 14 15 }); -
wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php
5 5 * $Date: 2006/03/14 17:33:47 $ 6 6 * 7 7 * @author Moxiecode 8 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.8 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 9 9 */ 10 10 11 // Ignore the Notice errors for now. 12 error_reporting(E_ALL ^ E_NOTICE); 13 11 14 require_once("config.php"); 12 15 13 16 $id = sanitize($_POST['id'], "loose"); … … 30 33 31 34 // Get input parameters. 32 35 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"); 41 44 $words = array(); 42 45 43 46 $validRequest = true; … … 109 112 switch($outputType) { 110 113 case "xml": 111 114 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 114 118 if (count($result) == 0) 115 echo'<res id="' . $id . '" cmd="'. $cmd .'" />';119 $body .= '<res id="' . $id . '" cmd="'. $cmd .'" />'; 116 120 else 117 echo '<res id="' . $id . '" cmd="'. $cmd .'">'. utf8_encode(implode(" ", $result)) .'</res>';121 $body .= '<res id="' . $id . '" cmd="'. $cmd .'">'. urlencode(implode(" ", $result)) .'</res>'; 118 122 123 echo $body; 119 124 break; 120 125 case "xmlerror"; 121 126 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; 125 131 break; 126 132 case "html": 127 133 var_dump($result);