|
1 <?php |
|
2 /** |
|
3 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
|
4 * |
|
5 * This class was contributed by Michel Weimerskirch. |
|
6 * |
|
7 * @author Moxiecode |
|
8 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
|
9 */ |
|
10 |
|
11 class EnchantSpell extends SpellChecker { |
|
12 /** |
|
13 * Spellchecks an array of words. |
|
14 * |
|
15 * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1 |
|
16 * @param Array $words Array of words to check. |
|
17 * @return Array of misspelled words. |
|
18 */ |
|
19 function &checkWords($lang, $words) { |
|
20 $r = enchant_broker_init(); |
|
21 |
|
22 if (enchant_broker_dict_exists($r,$lang)) { |
|
23 $d = enchant_broker_request_dict($r, $lang); |
|
24 |
|
25 $returnData = array(); |
|
26 foreach($words as $key => $value) { |
|
27 $correct = enchant_dict_check($d, $value); |
|
28 if(!$correct) { |
|
29 $returnData[] = trim($value); |
|
30 } |
|
31 } |
|
32 |
|
33 return $returnData; |
|
34 enchant_broker_free_dict($d); |
|
35 } else { |
|
36 |
|
37 } |
|
38 enchant_broker_free($r); |
|
39 } |
|
40 |
|
41 /** |
|
42 * Returns suggestions for a specific word. |
|
43 * |
|
44 * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1 |
|
45 * @param String $word Specific word to get suggestions for. |
|
46 * @return Array of suggestions for the specified word. |
|
47 */ |
|
48 function &getSuggestions($lang, $word) { |
|
49 $r = enchant_broker_init(); |
|
50 $suggs = array(); |
|
51 |
|
52 if (enchant_broker_dict_exists($r,$lang)) { |
|
53 $d = enchant_broker_request_dict($r, $lang); |
|
54 $suggs = enchant_dict_suggest($d, $word); |
|
55 |
|
56 enchant_broker_free_dict($d); |
|
57 } else { |
|
58 |
|
59 } |
|
60 enchant_broker_free($r); |
|
61 |
|
62 return $suggs; |
|
63 } |
|
64 } |
|
65 |
|
66 ?> |