Make WordPress Core

Changeset 4985


Ignore:
Timestamp:
03/07/2007 04:26:26 AM (18 years ago)
Author:
ryan
Message:

Update to tinyMCE spellchecker 1.0.3.1

Location:
trunk/wp-includes/js/tinymce/plugins/spellchecker
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php

    r4747 r4985  
    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();
     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;
     110    }
     111
     112    function _debugData($data) {
     113        $fh = @fopen("debug.log", 'a+');
     114        @fwrite($fh, $data);
     115        @fclose($fh);
    67116    }
    68117}
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php

    r4747 r4985  
    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);
    47         @unlink($this->tmpfile);
     51        @unlink($this->tmpfile);
     52       
    4853        $returnData = array();
    4954        $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
     
    6772    // Returns array with suggestions or false if failed.
    6873    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
    6979        if ($fh = fopen($this->tmpfile, "w")) {
    7080            fwrite($fh, "!\n");
     
    7282            fclose($fh);
    7383        } else
    74             wp_die("Error opening tmp file.");
     84            die("Error opening tmp file.");
    7585
    7686        $data = shell_exec($this->cmd);
    77         @unlink($this->tmpfile);
     87
     88        @unlink($this->tmpfile);
     89
    7890        $returnData = array();
    7991        $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
     
    95107        return $returnData;
    96108    }
     109
     110    function _debugData($data) {
     111        $fh = @fopen("debug.log", 'a+');
     112        @fwrite($fh, $data);
     113        @fclose($fh);
     114    }
     115
    97116}
    98117
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/config.php

    r4747 r4985  
    22    $spellCheckerConfig = array();
    33
     4    // Spellchecker class use
     5    // require_once("classes/TinyPspellShell.class.php"); // Command line pspell
     6    require_once("classes/TinyGoogleSpell.class.php"); // Google web service
     7    // require_once("classes/TinyPspell.class.php"); // Internal PHP version
     8
    49    // General settings
    510    $spellCheckerConfig['enabled'] = true;
    6 
    7     // Pspell shell specific settings
    8     $spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell';
    9     $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp/tinyspell/0';
    1011
    1112    // Default settings
     
    1819    $spellCheckerConfig['default.encoding'] = "";
    1920
    20     // Spellchecker class use
    21     if ( function_exists('pspell_new') )
    22         require_once("classes/TinyPspell.class.php"); // Internal PHP version
    23 
    24     elseif ( file_exists($spellCheckerConfig['tinypspellshell.aspell']) )
    25         require_once("classes/TinyPspellShell.class.php"); // Command line pspell
    26 
    27     else
    28         require_once("classes/TinyGoogleSpell.class.php"); // Google web service
     21    // Pspell shell specific settings
     22    $spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell';
     23    $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp';
    2924?>
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/css/content.css

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

    r3664 r4985  
    3232    font-weight: bold;
    3333    font-size: 11px;
     34    background-color: #FFF;
    3435}
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js

    r4747 r4985  
    1 /**
    2  * $RCSfile: editor_plugin_src.js,v $
    3  * $Revision: 1.4 $
    4  * $Date: 2006/03/24 17:24:50 $
    5  *
    6  * @author Moxiecode
    7  * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
    8  */
    9 
    10 tinyMCE.importPluginLanguagePack('spellchecker', 'en,sv,nn,nb');
    11 
    12 // Plucin static class
    13 var TinyMCE_SpellCheckerPlugin = {
    14     _contextMenu : new TinyMCE_Menu(),
    15     _menu : new TinyMCE_Menu(),
    16     _counter : 0,
    17 
    18     getInfo : function() {
    19         return {
    20             longname : 'Spellchecker',
    21             author : 'Moxiecode Systems AB',
    22             authorurl : 'http://tinymce.moxiecode.com',
    23             infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',
    24             version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    25         };
    26     },
    27 
    28     handleEvent : function(e) {
    29         var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
    30         var inst = tinyMCE.selectedInstance, args = '';
    31         var self = TinyMCE_SpellCheckerPlugin;
    32         var cm = self._contextMenu;
    33         var p, p2, x, y, sx, sy, h, elm;
    34 
    35         // Handle click on word
    36         if ((e.type == "click" || e.type == "contextmenu") && elm) {
    37             do {
    38                 if (tinyMCE.getAttrib(elm, 'class') == "mceItemHiddenSpellWord") {
    39                     inst.spellCheckerElm = elm;
    40 
    41                     // Setup arguments
    42                     args += 'id=' + inst.editorId + "|" + (++self._counter);
    43                     args += '&cmd=suggest&check=' + escape(elm.innerHTML);
    44                     args += '&lang=' + escape(inst.spellCheckerLang);
    45 
    46                     elm = inst.spellCheckerElm;
    47                     p = tinyMCE.getAbsPosition(inst.iframeElement);
    48                     p2 = tinyMCE.getAbsPosition(elm);
    49                     h = parseInt(elm.offsetHeight);
    50                     sx = inst.getBody().scrollLeft;
    51                     sy = inst.getBody().scrollTop;
    52                     x = p.absLeft + p2.absLeft - sx;
    53                     y = p.absTop + p2.absTop - sy + h;
    54 
    55                     cm.clear();
    56                     cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait', '', true));
    57                     cm.show();
    58                     cm.moveTo(x, y);
    59 
    60                     inst.selection.selectNode(elm, false, false);
    61 
    62                     self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);
    63 
    64                     tinyMCE.cancelEvent(e);
    65                     return false;
    66                 }
    67             } while ((elm = elm.parentNode));
    68         }
    69 
    70         return true;
    71     },
    72 
    73     initInstance : function(inst) {
    74         var self = TinyMCE_SpellCheckerPlugin, m = self._menu, cm = self._contextMenu, e;
    75 
    76         tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/spellchecker/css/content.css");
    77 
    78         if (!tinyMCE.hasMenu('spellcheckercontextmenu')) {
    79             tinyMCE.importCSS(document, tinyMCE.baseURL + "/plugins/spellchecker/css/spellchecker.css");
    80 
    81             cm.init({drop_menu : false});
    82             tinyMCE.addMenu('spellcheckercontextmenu', cm);
    83         }
    84 
    85         if (!tinyMCE.hasMenu('spellcheckermenu')) {
    86             m.init({});
    87             tinyMCE.addMenu('spellcheckermenu', m);
    88         }
    89 
    90         inst.spellCheckerLang = 'en';
    91         self._buildSettingsMenu(inst, null);
    92 
    93         e = self._getBlockBoxLayer(inst).create('div', 'mceBlockBox', document.getElementById(inst.editorId + '_parent'));
    94         self._getMsgBoxLayer(inst).create('div', 'mceMsgBox', document.getElementById(inst.editorId + '_parent'));
    95     },
    96 
    97     _getMsgBoxLayer : function(inst) {
    98         if (!inst.spellCheckerMsgBoxL)
    99             inst.spellCheckerMsgBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerMsgBox', false);
    100 
    101         return inst.spellCheckerMsgBoxL;
    102     },
    103 
    104     _getBlockBoxLayer : function(inst) {
    105         if (!inst.spellCheckerBoxL)
    106             inst.spellCheckerBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerBlockBox', false);
    107 
    108         return inst.spellCheckerBoxL;
    109     },
    110 
    111     _buildSettingsMenu : function(inst, lang) {
    112         var i, ar = tinyMCE.getParam('spellchecker_languages', '+English=en').split(','), p;
    113         var self = TinyMCE_SpellCheckerPlugin, m = self._menu, c;
    114 
    115         m.clear();
    116         m.addTitle(tinyMCE.getLang('lang_spellchecker_langs', '', true));
    117 
    118         for (i=0; i<ar.length; i++) {
    119             if (ar[i] != '') {
    120                 p = ar[i].split('=');
    121                 c = 'mceMenuCheckItem';
    122 
    123                 if (p[0].charAt(0) == '+') {
    124                     p[0] = p[0].substring(1);
    125 
    126                     if (lang == null) {
    127                         c = 'mceMenuSelectedItem';
    128                         inst.spellCheckerLang = p[1];
    129                     }
    130                 }
    131 
    132                 if (lang == p[1])
    133                     c = 'mceMenuSelectedItem';
    134 
    135                 m.add({text : p[0], js : "tinyMCE.execInstanceCommand('" + inst.editorId + "','mceSpellCheckerSetLang',false,'" + p[1] + "');", class_name : c});
    136             }
    137         }
    138     },
    139 
    140     setupContent : function(editor_id, body, doc) {
    141         TinyMCE_SpellCheckerPlugin._removeWords(doc);
    142     },
    143 
    144     getControlHTML : function(cn) {
    145         switch (cn) {
    146             case "spellchecker":
    147                 return TinyMCE_SpellCheckerPlugin._getMenuButtonHTML(cn, 'lang_spellchecker_desc', '{$pluginurl}/images/spellchecker.gif', 'lang_spellchecker_desc', 'mceSpellCheckerMenu', 'mceSpellCheck');
    148         }
    149 
    150         return "";
    151     },
    152 
    153     /**
    154      * Returns the HTML code for a normal button control.
    155      *
    156      * @param {string} id Button control id, this will be the suffix for the element id, the prefix is the editor id.
    157      * @param {string} lang Language variable key name to insert as the title/alt of the button image.
    158      * @param {string} img Image URL to insert, {$themeurl} and {$pluginurl} will be replaced.
    159      * @param {string} mlang Language variable key name to insert as the title/alt of the menu button image.
    160      * @param {string} mid Menu by id to display when the menu button is pressed.
    161      * @param {string} cmd Command to execute when the user clicks the button.
    162      * @param {string} ui Optional user interface boolean for command.
    163      * @param {string} val Optional value for command.
    164      * @return HTML code for a normal button based in input information.
    165      * @type string
    166      */
    167     _getMenuButtonHTML : function(id, lang, img, mlang, mid, cmd, ui, val) {
    168         var h = '', m, x;
    169 
    170         cmd = 'tinyMCE.hideMenus();tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
    171 
    172         if (typeof(ui) != "undefined" && ui != null)
    173             cmd += ',' + ui;
    174 
    175         if (typeof(val) != "undefined" && val != null)
    176             cmd += ",'" + val + "'";
    177 
    178         cmd += ');';
    179 
    180         // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
    181         if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
    182             // Tiled button
    183             x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
    184             h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';
    185             h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';
    186             h += '<img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" onclick="' + mcmd + 'return false;" />';
    187             h += '</a>';
    188         } else {
    189             if (tinyMCE.isMSIE && !tinyMCE.isOpera)
    190                 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE.plugins.spellchecker._menuButtonEvent(\'over\',this);" onmouseout="tinyMCE.plugins.spellchecker._menuButtonEvent(\'out\',this);">';
    191             else
    192                 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
    193 
    194             h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
    195             h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
    196             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" />';
    197             h += '</a></span>';
    198         }
    199 
    200         return h;
    201     },
    202 
    203     _menuButtonEvent : function(e, o) {
    204         if (o.className == 'mceMenuButtonFocus')
    205             return;
    206 
    207         if (e == 'over')
    208             o.className = o.className + ' mceMenuHover';
    209         else
    210             o.className = o.className.replace(/\s.*$/, '');
    211     },
    212 
    213     _toggleMenu : function(editor_id, id) {
    214         var self = TinyMCE_SpellCheckerPlugin;
    215         var e = document.getElementById(editor_id + '_spellchecker');
    216         var inst = tinyMCE.getInstanceById(editor_id);
    217 
    218         if (self._menu.isVisible()) {
    219             tinyMCE.hideMenus();
    220             return;
    221         }
    222 
    223         tinyMCE.lastMenuBtnClass = e.className.replace(/\s.*$/, '');
    224         tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonFocus');
    225 
    226         self._menu.moveRelativeTo(e, 'bl');
    227         self._menu.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? 0 : 1, -1);
    228 
    229         if (tinyMCE.isOpera)
    230             self._menu.moveBy(0, -2);
    231 
    232         self._onMenuEvent(inst, self._menu, 'show');
    233 
    234         self._menu.show();
    235 
    236         tinyMCE.lastSelectedMenuBtn = editor_id + '_spellchecker';
    237     },
    238 
    239     _onMenuEvent : function(inst, m, n) {
    240         TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst, inst.spellCheckerLang);
    241     },
    242 
    243     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;
    245 
    246         // Handle commands
    247         switch (command) {
    248             case "mceSpellCheck":
    249                 if (!inst.spellcheckerOn) {
    250                     inst.spellCheckerBookmark = inst.selection.getBookmark();
    251 
    252                     // Setup arguments
    253                     args += 'id=' + inst.editorId + "|" + (++self._counter);
    254                     args += '&cmd=spell&check=' + escape(self._getWordList(inst.getBody())).replace(/%20/g, '+');
    255                     args += '&lang=' + escape(inst.spellCheckerLang);
    256 
    257                     co = document.getElementById(inst.editorId + '_parent').firstChild;
    258                     bb = self._getBlockBoxLayer(inst);
    259                     bb.moveRelativeTo(co, 'tl');
    260                     bb.resizeTo(co.offsetWidth, co.offsetHeight);
    261                     bb.show();
    262 
    263                     // Setup message box
    264                     mb = self._getMsgBoxLayer(inst);
    265                     e = mb.getElement();
    266                     e.innerHTML = '<span>' + tinyMCE.getLang('lang_spellchecker_swait', '', true) + '</span>';
    267                     mb.show();
    268                     mb.moveRelativeTo(co, 'cc');
    269 
    270                     if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
    271                         nl = co.getElementsByTagName('select');
    272                         for (i=0; i<nl.length; i++)
    273                             nl[i].disabled = true;
    274                     }
    275 
    276                     inst.spellcheckerOn = true;
    277                     tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonSelected');
    278 
    279                     self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args);
    280                 } else {
    281                     self._removeWords(inst.getDoc());
    282                     inst.spellcheckerOn = false;
    283                     tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButton');
    284                 }
    285 
    286                 return true;
    287 
    288             case "mceSpellCheckReplace":
    289                 if (inst.spellCheckerElm)
    290                     tinyMCE.setOuterHTML(inst.spellCheckerElm, value);
    291 
    292                 self._checkDone(inst);
    293                 self._contextMenu.hide();
    294                 self._menu.hide();
    295 
    296                 return true;
    297 
    298             case "mceSpellCheckIgnore":
    299                 if (inst.spellCheckerElm)
    300                     self._removeWord(inst.spellCheckerElm);
    301 
    302                 self._checkDone(inst);
    303                 self._contextMenu.hide();
    304                 self._menu.hide();
    305                 return true;
    306 
    307             case "mceSpellCheckIgnoreAll":
    308                 if (inst.spellCheckerElm)
    309                     self._removeWords(inst.getDoc(), inst.spellCheckerElm.innerHTML);
    310 
    311                 self._checkDone(inst);
    312                 self._contextMenu.hide();
    313                 self._menu.hide();
    314                 return true;
    315 
    316             case "mceSpellCheckerSetLang":
    317                 tinyMCE.hideMenus();
    318                 inst.spellCheckerLang = value;
    319                 self._removeWords(inst.getDoc());
    320                 inst.spellcheckerOn = false;
    321                 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButton');
    322                 return true;
    323         }
    324 
    325         // Pass to next handler in chain
    326         return false;
    327     },
    328 
    329     cleanup : function(type, content, inst) {
    330         switch (type) {
    331             case "get_from_editor_dom":
    332                 TinyMCE_SpellCheckerPlugin._removeWords(content);
    333                 inst.spellcheckerOn = false;
    334                 break;
    335         }
    336 
    337         return content;
    338     },
    339 
    340     // Private plugin specific methods
    341 
    342     _displayUI : function(inst) {
    343         var self = TinyMCE_SpellCheckerPlugin;
    344         var bb = self._getBlockBoxLayer(inst);
    345         var mb = self._getMsgBoxLayer(inst);
    346         var nl, i;
    347         var co = document.getElementById(inst.editorId + '_parent').firstChild;
    348 
    349         if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
    350             nl = co.getElementsByTagName('select');
    351             for (i=0; i<nl.length; i++)
    352                 nl[i].disabled = false;
    353         }
    354 
    355         bb.hide();
    356         mb.hide();
    357     },
    358 
    359     _ajaxResponse : function(xml) {
    360         var el = xml ? xml.documentElement : null;
    361         var inst = tinyMCE.selectedInstance, self = TinyMCE_SpellCheckerPlugin;
    362         var cmd = el ? el.getAttribute("cmd") : null, err, id = el ? el.getAttribute("id") : null;
    363 
    364         if (id)
    365             inst = tinyMCE.getInstanceById(id.substring(0, id.indexOf('|')));
    366 
    367         self._displayUI(inst);
    368 
    369         // Ignore suggestions for other ajax responses
    370         if (cmd == "suggest" && id != inst.editorId + "|" + self._counter)
    371             return;
    372 
    373         if (!el) {
    374             inst.spellcheckerOn = false;
    375             tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton');
    376             alert("Could not execute AJAX call, server didn't return valid a XML.");
    377             return;
    378         }
    379 
    380         err = el.getAttribute("error");
    381 
    382         if (err == "true") {
    383             inst.spellcheckerOn = false;
    384             tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton');
    385             alert(el.getAttribute("msg"));
    386             return;
    387         }
    388 
    389         switch (cmd) {
    390             case "spell":
    391                 if (xml.documentElement.firstChild) {
    392                     self._markWords(inst.getDoc(), inst.getBody(), el.firstChild.nodeValue.split(' '));
    393                     inst.selection.moveToBookmark(inst.spellCheckerBookmark);
    394                 } else
    395                     alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true));
    396 
    397                 self._checkDone(inst);
    398 
    399                 break;
    400 
    401             case "suggest":
    402                 self._buildMenu(el.firstChild ? el.firstChild.nodeValue.split(' ') : null, 10);
    403                 self._contextMenu.show();
    404                 break;
    405         }
    406     },
    407 
    408     _getWordSeparators : function() {
    409         var i, re = '', ch = tinyMCE.getParam('spellchecker_word_separator_chars', '\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c');
    410 
    411         for (i=0; i<ch.length; i++)
    412             re += '\\' + ch.charAt(i);
    413 
    414         return re;
    415     },
    416 
    417     _getWordList : function(n) {
    418         var i, x, s, nv = '', nl = tinyMCE.getNodeTree(n, new Array(), 3), wl = new Array();
    419         var re = TinyMCE_SpellCheckerPlugin._getWordSeparators();
    420 
    421         for (i=0; i<nl.length; i++)
    422             nv += nl[i].nodeValue + " ";
    423 
    424         nv = nv.replace(new RegExp('([0-9]|[' + re + '])', 'g'), ' ');
    425         nv = tinyMCE.trim(nv.replace(/(\s+)/g, ' '));
    426 
    427         nl = nv.split(/\s+/);
    428         for (i=0; i<nl.length; i++) {
    429             s = false;
    430             for (x=0; x<wl.length; x++) {
    431                 if (wl[x] == nl[i]) {
    432                     s = true;
    433                     break;
    434                 }
    435             }
    436 
    437             if (!s)
    438                 wl[wl.length] = nl[i];
    439         }
    440 
    441         return wl.join(' ');
    442     },
    443 
    444     _removeWords : function(doc, word) {
    445         var i, c, nl = doc.getElementsByTagName("span");
    446         var self = TinyMCE_SpellCheckerPlugin;
    447         var inst = tinyMCE.selectedInstance, b = inst ? inst.selection.getBookmark() : null;
    448 
    449         word = typeof(word) == 'undefined' ? null : word;
    450 
    451         for (i=nl.length-1; i>=0; i--) {
    452             c = tinyMCE.getAttrib(nl[i], 'class');
    453 
    454             if ((c == 'mceItemHiddenSpellWord' || c == 'mceItemHidden') && (word == null || nl[i].innerHTML == word))
    455                 self._removeWord(nl[i]);
    456         }
    457 
    458         if (b)
    459             inst.selection.moveToBookmark(b);
    460     },
    461 
    462     _checkDone : function(inst) {
    463         var i, w = 0, nl = inst.getDoc().getElementsByTagName("span")
    464         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         }
    472 
    473         if (w == 0) {
    474             self._removeWords(inst.getDoc());
    475             inst.spellcheckerOn = false;
    476             tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton');
    477         }
    478     },
    479 
    480     _removeWord : function(e) {
    481         tinyMCE.setOuterHTML(e, e.innerHTML);
    482     },
    483 
    484     _markWords : function(doc, n, wl) {
    485         var i, nv, nn, nl = tinyMCE.getNodeTree(n, new Array(), 3);
    486         var r1, r2, r3, r4, r5, w = '';
    487         var re = TinyMCE_SpellCheckerPlugin._getWordSeparators();
    488 
    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');
    497 
    498         for (i=0; i<nl.length; i++) {
    499             nv = nl[i].nodeValue;
    500             if (r1.test(nv) || r2.test(nv) || r3.test(nv) || r4.test(nv)) {
    501                 nv = tinyMCE.xmlEncode(nv);
    502                 nv = nv.replace(r5, '<span class="mceItemHiddenSpellWord">$1</span>$2');
    503                 nv = nv.replace(r3, '<span class="mceItemHiddenSpellWord">$1</span>$2');
    504 
    505                 nn = doc.createElement('span');
    506                 nn.className = "mceItemHidden";
    507                 nn.innerHTML = nv;
    508 
    509                 // Remove old text node
    510                 nl[i].parentNode.replaceChild(nn, nl[i]);
    511             }
    512         }
    513     },
    514 
    515     _buildMenu : function(sg, max) {
    516         var i, self = TinyMCE_SpellCheckerPlugin, cm = self._contextMenu;
    517 
    518         cm.clear();
    519 
    520         if (sg != null) {
    521             cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug', '', true));
    522 
    523             for (i=0; i<sg.length && i<max; i++)
    524                 cm.addItem(sg[i], 'tinyMCE.execCommand("mceSpellCheckReplace",false,"' + sg[i] + '");');
    525 
    526             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         } else
    530             cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug', '', true));
    531 
    532         cm.update();
    533     },
    534 
    535     _getAjaxHTTP : function() {
    536         try {
    537             return new ActiveXObject('Msxml2.XMLHTTP')
    538         } catch (e) {
    539             try {
    540                 return new ActiveXObject('Microsoft.XMLHTTP')
    541             } catch (e) {
    542                 return new XMLHttpRequest();
    543             }
    544         }
    545     },
    546 
    547     /**
    548      * Perform AJAX call.
    549      *
    550      * @param {string} u URL of AJAX service.
    551      * @param {function} f Function to call when response arrives.
    552      * @param {string} m Request method post or get.
    553      * @param {Array} a Array with arguments to send.
    554      */
    555     _sendAjax : function(u, f, m, a) {
    556         var x = TinyMCE_SpellCheckerPlugin._getAjaxHTTP();
    557 
    558         x.open(m, u, true);
    559 
    560         x.onreadystatechange = function() {
    561             if (x.readyState == 4)
    562                 f(x.responseXML);
    563         };
    564 
    565         if (m == 'post')
    566             x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    567 
    568         x.send(a);
    569     }
    570 };
    571 
    572 // Register plugin
    573 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 PHP',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',version:"1.0.3"};},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,null,true);},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){var t=this;window.setTimeout(function(){t._menuButtonEvent2(e,o);},1);},_menuButtonEvent2: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,mbs;switch(command){case"mceSpellCheck":if(!inst.spellcheckerOn){inst.spellCheckerBookmark=inst.selection.getBookmark();if(tinyMCE.isRealIE)tinyMCE.setInnerHTML(inst.getBody(),inst.getBody().innerHTML);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();if(e.childNodes[0])e.removeChild(e.childNodes[0]);mbs=document.createElement("span");mbs.innerHTML='<span>'+tinyMCE.getLang('lang_spellchecker_swait','',true)+'</span>';e.appendChild(mbs);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,null,true);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_misspellings',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);inst.useCSS=false;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,cleanup){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&&!cleanup)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);
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js

    r4747 r4985  
    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});
  • trunk/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php

    r4747 r4985  
    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?>
Note: See TracChangeset for help on using the changeset viewer.