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