3 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
5 * @package MCManager.includes
7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
10 class PSpell extends SpellChecker {
12 * Spellchecks an array of words.
14 * @param {String} $lang Language code like sv or en.
15 * @param {Array} $words Array of words to spellcheck.
16 * @return {Array} Array of misspelled words.
18 function &checkWords($lang, $words) {
19 $plink = $this->_getPLink($lang);
22 foreach ($words as $word) {
23 if (!pspell_check($plink, trim($word)))
24 $outWords[] = utf8_encode($word);
31 * Returns suggestions of for a specific word.
33 * @param {String} $lang Language code like sv or en.
34 * @param {String} $word Specific word to get suggestions for.
35 * @return {Array} Array of suggestions for the specified word.
37 function &getSuggestions($lang, $word) {
38 $words = pspell_suggest($this->_getPLink($lang), $word);
40 for ($i=0; $i<count($words); $i++)
41 $words[$i] = utf8_encode($words[$i]);
47 * Opens a link for pspell.
49 function &_getPLink($lang) {
50 // Check for native PSpell support
51 if (!function_exists("pspell_new"))
52 $this->throwError("PSpell support not found in PHP installation.");
57 $this->_config['PSpell.spelling'],
58 $this->_config['PSpell.jargon'],
59 $this->_config['PSpell.encoding'],
60 $this->_config['PSpell.mode']
65 $pspellConfig = pspell_config_create(
67 $this->_config['PSpell.spelling'],
68 $this->_config['PSpell.jargon'],
69 $this->_config['PSpell.encoding']
72 $plink = pspell_new_config($pspell_config);
76 $this->throwError("No PSpell link found opened.");