~ubuntu-branches/debian/jessie/wordpress/jessie

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2014-04-17 20:56:19 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20140417205619-nurbet6eho4yvwfv
Tags: 3.9+dfsg-1
* New upstream release
* 3.9 seems to handle different locations for plugins so the
  plugin directory handling patches have been cut back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
4
 
 *
5
 
 * This class was contributed by Michel Weimerskirch.
6
 
 *
7
 
 * @package MCManager.includes
8
 
 * @author Moxiecode
9
 
 * @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved.
10
 
 */
11
 
 
12
 
class EnchantSpell extends SpellChecker {
13
 
        /**
14
 
         * Spellchecks an array of words.
15
 
         *
16
 
         * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
17
 
         * @param Array $words Array of words to check.
18
 
         * @return Array of misspelled words.
19
 
         */
20
 
        function &checkWords($lang, $words) {
21
 
                $r = enchant_broker_init();
22
 
                
23
 
                if (enchant_broker_dict_exists($r,$lang)) {
24
 
                        $d = enchant_broker_request_dict($r, $lang);
25
 
                        
26
 
                        $returnData = array();
27
 
                        foreach($words as $key => $value) {
28
 
                                $correct = enchant_dict_check($d, $value);
29
 
                                if(!$correct) {
30
 
                                        $returnData[] = trim($value);
31
 
                                }
32
 
                        }
33
 
        
34
 
                        return $returnData;
35
 
                        enchant_broker_free_dict($d);
36
 
                } else {
37
 
 
38
 
                }
39
 
                enchant_broker_free($r);
40
 
        }
41
 
 
42
 
        /**
43
 
         * Returns suggestions for a specific word.
44
 
         *
45
 
         * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
46
 
         * @param String $word Specific word to get suggestions for.
47
 
         * @return Array of suggestions for the specified word.
48
 
         */
49
 
        function &getSuggestions($lang, $word) {
50
 
                $r = enchant_broker_init();
51
 
 
52
 
                if (enchant_broker_dict_exists($r,$lang)) {
53
 
                        $d = enchant_broker_request_dict($r, $lang);
54
 
                        $suggs = enchant_dict_suggest($d, $word);
55
 
 
56
 
                        // enchant_dict_suggest() sometimes returns NULL
57
 
                        if (!is_array($suggs))
58
 
                                $suggs = array();
59
 
 
60
 
                        enchant_broker_free_dict($d);
61
 
                } else {
62
 
                        $suggs = array();
63
 
                }
64
 
 
65
 
                enchant_broker_free($r);
66
 
 
67
 
                return $suggs;
68
 
        }
69
 
}
70
 
 
71
 
?>