]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
Imported Upstream version 0.1~rc2
[roundcube.git] / program / js / tiny_mce / plugins / spellchecker / classes / TinyPspell.class.php
diff --git a/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php b/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
new file mode 100644 (file)
index 0000000..21fb194
--- /dev/null
@@ -0,0 +1,64 @@
+<?php\r
+/* * \r
+ * Tiny Spelling Interface for TinyMCE Spell Checking.\r
+ *\r
+ * Copyright © 2006 Moxiecode Systems AB\r
+ *\r
+ */\r
+\r
+class TinyPSpell {\r
+       var $lang;\r
+       var $mode;\r
+       var $string;\r
+       var $plink;\r
+       var $errorMsg;\r
+\r
+       var $jargon;\r
+       var $spelling;\r
+       var $encoding;\r
+\r
+       function TinyPSpell(&$config, $lang, $mode, $spelling, $jargon, $encoding) {\r
+               $this->lang = $lang;\r
+               $this->mode = $mode;\r
+               $this->plink = false;\r
+               $this->errorMsg = array();\r
+\r
+               if (!function_exists("pspell_new")) {\r
+                       $this->errorMsg[] = "PSpell not found.";\r
+                       return;\r
+               }\r
+\r
+               $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode);\r
+       }\r
+\r
+       // Returns array with bad words or false if failed.\r
+       function checkWords($wordArray) {\r
+               if (!$this->plink) {\r
+                       $this->errorMsg[] = "No PSpell link found for checkWords.";\r
+                       return array();\r
+               }\r
+\r
+               $wordError = array();\r
+               foreach($wordArray as $word) {\r
+                       if(!pspell_check($this->plink, trim($word)))\r
+                               $wordError[] = $word;\r
+               }\r
+\r
+               return $wordError;\r
+       }\r
+\r
+       // Returns array with suggestions or false if failed.\r
+       function getSuggestion($word) {\r
+               if (!$this->plink) {\r
+                       $this->errorMsg[] = "No PSpell link found for getSuggestion.";\r
+                       return array();\r
+               }\r
+\r
+               return pspell_suggest($this->plink, $word);\r
+       }\r
+}\r
+\r
+// Setup classname, should be the same as the name of the spellchecker class\r
+$spellCheckerConfig['class'] = "TinyPspell";\r
+\r
+?>
\ No newline at end of file