--- /dev/null
+<?php\r
+/**\r
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class PSpell extends SpellChecker {\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {Array} $words Array of words to spellcheck.\r
+ * @return {Array} Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ $plink = $this->_getPLink($lang);\r
+\r
+ $outWords = array();\r
+ foreach ($words as $word) {\r
+ if (!pspell_check($plink, trim($word)))\r
+ $outWords[] = utf8_encode($word);\r
+ }\r
+\r
+ return $outWords;\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions of for a specific word.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {String} $word Specific word to get suggestions for.\r
+ * @return {Array} Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ $words = pspell_suggest($this->_getPLink($lang), $word);\r
+\r
+ for ($i=0; $i<count($words); $i++)\r
+ $words[$i] = $words[$i];\r
+\r
+ return $words;\r
+ }\r
+\r
+ /**\r
+ * Opens a link for pspell.\r
+ */\r
+ function &_getPLink($lang) {\r
+ // Check for native PSpell support\r
+ if (!function_exists("pspell_new"))\r
+ $this->throwError("PSpell support not found in PHP installation.");\r
+\r
+ // Setup PSpell link\r
+ $plink = pspell_new(\r
+ $lang,\r
+ $this->_config['PSpell.spelling'],\r
+ $this->_config['PSpell.jargon'],\r
+ $this->_config['PSpell.encoding'],\r
+ $this->_config['PSpell.mode']\r
+ );\r
+\r
+ // Setup PSpell link\r
+/* if (!$plink) {\r
+ $pspellConfig = pspell_config_create(\r
+ $lang,\r
+ $this->_config['PSpell.spelling'],\r
+ $this->_config['PSpell.jargon'],\r
+ $this->_config['PSpell.encoding']\r
+ );\r
+\r
+ $plink = pspell_new_config($pspell_config);\r
+ }*/\r
+\r
+ if (!$plink)\r
+ $this->throwError("No PSpell link found opened.");\r
+\r
+ return $plink;\r
+ }\r
+}\r
+\r
+?>\r