3
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
5
* This class was contributed by Michel Weimerskirch.
7
* @package MCManager.includes
9
* @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved.
12
class EnchantSpell extends SpellChecker {
14
* Spellchecks an array of words.
16
* @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
17
* @param Array $words Array of words to check.
18
* @return Array of misspelled words.
20
function &checkWords($lang, $words) {
21
$r = enchant_broker_init();
23
if (enchant_broker_dict_exists($r,$lang)) {
24
$d = enchant_broker_request_dict($r, $lang);
26
$returnData = array();
27
foreach($words as $key => $value) {
28
$correct = enchant_dict_check($d, $value);
30
$returnData[] = trim($value);
35
enchant_broker_free_dict($d);
39
enchant_broker_free($r);
43
* Returns suggestions for a specific word.
45
* @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
46
* @param String $word Specific word to get suggestions for.
47
* @return Array of suggestions for the specified word.
49
function &getSuggestions($lang, $word) {
50
$r = enchant_broker_init();
52
if (enchant_broker_dict_exists($r,$lang)) {
53
$d = enchant_broker_request_dict($r, $lang);
54
$suggs = enchant_dict_suggest($d, $word);
56
// enchant_dict_suggest() sometimes returns NULL
57
if (!is_array($suggs))
60
enchant_broker_free_dict($d);
65
enchant_broker_free($r);