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