]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php
Wordpress 2.3.3
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / spellchecker / classes / TinyPspell.class.php
1 <?php
2 /* * 
3  * Tiny Spelling Interface for TinyMCE Spell Checking.
4  *
5  * Copyright © 2006 Moxiecode Systems AB
6  *
7  */
8
9 class TinyPSpell {
10         var $lang;
11         var $mode;
12         var $string;
13         var $plink;
14         var $errorMsg;
15
16         var $jargon;
17         var $spelling;
18         var $encoding;
19
20         function TinyPSpell(&$config, $lang, $mode, $spelling, $jargon, $encoding) {
21                 $this->lang = $lang;
22                 $this->mode = $mode;
23                 $this->plink = false;
24                 $this->errorMsg = array();
25
26                 if (!function_exists("pspell_new")) {
27                         $this->errorMsg[] = "PSpell not found.";
28                         return;
29                 }
30
31                 $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode);
32         }
33
34         // Returns array with bad words or false if failed.
35         function checkWords($wordArray) {
36                 if (!$this->plink) {
37                         $this->errorMsg[] = "No PSpell link found for checkWords.";
38                         return array();
39                 }
40
41                 $wordError = array();
42                 foreach($wordArray as $word) {
43                         if(!pspell_check($this->plink, trim($word)))
44                                 $wordError[] = $word;
45                 }
46
47                 return $wordError;
48         }
49
50         // Returns array with suggestions or false if failed.
51         function getSuggestion($word) {
52                 if (!$this->plink) {
53                         $this->errorMsg[] = "No PSpell link found for getSuggestion.";
54                         return array();
55                 }
56
57                 return pspell_suggest($this->plink, $word);
58         }
59 }
60
61 // Setup classname, should be the same as the name of the spellchecker class
62 $spellCheckerConfig['class'] = "TinyPspell";
63
64 ?>