1
|
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 |
* @package MCManager.includes |
|
8 |
* @author Moxiecode |
|
9 |
* @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved. |
|
10 |
*/ |
|
11 |
|
|
12 |
class EnchantSpell extends SpellChecker { |
|
13 |
/** |
|
14 |
* Spellchecks an array of words. |
|
15 |
* |
|
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. |
|
19 |
*/ |
|
20 |
function &checkWords($lang, $words) { |
|
21 |
$r = enchant_broker_init(); |
|
22 |
|
|
23 |
if (enchant_broker_dict_exists($r,$lang)) { |
|
24 |
$d = enchant_broker_request_dict($r, $lang); |
|
25 |
|
|
26 |
$returnData = array(); |
|
27 |
foreach($words as $key => $value) { |
|
28 |
$correct = enchant_dict_check($d, $value); |
|
29 |
if(!$correct) { |
|
30 |
$returnData[] = trim($value); |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
return $returnData; |
|
35 |
enchant_broker_free_dict($d); |
|
36 |
} else { |
|
37 |
|
|
38 |
} |
|
39 |
enchant_broker_free($r); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Returns suggestions for a specific word. |
|
44 |
* |
|
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. |
|
48 |
*/ |
|
49 |
function &getSuggestions($lang, $word) { |
|
50 |
$r = enchant_broker_init(); |
|
51 |
$suggs = array(); |
|
52 |
|
|
53 |
if (enchant_broker_dict_exists($r,$lang)) { |
|
54 |
$d = enchant_broker_request_dict($r, $lang); |
|
55 |
$suggs = enchant_dict_suggest($d, $word); |
|
56 |
|
|
57 |
enchant_broker_free_dict($d); |
|
58 |
} else { |
|
59 |
|
|
60 |
} |
|
61 |
enchant_broker_free($r); |
|
62 |
|
|
63 |
return $suggs; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
?> |