3 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
6 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
9 class PSpell extends SpellChecker {
11 * Spellchecks an array of words.
13 * @param {String} $lang Language code like sv or en.
14 * @param {Array} $words Array of words to spellcheck.
15 * @return {Array} Array of misspelled words.
17 function &checkWords($lang, $words) {
18 $plink = $this->_getPLink($lang);
21 foreach ($words as $word) {
22 if (!pspell_check($plink, trim($word)))
23 $outWords[] = utf8_encode($word);
30 * Returns suggestions of for a specific word.
32 * @param {String} $lang Language code like sv or en.
33 * @param {String} $word Specific word to get suggestions for.
34 * @return {Array} Array of suggestions for the specified word.
36 function &getSuggestions($lang, $word) {
37 $words = pspell_suggest($this->_getPLink($lang), $word);
39 for ($i=0; $i<count($words); $i++)
40 $words[$i] = utf8_encode($words[$i]);
46 * Opens a link for pspell.
48 function &_getPLink($lang) {
49 // Check for native PSpell support
50 if (!function_exists("pspell_new"))
51 $this->throwError("PSpell support not found in PHP installation.");
56 $this->_config['PSpell.spelling'],
57 $this->_config['PSpell.jargon'],
58 $this->_config['PSpell.encoding'],
59 $this->_config['PSpell.mode']
64 $pspellConfig = pspell_config_create(
66 $this->_config['PSpell.spelling'],
67 $this->_config['PSpell.jargon'],
68 $this->_config['PSpell.encoding']
71 $plink = pspell_new_config($pspell_config);
75 $this->throwError("No PSpell link found opened.");