summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/spellchecker
diff options
context:
space:
mode:
authorsvncommit <devs@roundcube.net>2007-05-24 03:49:19 +0000
committersvncommit <devs@roundcube.net>2007-05-24 03:49:19 +0000
commit2c633703e97eb6e7aa7ba840ef86b1fc1bd98ada (patch)
tree39cf2cada6948a447985436c1d6f7f2b512cba20 /program/js/tiny_mce/plugins/spellchecker
parent597c09cf972ffb3c4e86adfcd79aa86b0258d3a8 (diff)
upgrade to TinyMCE v2.1.1.1
Diffstat (limited to 'program/js/tiny_mce/plugins/spellchecker')
-rw-r--r--program/js/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php74
-rw-r--r--program/js/tiny_mce/plugins/spellchecker/config.php4
2 files changed, 40 insertions, 38 deletions
diff --git a/program/js/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/program/js/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
index 33e7b1cc1..7be929731 100644
--- a/program/js/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
+++ b/program/js/tiny_mce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
@@ -1,4 +1,5 @@
<?php
+
/* *
* Tiny Spelling Interface for TinyMCE Spell Checking.
*
@@ -7,19 +8,21 @@
class TinyGoogleSpell {
var $lang;
+ var $spellurl;
- function TinyGoogleSpell(&$config, $lang, $mode, $spelling, $jargon, $encoding) {
+ function TinyGoogleSpell(& $config, $lang, $mode, $spelling, $jargon, $encoding) {
$this->lang = $lang;
+ $this->spellurl = $config['googlespell.url'];
}
// Returns array with bad words or false if failed.
function checkWords($word_array) {
- $words = array();
+ $words = array ();
$wordstr = implode(' ', $word_array);
$matches = $this->_getMatches($wordstr);
- for ($i=0; $i<count($matches); $i++)
+ for ($i = 0; $i < count($matches); $i++)
$words[] = $this->unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8"));
return $words;
@@ -37,7 +40,7 @@ class TinyGoogleSpell {
// Returns array with suggestions or false if failed.
function getSuggestion($word) {
- $sug = array();
+ $sug = array ();
$matches = $this->_getMatches($word);
@@ -48,43 +51,41 @@ class TinyGoogleSpell {
}
function _xmlChars($string) {
- $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
-
- foreach ($trans as $k => $v)
- $trans[$k] = "&#".ord($k).";";
+ $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
+
+ foreach ($trans as $k => $v)
+ $trans[$k] = "&#" . ord($k) . ";";
- return strtr($string, $trans);
+ return strtr($string, $trans);
}
function _getMatches($word_list) {
- $server = "www.google.com";
- $port = 443;
- $path = "/tbproxy/spell?lang=" . $this->lang . "&hl=en";
- $host = "www.google.com";
- $url = "https://" . $server;
+ $url = $this->spellurl . "&" . $this->lang;
+
+ $path = preg_replace("/^https?:\/\//i", "", $url);
// Setup XML request
- $xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $word_list . '</text></spellrequest>';
-
- $header = "POST ".$path." HTTP/1.0 \r\n";
- $header .= "MIME-Version: 1.0 \r\n";
- $header .= "Content-type: application/PTI26 \r\n";
- $header .= "Content-length: ".strlen($xml)." \r\n";
- $header .= "Content-transfer-encoding: text \r\n";
- $header .= "Request-number: 1 \r\n";
- $header .= "Document-type: Request \r\n";
- $header .= "Interface-Version: Test 1.4 \r\n";
- $header .= "Connection: close \r\n\r\n";
- $header .= $xml;
+ $xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $word_list . '</text></spellrequest>';
+
+ $header = "POST " . $path . " HTTP/1.0 \r\n";
+ $header .= "MIME-Version: 1.0 \r\n";
+ $header .= "Content-type: application/PTI26 \r\n";
+ $header .= "Content-length: " . strlen($xml) . " \r\n";
+ $header .= "Content-transfer-encoding: text \r\n";
+ $header .= "Request-number: 1 \r\n";
+ $header .= "Document-type: Request \r\n";
+ $header .= "Interface-Version: Test 1.4 \r\n";
+ $header .= "Connection: close \r\n\r\n";
+ $header .= $xml;
//$this->_debugData($xml);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- $xml = curl_exec($ch);
- curl_close($ch);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+ $xml = curl_exec($ch);
+ curl_close($ch);
//$this->_debugData($xml);
@@ -95,13 +96,12 @@ class TinyGoogleSpell {
}
function _debugData($data) {
- $fh = @fopen("debug.log", 'a+');
- @fwrite($fh, $data);
- @fclose($fh);
+ $fh = @ fopen("debug.log", 'a+');
+ @ fwrite($fh, $data);
+ @ fclose($fh);
}
}
// Setup classname, should be the same as the name of the spellchecker class
$spellCheckerConfig['class'] = "TinyGoogleSpell";
-
?>
diff --git a/program/js/tiny_mce/plugins/spellchecker/config.php b/program/js/tiny_mce/plugins/spellchecker/config.php
index f008d11ca..6622248c0 100644
--- a/program/js/tiny_mce/plugins/spellchecker/config.php
+++ b/program/js/tiny_mce/plugins/spellchecker/config.php
@@ -21,4 +21,6 @@
// Pspell shell specific settings
$spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell';
$spellCheckerConfig['tinypspellshell.tmp'] = '/tmp';
-?>
+
+ $spellCheckerConfig['googlespell.url'] = 'https://www.google.com/tbproxy/spell?hl=en'
+?> \ No newline at end of file