Changeset 491

Show
Ignore:
Timestamp:
08/10/06 18:38:35 (2 years ago)
Author:
misja
Message:

Updated to version 1.02 of the tinymce spellchecker. It should fix spellchecking with Google, please test. Note: the Google spellchecking needs the PHP curl extension.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/changelog

    r355 r491  
     1Version 1.0.2 (2006-08-02) 
     2        Added new spellchecker_report_mispellings option, contributed by Jeremy B. 
     3        Fixed various regexp bugs and issues. Some where contributed by Jeremy B. 
     4        Fixed the Google speller class so it uses curl, patch contributed by Yuriy Kramar. 
     5        Fixed encoding issues with language specific characters, patch contributed by codepit. 
     6        Fixed bug where the spellchecker wasn't working in MSIE if the editor was placed in a P tag. 
    17Version 1.0.1 (2006-05-05) 
    28        Since sourceforge has a serious bug when it comes to replacing files with the same name this release was necessary. 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php

    r355 r491  
    11<?php 
    2 /* *  
     2/* * 
    33 * Tiny Spelling Interface for TinyMCE Spell Checking. 
    44 * 
    55 * Copyright © 2006 Moxiecode Systems AB 
    66 */ 
    7  
    8 require_once("HttpClient.class.php"); 
    97 
    108class TinyGoogleSpell { 
     
    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; 
     26        } 
     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); 
    2836        } 
    2937 
     
    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 = ""; 
    44  
    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); 
     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; 
    5065 
    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(); 
    60                 } 
     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        $ch = curl_init(); 
     82        curl_setopt($ch, CURLOPT_URL,$url); 
     83        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     84        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); 
     85        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     86        $xml = curl_exec($ch); 
     87        curl_close($ch); 
     88 
     89                //$this->_debugData($xml); 
    6190 
    6291                // Grab and parse content 
    63                 $xml = $client->getContent(); 
    6492                preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); 
    6593 
    6694                return $matches; 
     95        } 
     96 
     97        function _debugData($data) { 
     98                $fh = @fopen("debug.log", 'a+'); 
     99                @fwrite($fh, $data); 
     100                @fclose($fh); 
    67101        } 
    68102} 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/classes/TinyPspellShell.class.php

    r355 r491  
    66 * 
    77 */ 
     8 
    89 
    910class TinyPspellShell { 
     
    2829 
    2930                $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell"); 
    30         $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang; 
     31 
     32                if(preg_match("#win#i",php_uname())) 
     33            $this->cmd = $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang." --encoding=utf-8 -H < $this->tmpfile 2>&1"; 
     34        else 
     35            $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --encoding=utf-8 -H --lang=". $this->lang; 
    3136        } 
    3237 
     
    3742                        foreach($wordArray as $key => $value) 
    3843                                fwrite($fh, "^" . $value . "\n"); 
    39  
    4044                        fclose($fh); 
    4145                } else { 
     
    4549 
    4650                $data = shell_exec($this->cmd); 
     51        @unlink($this->tmpfile); 
     52                 
    4753                $returnData = array(); 
    4854                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 
     
    6672        // Returns array with suggestions or false if failed. 
    6773        function getSuggestion($word) { 
     74        if (function_exists("mb_convert_encoding")) 
     75            $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); 
     76        else 
     77            $word = utf8_encode($word); 
     78 
    6879                if ($fh = fopen($this->tmpfile, "w")) { 
    6980                        fwrite($fh, "!\n"); 
     
    7485 
    7586                $data = shell_exec($this->cmd); 
     87 
     88        @unlink($this->tmpfile); 
     89 
    7690                $returnData = array(); 
    7791                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 
     
    93107                return $returnData; 
    94108        } 
     109 
     110        function _debugData($data) { 
     111                $fh = @fopen("debug.log", 'a+'); 
     112                @fwrite($fh, $data); 
     113                @fclose($fh); 
     114        } 
     115 
    95116} 
    96117 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/config.php

    r355 r491  
    33 
    44        // Spellchecker class use 
    5         //require_once("classes/TinyPspellShell.class.php"); // Command line pspell 
     5        // require_once("classes/TinyPspellShell.class.php"); // Command line pspell 
    66        require_once("classes/TinyGoogleSpell.class.php"); // Google web service 
    7         //require_once("classes/TinyPspell.class.php"); // Internal PHP version 
     7        // require_once("classes/TinyPspell.class.php"); // Internal PHP version 
    88 
    99        // General settings 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/editor_plugin.js

    r355 r491  
    1 tinyMCE.importPluginLanguagePack('spellchecker','en,sv,nn,nb');var TinyMCE_SpellCheckerPlugin={_contextMenu:new TinyMCE_Menu(),_menu:new TinyMCE_Menu(),_counter:0,getInfo:function(){return{longname:'Spellchecker',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},handleEvent:function(e){var elm=tinyMCE.isMSIE?e.srcElement:e.target;var inst=tinyMCE.selectedInstance,args='';var self=TinyMCE_SpellCheckerPlugin;var cm=self._contextMenu;var p,p2,x,y,sx,sy,h,elm;if((e.type=="click"||e.type=="contextmenu")&&elm){do{if(tinyMCE.getAttrib(elm,'class')=="mceItemHiddenSpellWord"){inst.spellCheckerElm=elm;args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=suggest&check='+escape(elm.innerHTML);args+='&lang='+escape(inst.spellCheckerLang);elm=inst.spellCheckerElm;p=tinyMCE.getAbsPosition(inst.iframeElement);p2=tinyMCE.getAbsPosition(elm);h=parseInt(elm.offsetHeight);sx=inst.getBody().scrollLeft;sy=inst.getBody().scrollTop;x=p.absLeft+p2.absLeft-sx;y=p.absTop+p2.absTop-sy+h;cm.clear();cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait','',true));cm.show();cm.moveTo(x,y);inst.selection.selectNode(elm,false,false);self._sendAjax(self.baseURL+"/tinyspell.php",self._ajaxResponse,'post',args);tinyMCE.cancelEvent(e);return false;}}while((elm=elm.parentNode));}return true;},initInstance:function(inst){var self=TinyMCE_SpellCheckerPlugin,m=self._menu,cm=self._contextMenu,e;tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/spellchecker/css/content.css");if(!tinyMCE.hasMenu('spellcheckercontextmenu')){tinyMCE.importCSS(document,tinyMCE.baseURL+"/plugins/spellchecker/css/spellchecker.css");cm.init({drop_menu:false});tinyMCE.addMenu('spellcheckercontextmenu',cm);}if(!tinyMCE.hasMenu('spellcheckermenu')){m.init({});tinyMCE.addMenu('spellcheckermenu',m);}inst.spellCheckerLang='en';self._buildSettingsMenu(inst,null);e=self._getBlockBoxLayer(inst).create('div','mceBlockBox',document.getElementById(inst.editorId+'_parent'));self._getMsgBoxLayer(inst).create('div','mceMsgBox',document.getElementById(inst.editorId+'_parent'));},_getMsgBoxLayer:function(inst){if(!inst.spellCheckerMsgBoxL)inst.spellCheckerMsgBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerMsgBox',false);return inst.spellCheckerMsgBoxL;},_getBlockBoxLayer:function(inst){if(!inst.spellCheckerBoxL)inst.spellCheckerBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerBlockBox',false);return inst.spellCheckerBoxL;},_buildSettingsMenu:function(inst,lang){var i,ar=tinyMCE.getParam('spellchecker_languages','+English=en').split(','),p;var self=TinyMCE_SpellCheckerPlugin,m=self._menu,c;m.clear();m.addTitle(tinyMCE.getLang('lang_spellchecker_langs','',true));for(i=0;i<ar.length;i++){if(ar[i]!=''){p=ar[i].split('=');c='mceMenuCheckItem';if(p[0].charAt(0)=='+'){p[0]=p[0].substring(1);if(lang==null){c='mceMenuSelectedItem';inst.spellCheckerLang=p[1];}}if(lang==p[1])c='mceMenuSelectedItem';m.add({text:p[0],js:"tinyMCE.execInstanceCommand('"+inst.editorId+"','mceSpellCheckerSetLang',false,'"+p[1]+"');",class_name:c});}}},setupContent:function(editor_id,body,doc){TinyMCE_SpellCheckerPlugin._removeWords(doc);},getControlHTML:function(cn){switch(cn){case"spellchecker":return TinyMCE_SpellCheckerPlugin._getMenuButtonHTML(cn,'lang_spellchecker_desc','{$pluginurl}/images/spellchecker.gif','lang_spellchecker_desc','mceSpellCheckerMenu','mceSpellCheck');}return"";},_getMenuButtonHTML:function(id,lang,img,mlang,mid,cmd,ui,val){var h='',m,x;cmd='tinyMCE.hideMenus();tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+cmd+'\'';if(typeof(ui)!="undefined"&&ui!=null)cmd+=','+ui;if(typeof(val)!="undefined"&&val!=null)cmd+=",'"+val+"'";cmd+=');';if(tinyMCE.getParam('button_tile_map')&&(!tinyMCE.isMSIE||tinyMCE.isOpera)&&(m=tinyMCE.buttonMap[id])!=null&&(tinyMCE.getParam("language")=="en"||img.indexOf('$lang')==-1)){x=0-(m*20)==0?'0':0-(m*20);h+='<a id="{$editor_id}_'+id+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';h+='<img src="{$themeurl}/images/spacer.gif" style="background-position: '+x+'px 0" title="{$'+lang+'}" />';h+='<img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" onclick="'+mcmd+'return false;" />';h+='</a>';}else{if(tinyMCE.isMSIE&&!tinyMCE.isOpera)h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton" onmouseover="tinyMCE.plugins.spellchecker._menuButtonEvent(\'over\',this);" onmouseout="tinyMCE.plugins.spellchecker._menuButtonEvent(\'out\',this);">';else h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton">';h+='<a href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';h+='<img src="'+img+'" title="{$'+lang+'}" /></a>';h+='<a href="#" onclick="tinyMCE.plugins.spellchecker._toggleMenu(\'{$editor_id}\',\''+mid+'\');return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" />';h+='</a></span>';}return h;},_menuButtonEvent:function(e,o){if(o.className=='mceMenuButtonFocus')return;if(e=='over')o.className=o.className+' mceMenuHover';else o.className=o.className.replace(/\s.*$/,'');},_toggleMenu:function(editor_id,id){var self=TinyMCE_SpellCheckerPlugin;var e=document.getElementById(editor_id+'_spellchecker');var inst=tinyMCE.getInstanceById(editor_id);if(self._menu.isVisible()){tinyMCE.hideMenus();return;}tinyMCE.lastMenuBtnClass=e.className.replace(/\s.*$/,'');tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonFocus');self._menu.moveRelativeTo(e,'bl');self._menu.moveBy(tinyMCE.isMSIE&&!tinyMCE.isOpera?0:1,-1);if(tinyMCE.isOpera)self._menu.moveBy(0,-2);self._onMenuEvent(inst,self._menu,'show');self._menu.show();tinyMCE.lastSelectedMenuBtn=editor_id+'_spellchecker';},_onMenuEvent:function(inst,m,n){TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst,inst.spellCheckerLang);},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),self=TinyMCE_SpellCheckerPlugin,args='',co,bb,mb,nl,i,e;switch(command){case"mceSpellCheck":if(!inst.spellcheckerOn){inst.spellCheckerBookmark=inst.selection.getBookmark();args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=spell&check='+escape(self._getWordList(inst.getBody())).replace(/%20/g,'+');args+='&lang='+escape(inst.spellCheckerLang);co=document.getElementById(inst.editorId+'_parent').firstChild;bb=self._getBlockBoxLayer(inst);bb.moveRelativeTo(co,'tl');bb.resizeTo(co.offsetWidth,co.offsetHeight);bb.show();mb=self._getMsgBoxLayer(inst);e=mb.getElement();e.innerHTML='<span>'+tinyMCE.getLang('lang_spellchecker_swait','',true)+'</span>';mb.show();mb.moveRelativeTo(co,'cc');if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=true;}inst.spellcheckerOn=true;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonSelected');self._sendAjax(self.baseURL+"/tinyspell.php",self._ajaxResponse,'post',args);}else{self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');}return true;case"mceSpellCheckReplace":if(inst.spellCheckerElm)tinyMCE.setOuterHTML(inst.spellCheckerElm,value);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnore":if(inst.spellCheckerElm)self._removeWord(inst.spellCheckerElm);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnoreAll":if(inst.spellCheckerElm)self._removeWords(inst.getDoc(),inst.spellCheckerElm.innerHTML);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckerSetLang":tinyMCE.hideMenus();inst.spellCheckerLang=value;self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');return true;}return false;},cleanup:function(type,content,inst){switch(type){case"get_from_editor_dom":TinyMCE_SpellCheckerPlugin._removeWords(content);inst.spellcheckerOn=false;break;}return content;},_displayUI:function(inst){var self=TinyMCE_SpellCheckerPlugin;var bb=self._getBlockBoxLayer(inst);var mb=self._getMsgBoxLayer(inst);var nl,i;var co=document.getElementById(inst.editorId+'_parent').firstChild;if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=false;}bb.hide();mb.hide();},_ajaxResponse:function(xml){var el=xml?xml.documentElement:null;var inst=tinyMCE.selectedInstance,self=TinyMCE_SpellCheckerPlugin;var cmd=el?el.getAttribute("cmd"):null,err,id=el?el.getAttribute("id"):null;if(id)inst=tinyMCE.getInstanceById(id.substring(0,id.indexOf('|')));self._displayUI(inst);if(cmd=="suggest"&&id!=inst.editorId+"|"+self._counter)return;if(!el){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert("Could not execute AJAX call, server didn't return valid a XML.");return;}err=el.getAttribute("error");if(err=="true"){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert(el.getAttribute("msg"));return;}switch(cmd){case"spell":if(xml.documentElement.firstChild){self._markWords(inst.getDoc(),inst.getBody(),el.firstChild.nodeValue.split(' '));inst.selection.moveToBookmark(inst.spellCheckerBookmark);}else alert(tinyMCE.getLang('lang_spellchecker_no_mpell','',true));self._checkDone(inst);break;case"suggest":self._buildMenu(el.firstChild?el.firstChild.nodeValue.split(' '):null,10);self._contextMenu.show();break;}},_getWordSeparators:function(){var i,re='',ch=tinyMCE.getParam('spellchecker_word_separator_chars','\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}\u201d\u201c');for(i=0;i<ch.length;i++)re+='\\'+ch.charAt(i);return re;},_getWordList:function(n){var i,x,s,nv='',nl=tinyMCE.getNodeTree(n,new Array(),3),wl=new Array();var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<nl.length;i++)nv+=nl[i].nodeValue+" ";nv=nv.replace(new RegExp('([0-9]|['+re+'])','g'),' ');nv=tinyMCE.trim(nv.replace(/(\s+)/g,' '));nl=nv.split(/\s+/);for(i=0;i<nl.length;i++){s=false;for(x=0;x<wl.length;x++){if(wl[x]==nl[i]){s=true;break;}}if(!s)wl[wl.length]=nl[i];}return wl.join(' ');},_removeWords:function(doc,word){var i,c,nl=doc.getElementsByTagName("span");var self=TinyMCE_SpellCheckerPlugin;var inst=tinyMCE.selectedInstance,b=inst?inst.selection.getBookmark():null;word=typeof(word)=='undefined'?null:word;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if((c=='mceItemHiddenSpellWord'||c=='mceItemHidden')&&(word==null||nl[i].innerHTML==word))self._removeWord(nl[i]);}if(b)inst.selection.moveToBookmark(b);},_checkDone:function(inst){var i,w=0,nl=inst.getDoc().getElementsByTagName("span") 
    2 var self=TinyMCE_SpellCheckerPlugin;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if(c=='mceItemHiddenSpellWord')w++;}if(w==0){self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');}},_removeWord:function(e){tinyMCE.setOuterHTML(e,e.innerHTML);},_markWords:function(doc,n,wl){var i,nv,nn,nl=tinyMCE.getNodeTree(n,new Array(),3);var r1,r2,r3,r4,r5,w='';var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<wl.length;i++)w+=wl[i]+((i==wl.length-1)?'':'|');r1=new RegExp('(['+re+'])('+w+')(['+re+'])','g');r2=new RegExp('^('+w+')','g');r3=new RegExp('('+w+')(['+re+']?)$','g');r4=new RegExp('^('+w+')(['+re+']?)$','g');r5=new RegExp('('+w+')(['+re+'])','g');for(i=0;i<nl.length;i++){nv=nl[i].nodeValue;if(r1.test(nv)||r2.test(nv)||r3.test(nv)||r4.test(nv)){nv=tinyMCE.xmlEncode(nv);nv=nv.replace(r5,'<span class="mceItemHiddenSpellWord">$1</span>$2');nv=nv.replace(r3,'<span class="mceItemHiddenSpellWord">$1</span>$2');nn=doc.createElement('span');nn.className="mceItemHidden";nn.innerHTML=nv;nl[i].parentNode.replaceChild(nn,nl[i]);}}},_buildMenu:function(sg,max){var i,self=TinyMCE_SpellCheckerPlugin,cm=self._contextMenu;cm.clear();if(sg!=null){cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug','',true));for(i=0;i<sg.length&&i<max;i++)cm.addItem(sg[i],'tinyMCE.execCommand("mceSpellCheckReplace",false,"'+sg[i]+'");');cm.addSeparator();cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnore\');');cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');');}else cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug','',true));cm.update();},_getAjaxHTTP:function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest();}}},_sendAjax:function(u,f,m,a){var x=TinyMCE_SpellCheckerPlugin._getAjaxHTTP();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseXML);};if(m=='post')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a);}};tinyMCE.addPlugin('spellchecker',TinyMCE_SpellCheckerPlugin); 
     1tinyMCE.importPluginLanguagePack('spellchecker','en,fr,sv,nn,nb');var TinyMCE_SpellCheckerPlugin={_contextMenu:new TinyMCE_Menu(),_menu:new TinyMCE_Menu(),_counter:0,_ajaxPage:'/tinyspell.php',getInfo:function(){return{longname:'Spellchecker',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},handleEvent:function(e){var elm=tinyMCE.isMSIE?e.srcElement:e.target;var inst=tinyMCE.selectedInstance,args='';var self=TinyMCE_SpellCheckerPlugin;var cm=self._contextMenu;var p,p2,x,y,sx,sy,h,elm;if((e.type=="click"||e.type=="contextmenu")&&elm){do{if(tinyMCE.getAttrib(elm,'class')=="mceItemHiddenSpellWord"){inst.spellCheckerElm=elm;args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=suggest&check='+encodeURIComponent(elm.innerHTML);args+='&lang='+escape(inst.spellCheckerLang);elm=inst.spellCheckerElm;p=tinyMCE.getAbsPosition(inst.iframeElement);p2=tinyMCE.getAbsPosition(elm);h=parseInt(elm.offsetHeight);sx=inst.getBody().scrollLeft;sy=inst.getBody().scrollTop;x=p.absLeft+p2.absLeft-sx;y=p.absTop+p2.absTop-sy+h;cm.clear();cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait','',true));cm.show();cm.moveTo(x,y);inst.selection.selectNode(elm,false,false);self._sendAjax(self.baseURL+self._ajaxPage,self._ajaxResponse,'post',args);tinyMCE.cancelEvent(e);return false;}}while((elm=elm.parentNode));}return true;},initInstance:function(inst){var self=TinyMCE_SpellCheckerPlugin,m=self._menu,cm=self._contextMenu,e;tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/spellchecker/css/content.css");if(!tinyMCE.hasMenu('spellcheckercontextmenu')){tinyMCE.importCSS(document,tinyMCE.baseURL+"/plugins/spellchecker/css/spellchecker.css");cm.init({drop_menu:false});tinyMCE.addMenu('spellcheckercontextmenu',cm);}if(!tinyMCE.hasMenu('spellcheckermenu')){m.init({});tinyMCE.addMenu('spellcheckermenu',m);}inst.spellCheckerLang='en';self._buildSettingsMenu(inst,null);e=self._getBlockBoxLayer(inst).create('div','mceBlockBox',document.getElementById(inst.editorId+'_parent'));self._getMsgBoxLayer(inst).create('div','mceMsgBox',document.getElementById(inst.editorId+'_parent'));},_getMsgBoxLayer:function(inst){if(!inst.spellCheckerMsgBoxL)inst.spellCheckerMsgBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerMsgBox',false);return inst.spellCheckerMsgBoxL;},_getBlockBoxLayer:function(inst){if(!inst.spellCheckerBoxL)inst.spellCheckerBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerBlockBox',false);return inst.spellCheckerBoxL;},_buildSettingsMenu:function(inst,lang){var i,ar=tinyMCE.getParam('spellchecker_languages','+English=en').split(','),p;var self=TinyMCE_SpellCheckerPlugin,m=self._menu,c;m.clear();m.addTitle(tinyMCE.getLang('lang_spellchecker_langs','',true));for(i=0;i<ar.length;i++){if(ar[i]!=''){p=ar[i].split('=');c='mceMenuCheckItem';if(p[0].charAt(0)=='+'){p[0]=p[0].substring(1);if(lang==null){c='mceMenuSelectedItem';inst.spellCheckerLang=p[1];}}if(lang==p[1])c='mceMenuSelectedItem';m.add({text:p[0],js:"tinyMCE.execInstanceCommand('"+inst.editorId+"','mceSpellCheckerSetLang',false,'"+p[1]+"');",class_name:c});}}},setupContent:function(editor_id,body,doc){TinyMCE_SpellCheckerPlugin._removeWords(doc);},getControlHTML:function(cn){switch(cn){case"spellchecker":return TinyMCE_SpellCheckerPlugin._getMenuButtonHTML(cn,'lang_spellchecker_desc','{$pluginurl}/images/spellchecker.gif','lang_spellchecker_desc','mceSpellCheckerMenu','mceSpellCheck');}return"";},_getMenuButtonHTML:function(id,lang,img,mlang,mid,cmd,ui,val){var h='',m,x;cmd='tinyMCE.hideMenus();tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+cmd+'\'';if(typeof(ui)!="undefined"&&ui!=null)cmd+=','+ui;if(typeof(val)!="undefined"&&val!=null)cmd+=",'"+val+"'";cmd+=');';if(tinyMCE.getParam('button_tile_map')&&(!tinyMCE.isMSIE||tinyMCE.isOpera)&&(m=tinyMCE.buttonMap[id])!=null&&(tinyMCE.getParam("language")=="en"||img.indexOf('$lang')==-1)){x=0-(m*20)==0?'0':0-(m*20);h+='<a id="{$editor_id}_'+id+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';h+='<img src="{$themeurl}/images/spacer.gif" style="background-position: '+x+'px 0" title="{$'+lang+'}" />';h+='<img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" onclick="'+mcmd+'return false;" />';h+='</a>';}else{if(tinyMCE.isMSIE&&!tinyMCE.isOpera)h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton" onmouseover="tinyMCE.plugins.spellchecker._menuButtonEvent(\'over\',this);" onmouseout="tinyMCE.plugins.spellchecker._menuButtonEvent(\'out\',this);">';else h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton">';h+='<a href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';h+='<img src="'+img+'" title="{$'+lang+'}" /></a>';h+='<a href="#" onclick="tinyMCE.plugins.spellchecker._toggleMenu(\'{$editor_id}\',\''+mid+'\');return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" />';h+='</a></span>';}return h;},_menuButtonEvent:function(e,o){if(o.className=='mceMenuButtonFocus')return;if(e=='over')o.className=o.className+' mceMenuHover';else o.className=o.className.replace(/\s.*$/,'');},_toggleMenu:function(editor_id,id){var self=TinyMCE_SpellCheckerPlugin;var e=document.getElementById(editor_id+'_spellchecker');var inst=tinyMCE.getInstanceById(editor_id);if(self._menu.isVisible()){tinyMCE.hideMenus();return;}tinyMCE.lastMenuBtnClass=e.className.replace(/\s.*$/,'');tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonFocus');self._menu.moveRelativeTo(e,'bl');self._menu.moveBy(tinyMCE.isMSIE&&!tinyMCE.isOpera?0:1,-1);if(tinyMCE.isOpera)self._menu.moveBy(0,-2);self._onMenuEvent(inst,self._menu,'show');self._menu.show();tinyMCE.lastSelectedMenuBtn=editor_id+'_spellchecker';},_onMenuEvent:function(inst,m,n){TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst,inst.spellCheckerLang);},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),self=TinyMCE_SpellCheckerPlugin,args='',co,bb,mb,nl,i,e;switch(command){case"mceSpellCheck":if(!inst.spellcheckerOn){inst.spellCheckerBookmark=inst.selection.getBookmark();args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=spell&check='+encodeURIComponent(self._getWordList(inst.getBody())).replace(/\'/g,'%27');args+='&lang='+escape(inst.spellCheckerLang);co=document.getElementById(inst.editorId+'_parent').firstChild;bb=self._getBlockBoxLayer(inst);bb.moveRelativeTo(co,'tl');bb.resizeTo(co.offsetWidth,co.offsetHeight);bb.show();mb=self._getMsgBoxLayer(inst);e=mb.getElement();e.innerHTML='<span>'+tinyMCE.getLang('lang_spellchecker_swait','',true)+'</span>';mb.show();mb.moveRelativeTo(co,'cc');if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=true;}inst.spellcheckerOn=true;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonSelected');self._sendAjax(self.baseURL+self._ajaxPage,self._ajaxResponse,'post',args);}else{self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');}return true;case"mceSpellCheckReplace":if(inst.spellCheckerElm)tinyMCE.setOuterHTML(inst.spellCheckerElm,value);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnore":if(inst.spellCheckerElm)self._removeWord(inst.spellCheckerElm);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnoreAll":if(inst.spellCheckerElm)self._removeWords(inst.getDoc(),inst.spellCheckerElm.innerHTML);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckerSetLang":tinyMCE.hideMenus();inst.spellCheckerLang=value;self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');return true;}return false;},cleanup:function(type,content,inst){switch(type){case"get_from_editor_dom":TinyMCE_SpellCheckerPlugin._removeWords(content);inst.spellcheckerOn=false;break;}return content;},_displayUI:function(inst){var self=TinyMCE_SpellCheckerPlugin;var bb=self._getBlockBoxLayer(inst);var mb=self._getMsgBoxLayer(inst);var nl,i;var co=document.getElementById(inst.editorId+'_parent').firstChild;if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=false;}bb.hide();mb.hide();},_ajaxResponse:function(xml){var el=xml?xml.documentElement:null;var inst=tinyMCE.selectedInstance,self=TinyMCE_SpellCheckerPlugin;var cmd=el?el.getAttribute("cmd"):null,err,id=el?el.getAttribute("id"):null;if(id)inst=tinyMCE.getInstanceById(id.substring(0,id.indexOf('|')));self._displayUI(inst);if(cmd=="suggest"&&id!=inst.editorId+"|"+self._counter)return;if(!el){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert("Could not execute AJAX call, server didn't return valid a XML.");return;}err=el.getAttribute("error");if(err=="true"){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert(el.getAttribute("msg"));return;}switch(cmd){case"spell":if(xml.documentElement.firstChild){self._markWords(inst.getDoc(),inst.getBody(),decodeURIComponent(el.firstChild.nodeValue).split('+'));inst.selection.moveToBookmark(inst.spellCheckerBookmark);if(tinyMCE.getParam('spellchecker_report_mispellings',false))alert(tinyMCE.getLang('lang_spellchecker_mpell_found','',true,{words:self._countWords(inst)}));}else alert(tinyMCE.getLang('lang_spellchecker_no_mpell','',true));self._checkDone(inst);break;case"suggest":self._buildMenu(el.firstChild?decodeURIComponent(el.firstChild.nodeValue).split('+'):null,10);self._contextMenu.show();break;}},_getWordSeparators:function(){var i,re='',ch=tinyMCE.getParam('spellchecker_word_separator_chars','\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}\u201d\u201c');for(i=0;i<ch.length;i++)re+='\\'+ch.charAt(i);return re;},_getWordList:function(n){var i,x,s,nv='',nl=tinyMCE.getNodeTree(n,new Array(),3),wl=new Array();var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<nl.length;i++){if(!new RegExp('/SCRIPT|STYLE/').test(nl[i].parentNode.nodeName))nv+=nl[i].nodeValue+" ";}nv=nv.replace(new RegExp('([0-9]|['+re+'])','g'),' ');nv=tinyMCE.trim(nv.replace(/(\s+)/g,' '));nl=nv.split(/\s+/);for(i=0;i<nl.length;i++){s=false;for(x=0;x<wl.length;x++){if(wl[x]==nl[i]){s=true;break;}}if(!s&&nl[i].length>0)wl[wl.length]=nl[i];}return wl.join(' ');},_removeWords:function(doc,word){var i,c,nl=doc.getElementsByTagName("span");var self=TinyMCE_SpellCheckerPlugin;var inst=tinyMCE.selectedInstance,b=inst?inst.selection.getBookmark():null;word=typeof(word)=='undefined'?null:word;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if((c=='mceItemHiddenSpellWord'||c=='mceItemHidden')&&(word==null||nl[i].innerHTML==word))self._removeWord(nl[i]);}if(b)inst.selection.moveToBookmark(b);},_checkDone:function(inst){var self=TinyMCE_SpellCheckerPlugin;var w=self._countWords(inst);if(w==0){self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');}},_countWords:function(inst){var i,w=0,nl=inst.getDoc().getElementsByTagName("span"),c;var self=TinyMCE_SpellCheckerPlugin;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if(c=='mceItemHiddenSpellWord')w++;}return w;},_removeWord:function(e){if(e!=null)tinyMCE.setOuterHTML(e,e.innerHTML);},_markWords:function(doc,n,wl){var i,nv,nn,nl=tinyMCE.getNodeTree(n,new Array(),3);var r1,r2,r3,r4,r5,w='';var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<wl.length;i++){if(wl[i].length>0)w+=wl[i]+((i==wl.length-1)?'':'|');}for(i=0;i<nl.length;i++){nv=nl[i].nodeValue;r1=new RegExp('(['+re+'])('+w+')(['+re+'])','g');r2=new RegExp('^('+w+')','g');r3=new RegExp('('+w+')(['+re+']?)$','g');r4=new RegExp('^('+w+')(['+re+']?)$','g');r5=new RegExp('('+w+')(['+re+'])','g');if(r1.test(nv)||r2.test(nv)||r3.test(nv)||r4.test(nv)){nv=tinyMCE.xmlEncode(nv);nv=nv.replace(r5,'<span class="mceItemHiddenSpellWord">$1</span>$2');nv=nv.replace(r3,'<span class="mceItemHiddenSpellWord">$1</span>$2');nn=doc.createElement('span');nn.className="mceItemHidden";nn.innerHTML=nv;nl[i].parentNode.replaceChild(nn,nl[i]);}}},_buildMenu:function(sg,max){var i,self=TinyMCE_SpellCheckerPlugin,cm=self._contextMenu;cm.clear();if(sg!=null){cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug','',true));for(i=0;i<sg.length&&i<max;i++)cm.addItem(sg[i],'tinyMCE.execCommand("mceSpellCheckReplace",false,"'+sg[i]+'");');cm.addSeparator();}else cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug','',true));cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnore\');');cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');');cm.update();},_getAjaxHTTP:function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest();}}},_sendAjax:function(u,f,m,a){var x=TinyMCE_SpellCheckerPlugin._getAjaxHTTP();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseXML);};if(m=='post')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a);}};tinyMCE.addPlugin('spellchecker',TinyMCE_SpellCheckerPlugin); 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/editor_plugin_src.js

    r355 r491  
    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 28 2006-08-01 16:02:56Z spocke $ 
    53 * 
    64 * @author Moxiecode 
     
    86 */ 
    97 
    10 tinyMCE.importPluginLanguagePack('spellchecker', 'en,sv,nn,nb'); 
     8tinyMCE.importPluginLanguagePack('spellchecker', 'en,fr,sv,nn,nb'); 
    119 
    1210// Plucin static class 
     
    1513        _menu : new TinyMCE_Menu(), 
    1614        _counter : 0, 
     15        _ajaxPage : '/tinyspell.php', 
    1716 
    1817        getInfo : function() { 
     
    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 
     
    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); 
     
    252251                                        // Setup arguments 
    253252                                        args += 'id=' + inst.editorId + "|" + (++self._counter); 
    254                                         args += '&cmd=spell&check=' + escape(self._getWordList(inst.getBody())).replace(/%20/g, '+'); 
     253                                        args += '&cmd=spell&check=' + encodeURIComponent(self._getWordList(inst.getBody())).replace( /\'/g, '%27' ); 
    255254                                        args += '&lang=' + escape(inst.spellCheckerLang); 
    256255 
     
    277276                                        tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonSelected'); 
    278277 
    279                                         self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args); 
     278                                        self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args); 
    280279                                } else { 
    281280                                        self._removeWords(inst.getDoc()); 
     
    390389                        case "spell": 
    391390                                if (xml.documentElement.firstChild) { 
    392                                         self._markWords(inst.getDoc(), inst.getBody(), el.firstChild.nodeValue.split(' ')); 
     391                                        self._markWords(inst.getDoc(), inst.getBody(), decodeURIComponent(el.firstChild.nodeValue).split('+')); 
    393392                                        inst.selection.moveToBookmark(inst.spellCheckerBookmark); 
     393 
     394                                        if(tinyMCE.getParam('spellchecker_report_mispellings', false)) 
     395                                                alert(tinyMCE.getLang('lang_spellchecker_mpell_found', '', true, {words : self._countWords(inst)})); 
    394396                                } else 
    395397                                        alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true)); 
     
    400402 
    401403                        case "suggest": 
    402                                 self._buildMenu(el.firstChild ? el.firstChild.nodeValue.split(' ') : null, 10); 
     404                                self._buildMenu(el.firstChild ? decodeURIComponent(el.firstChild.nodeValue).split('+') : null, 10); 
    403405                                self._contextMenu.show(); 
    404406                                break; 
     
    419421                var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 
    420422 
    421                 for (i=0; i<nl.length; i++) 
    422                         nv += nl[i].nodeValue + " "; 
     423                for (i=0; i<nl.length; i++) { 
     424                        if (!new RegExp('/SCRIPT|STYLE/').test(nl[i].parentNode.nodeName)) 
     425                                nv += nl[i].nodeValue + " "; 
     426                } 
    423427 
    424428                nv = nv.replace(new RegExp('([0-9]|[' + re + '])', 'g'), ' '); 
     
    435439                        } 
    436440 
    437                         if (!s
     441                        if (!s && nl[i].length > 0
    438442                                wl[wl.length] = nl[i]; 
    439443                } 
     
    461465 
    462466        _checkDone : function(inst) { 
    463                 var i, w = 0, nl = inst.getDoc().getElementsByTagName("span") 
    464467                var self = TinyMCE_SpellCheckerPlugin; 
    465  
    466                 for (i=nl.length-1; i>=0; i--) { 
    467                         c = tinyMCE.getAttrib(nl[i], 'class'); 
    468  
    469                         if (c == 'mceItemHiddenSpellWord') 
    470                                 w++; 
    471                 } 
     468                var w = self._countWords(inst); 
    472469 
    473470                if (w == 0) { 
     
    478475        }, 
    479476 
     477        _countWords : function(inst) { 
     478                var i, w = 0, nl = inst.getDoc().getElementsByTagName("span"), c; 
     479                var self = TinyMCE_SpellCheckerPlugin; 
     480 
     481                for (i=nl.length-1; i>=0; i--) { 
     482                        c = tinyMCE.getAttrib(nl[i], 'class'); 
     483 
     484                        if (c == 'mceItemHiddenSpellWord') 
     485                                w++; 
     486                } 
     487 
     488                return w; 
     489        }, 
     490 
    480491        _removeWord : function(e) { 
    481                 tinyMCE.setOuterHTML(e, e.innerHTML); 
     492                if (e != null) 
     493                        tinyMCE.setOuterHTML(e, e.innerHTML); 
    482494        }, 
    483495 
     
    487499                var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 
    488500 
    489                 for (i=0; i<wl.length; i++) 
    490                         w += wl[i] + ((i == wl.length-1) ? '' : '|'); 
    491  
    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'); 
     501                for (i=0; i<wl.length; i++) { 
     502                        if (wl[i].length > 0) 
     503                                w += wl[i] + ((i == wl.length-1) ? '' : '|'); 
     504                } 
    497505 
    498506                for (i=0; i<nl.length; i++) { 
    499507                        nv = nl[i].nodeValue; 
     508                        r1 = new RegExp('([' + re + '])(' + w + ')([' + re + '])', 'g'); 
     509                        r2 = new RegExp('^(' + w + ')', 'g'); 
     510                        r3 = new RegExp('(' + w + ')([' + re + ']?)$', 'g'); 
     511                        r4 = new RegExp('^(' + w + ')([' + re + ']?)$', 'g'); 
     512                        r5 = new RegExp('(' + w + ')([' + re + '])', 'g'); 
     513 
    500514                        if (r1.test(nv) || r2.test(nv) || r3.test(nv) || r4.test(nv)) { 
    501515                                nv = tinyMCE.xmlEncode(nv); 
     
    525539 
    526540                        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\');'); 
    529541                } else 
    530542                        cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug', '', true)); 
     543 
     544                cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnore\');'); 
     545                cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');'); 
    531546 
    532547                cm.update(); 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/langs/en.js

    r290 r491  
    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}); 
  • devel/_tinymce/jscripts/tiny_mce/plugins/spellchecker/tinyspell.php

    r355 r491  
    88 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 
    99 */ 
     10 
     11        // Ignore the Notice errors for now. 
     12        error_reporting(E_ALL ^ E_NOTICE); 
    1013 
    1114        require_once("config.php"); 
     
    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 
     
    9194                                $result = $tinyspell->checkWords($words); 
    9295                        break; 
     96         
    9397                        case "suggest": 
    9498                                $result = $tinyspell->getSuggestion($check); 
    9599                        break; 
     100 
    96101                        default: 
    97102                                // Just use this for now. 
     
    110115                case "xml": 
    111116                        header('Content-type: text/xml; charset=utf-8'); 
    112                         echo '<?xml version="1.0" encoding="utf-8" ?>'; 
    113                         echo "\n"; 
     117                        $body  = '<?xml version="1.0" encoding="utf-8" ?>'; 
     118                        $body .= "\n"; 
     119                         
    114120                        if (count($result) == 0) 
    115                                 echo '<res id="' . $id . '" cmd="'. $cmd .'" />'; 
     121                                $body .= '<res id="' . $id . '" cmd="'. $cmd .'" />'; 
    116122                        else 
    117                                 echo '<res id="' . $id . '" cmd="'. $cmd .'">'. utf8_encode(implode(" ", $result)) .'</res>'; 
     123                                $body .= '<res id="' . $id . '" cmd="'. $cmd .'">'. urlencode(implode(" ", $result)) .'</res>'; 
    118124 
     125                        echo $body; 
    119126                break; 
    120127                case "xmlerror"; 
    121128                        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) .'" />'; 
     129                        $body  = '<?xml version="1.0" encoding="utf-8" ?>'; 
     130                        $body .= "\n"; 
     131                        $body .= '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. implode(" ", $tinyspell->errorMsg) .'" />'; 
     132                        echo $body; 
    125133                break; 
    126134                case "html": 
     
    131139                break; 
    132140        } 
    133 ?>  
     141 
     142?>