|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00010 class PSpell extends SpellChecker { 00018 function &checkWords($lang, $words) { 00019 $plink = $this->_getPLink($lang); 00020 00021 $outWords = array(); 00022 foreach ($words as $word) { 00023 if (!pspell_check($plink, trim($word))) 00024 $outWords[] = $word; 00025 } 00026 00027 return $outWords; 00028 } 00029 00037 function &getSuggestions($lang, $word) { 00038 $words = pspell_suggest($this->_getPLink($lang), $word); 00039 00040 return $words; 00041 } 00042 00046 function &_getPLink($lang) { 00047 // Check for native PSpell support 00048 if (!function_exists("pspell_new")) 00049 $this->throwError("PSpell support not found in PHP installation."); 00050 00051 // Setup PSpell link 00052 $plink = pspell_new( 00053 $lang, 00054 $this->_config['PSpell.spelling'], 00055 $this->_config['PSpell.jargon'], 00056 empty($this->_config['PSpell.encoding']) ? 'utf-8' : $this->_config['PSpell.encoding'], 00057 $this->_config['PSpell.mode'] 00058 ); 00059 00060 // Setup PSpell link 00061 /* if (!$plink) { 00062 $pspellConfig = pspell_config_create( 00063 $lang, 00064 $this->_config['PSpell.spelling'], 00065 $this->_config['PSpell.jargon'], 00066 $this->_config['PSpell.encoding'] 00067 ); 00068 00069 $plink = pspell_new_config($pspell_config); 00070 }*/ 00071 00072 if (!$plink) 00073 $this->throwError("No PSpell link found opened."); 00074 00075 return $plink; 00076 } 00077 } 00078 00079 ?>