summaryrefslogtreecommitdiff
path: root/roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
diff options
context:
space:
mode:
authorestadtherr <estadtherr@208e9e7b-5314-0410-a742-e7e81cd9613c>2006-09-23 23:37:29 +0000
committerestadtherr <estadtherr@208e9e7b-5314-0410-a742-e7e81cd9613c>2006-09-23 23:37:29 +0000
commit59d2dac613e7ac38da672f59797047140ba96704 (patch)
tree95b9a99711f3d9fbf2a86d052a951c4de8a03bd6 /roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
parent6c10f41884bf6b447961b860621383822efe0486 (diff)
added TinyMCE spellchecker plugin, configured to use GoogleSpell
git-svn-id: https://svn.roundcube.net/trunk@351 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php')
-rw-r--r--roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php b/roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
new file mode 100644
index 000000000..21fb19448
--- /dev/null
+++ b/roundcubemail/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php
@@ -0,0 +1,64 @@
+<?php
+/* *
+ * Tiny Spelling Interface for TinyMCE Spell Checking.
+ *
+ * Copyright © 2006 Moxiecode Systems AB
+ *
+ */
+
+class TinyPSpell {
+ var $lang;
+ var $mode;
+ var $string;
+ var $plink;
+ var $errorMsg;
+
+ var $jargon;
+ var $spelling;
+ var $encoding;
+
+ function TinyPSpell(&$config, $lang, $mode, $spelling, $jargon, $encoding) {
+ $this->lang = $lang;
+ $this->mode = $mode;
+ $this->plink = false;
+ $this->errorMsg = array();
+
+ if (!function_exists("pspell_new")) {
+ $this->errorMsg[] = "PSpell not found.";
+ return;
+ }
+
+ $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode);
+ }
+
+ // Returns array with bad words or false if failed.
+ function checkWords($wordArray) {
+ if (!$this->plink) {
+ $this->errorMsg[] = "No PSpell link found for checkWords.";
+ return array();
+ }
+
+ $wordError = array();
+ foreach($wordArray as $word) {
+ if(!pspell_check($this->plink, trim($word)))
+ $wordError[] = $word;
+ }
+
+ return $wordError;
+ }
+
+ // Returns array with suggestions or false if failed.
+ function getSuggestion($word) {
+ if (!$this->plink) {
+ $this->errorMsg[] = "No PSpell link found for getSuggestion.";
+ return array();
+ }
+
+ return pspell_suggest($this->plink, $word);
+ }
+}
+
+// Setup classname, should be the same as the name of the spellchecker class
+$spellCheckerConfig['class'] = "TinyPspell";
+
+?> \ No newline at end of file