From b4edf78e4b75bc40a829147941ba0cf6379fbc39 Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 30 May 2011 15:08:26 +0000 Subject: - Provided rcube_spellchecker class, simplified code in utils task (less spell* files) --- program/steps/utils/spell_pspell.inc | 75 ------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 program/steps/utils/spell_pspell.inc (limited to 'program/steps/utils/spell_pspell.inc') diff --git a/program/steps/utils/spell_pspell.inc b/program/steps/utils/spell_pspell.inc deleted file mode 100644 index 44415cd60..000000000 --- a/program/steps/utils/spell_pspell.inc +++ /dev/null @@ -1,75 +0,0 @@ - | - +-----------------------------------------------------------------------+ - - $Id$ - -*/ - -if (!extension_loaded('pspell')) { - raise_error(array( - 'code' => 500, - 'type' => 'php', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Pspell extension not available"), true, false); - - header('HTTP/1.1 404 Not Found'); - exit; -} - -// read input -$data = file_get_contents('php://input'); - -// parse data (simplexml_load_string breaks CRLFs) -$left = strpos($data, ''); -$right = strrpos($data, ''); -$text = substr($data, $left+6, $right-($left+6)); -$text = html_entity_decode($text, ENT_QUOTES, RCMAIL_CHARSET); - -// tokenize -$words = preg_split('/[ !"#$%&()*+\\,\/\n:;<=>?@\[\]^_{|}-]+|\.[^\w]/', $text, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE ); - -// init spellchecker -$plink = pspell_new(get_input_value('lang', RCUBE_INPUT_GET), null, null, RCMAIL_CHARSET, PSPELL_FAST); - -// send output -$out = ''; - -$diff = 0; -foreach ($words as $w) { - $word = trim($w[0]); - $pos = $w[1] - $diff; - $len = mb_strlen($word); - if ($word && $plink && preg_match('/[^0-9\.]/', $word) - && !pspell_check($plink, $word)) { - $suggestions = pspell_suggest($plink, $word); - if (sizeof($suggestions)>MAX_SUGGESTIONS) - $suggestions = array_slice($suggestions, 0, MAX_SUGGESTIONS); - - $out .= ''; - $out .= implode("\t", $suggestions); - $out .= ''; - } - $diff += (strlen($word) - $len); -} - -$out .= ''; - -header("Content-Type: text/xml; charset=".RCMAIL_CHARSET); -echo $out; -exit; - - -- cgit v1.2.3