]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/js/tiny_mce/plugins/spellchecker/classes/EnchantSpell.php
Imported Upstream version 0.2~stable
[roundcube.git] / program / js / tiny_mce / plugins / spellchecker / classes / EnchantSpell.php
diff --git a/program/js/tiny_mce/plugins/spellchecker/classes/EnchantSpell.php b/program/js/tiny_mce/plugins/spellchecker/classes/EnchantSpell.php
new file mode 100755 (executable)
index 0000000..fb6e67c
--- /dev/null
@@ -0,0 +1,66 @@
+<?php\r
+/**\r
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $\r
+ *\r
+ * This class was contributed by Michel Weimerskirch.\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class EnchantSpell extends SpellChecker {\r
+       /**\r
+        * Spellchecks an array of words.\r
+        *\r
+        * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1\r
+        * @param Array $words Array of words to check.\r
+        * @return Array of misspelled words.\r
+        */\r
+       function &checkWords($lang, $words) {\r
+               $r = enchant_broker_init();\r
+               \r
+               if (enchant_broker_dict_exists($r,$lang)) {\r
+                       $d = enchant_broker_request_dict($r, $lang);\r
+                       \r
+                       $returnData = array();\r
+                       foreach($words as $key => $value) {\r
+                               $correct = enchant_dict_check($d, $value);\r
+                               if(!$correct) {\r
+                                       $returnData[] = trim($value);\r
+                               }\r
+                       }\r
+       \r
+                       return $returnData;\r
+                       enchant_broker_free_dict($d);\r
+               } else {\r
+\r
+               }\r
+               enchant_broker_free($r);\r
+       }\r
+\r
+       /**\r
+        * Returns suggestions for a specific word.\r
+        *\r
+        * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1\r
+        * @param String $word Specific word to get suggestions for.\r
+        * @return Array of suggestions for the specified word.\r
+        */\r
+       function &getSuggestions($lang, $word) {\r
+               $r = enchant_broker_init();\r
+               $suggs = array();\r
+\r
+               if (enchant_broker_dict_exists($r,$lang)) {\r
+                       $d = enchant_broker_request_dict($r, $lang);\r
+                       $suggs = enchant_dict_suggest($d, $word);\r
+\r
+                       enchant_broker_free_dict($d);\r
+               } else {\r
+\r
+               }\r
+               enchant_broker_free($r);\r
+\r
+               return $suggs;\r
+       }\r
+}\r
+\r
+?>\r