From 6649b1f0a5db6160d197a13ca79cfd67fbb02d77 Mon Sep 17 00:00:00 2001 From: svncommit Date: Sat, 23 Sep 2006 23:37:29 +0000 Subject: added TinyMCE spellchecker plugin, configured to use GoogleSpell --- .../spellchecker/classes/TinyPspell.class.php | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php (limited to '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 index 000000000..21fb19448 --- /dev/null +++ b/program/js/tiny_mce/plugins/spellchecker/classes/TinyPspell.class.php @@ -0,0 +1,64 @@ +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 -- cgit v1.2.3