summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-03-19 12:35:25 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-03-19 12:35:25 +0000
commit50b00028bd207f461d6ed02f7868eccb5c6b8fe1 (patch)
tree003311f94f815dddbc39f91ba25b959f6ef18524 /wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
parent63f0f49bde74f02cdfc79140a7f101173f33322b (diff)
downloadwordpress-mu-50b00028bd207f461d6ed02f7868eccb5c6b8fe1.tar.gz
wordpress-mu-50b00028bd207f461d6ed02f7868eccb5c6b8fe1.tar.xz
wordpress-mu-50b00028bd207f461d6ed02f7868eccb5c6b8fe1.zip
Add and delete WP 2.5 files. *DON'T SVN UPDATE!*
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1214 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php')
-rw-r--r--wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
new file mode 100644
index 0000000..48af873
--- /dev/null
+++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class PSpell extends SpellChecker {
+ /**
+ * Spellchecks an array of words.
+ *
+ * @param {String} $lang Language code like sv or en.
+ * @param {Array} $words Array of words to spellcheck.
+ * @return {Array} Array of misspelled words.
+ */
+ function &checkWords($lang, $words) {
+ $plink = $this->_getPLink($lang);
+
+ $outWords = array();
+ foreach ($words as $word) {
+ if (!pspell_check($plink, trim($word)))
+ $outWords[] = utf8_encode($word);
+ }
+
+ return $outWords;
+ }
+
+ /**
+ * Returns suggestions of for a specific word.
+ *
+ * @param {String} $lang Language code like sv or en.
+ * @param {String} $word Specific word to get suggestions for.
+ * @return {Array} Array of suggestions for the specified word.
+ */
+ function &getSuggestions($lang, $word) {
+ $words = pspell_suggest($this->_getPLink($lang), $word);
+
+ for ($i=0; $i<count($words); $i++)
+ $words[$i] = utf8_encode($words[$i]);
+
+ return $words;
+ }
+
+ /**
+ * Opens a link for pspell.
+ */
+ function &_getPLink($lang) {
+ // Check for native PSpell support
+ if (!function_exists("pspell_new"))
+ $this->throwError("PSpell support not found in PHP installation.");
+
+ // Setup PSpell link
+ $plink = pspell_new(
+ $lang,
+ $this->_config['PSpell.spelling'],
+ $this->_config['PSpell.jargon'],
+ $this->_config['PSpell.encoding'],
+ $this->_config['PSpell.mode']
+ );
+
+ // Setup PSpell link
+/* if (!$plink) {
+ $pspellConfig = pspell_config_create(
+ $lang,
+ $this->_config['PSpell.spelling'],
+ $this->_config['PSpell.jargon'],
+ $this->_config['PSpell.encoding']
+ );
+
+ $plink = pspell_new_config($pspell_config);
+ }*/
+
+ if (!$plink)
+ $this->throwError("No PSpell link found opened.");
+
+ return $plink;
+ }
+}
+
+?>