]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/js/tiny_mce/plugins/spellchecker/classes/PSpellShell.php
Imported Upstream version 0.5
[roundcube.git] / program / js / tiny_mce / plugins / spellchecker / classes / PSpellShell.php
diff --git a/program/js/tiny_mce/plugins/spellchecker/classes/PSpellShell.php b/program/js/tiny_mce/plugins/spellchecker/classes/PSpellShell.php
deleted file mode 100755 (executable)
index 0bc57de..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php\r
-/**\r
- * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $\r
- *\r
- * @author Moxiecode\r
- * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
- */\r
-\r
-class PSpellShell extends SpellChecker {\r
-       /**\r
-        * Spellchecks an array of words.\r
-        *\r
-        * @param {String} $lang Language code like sv or en.\r
-        * @param {Array} $words Array of words to spellcheck.\r
-        * @return {Array} Array of misspelled words.\r
-        */\r
-       function &checkWords($lang, $words) {\r
-               $cmd = $this->_getCMD($lang);\r
-\r
-               if ($fh = fopen($this->_tmpfile, "w")) {\r
-                       fwrite($fh, "!\n");\r
-\r
-                       foreach($words as $key => $value)\r
-                               fwrite($fh, "^" . $value . "\n");\r
-\r
-                       fclose($fh);\r
-               } else\r
-                       $this->throwError("PSpell support was not found.");\r
-\r
-               $data = shell_exec($cmd);\r
-               @unlink($this->_tmpfile);\r
-\r
-               $returnData = array();\r
-               $dataArr = preg_split("/[\r\n]/", $data, -1, PREG_SPLIT_NO_EMPTY);\r
-\r
-               foreach ($dataArr as $dstr) {\r
-                       $matches = array();\r
-\r
-                       // Skip this line.\r
-                       if (strpos($dstr, "@") === 0)\r
-                               continue;\r
-\r
-                       preg_match("/\& ([^ ]+) .*/i", $dstr, $matches);\r
-\r
-                       if (!empty($matches[1]))\r
-                               $returnData[] = utf8_encode(trim($matches[1]));\r
-               }\r
-\r
-               return $returnData;\r
-       }\r
-\r
-       /**\r
-        * Returns suggestions of for a specific word.\r
-        *\r
-        * @param {String} $lang Language code like sv or en.\r
-        * @param {String} $word Specific word to get suggestions for.\r
-        * @return {Array} Array of suggestions for the specified word.\r
-        */\r
-       function &getSuggestions($lang, $word) {\r
-               $cmd = $this->_getCMD($lang);\r
-\r
-        if (function_exists("mb_convert_encoding"))\r
-            $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8"));\r
-        else\r
-            $word = utf8_encode($word);\r
-\r
-               if ($fh = fopen($this->_tmpfile, "w")) {\r
-                       fwrite($fh, "!\n");\r
-                       fwrite($fh, "^$word\n");\r
-                       fclose($fh);\r
-               } else\r
-                       $this->throwError("Error opening tmp file.");\r
-\r
-               $data = shell_exec($cmd);\r
-               @unlink($this->_tmpfile);\r
-\r
-               $returnData = array();\r
-               $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);\r
-\r
-               foreach($dataArr as $dstr) {\r
-                       $matches = array();\r
-\r
-                       // Skip this line.\r
-                       if (strpos($dstr, "@") === 0)\r
-                               continue;\r
-\r
-                       preg_match("/\&[^:]+:(.*)/i", $dstr, $matches);\r
-\r
-                       if (!empty($matches[1])) {\r
-                               $words = array_slice(explode(',', $matches[1]), 0, 10);\r
-\r
-                               for ($i=0; $i<count($words); $i++)\r
-                                       $words[$i] = trim($words[$i]);\r
-\r
-                               return $words;\r
-                       }\r
-               }\r
-\r
-               return array();\r
-       }\r
-\r
-       function _getCMD($lang) {\r
-               $this->_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell");\r
-\r
-               if(preg_match("#win#i", php_uname()))\r
-                       return $this->_config['PSpellShell.aspell'] . " -a --lang=". escapeshellarg($lang) . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";\r
-\r
-               return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". escapeshellarg($lang);\r
-       }\r
-}\r
-\r
-?>\r