From bc3f3685c81b2ce62ac8e0e35f5fb5e22e318b94 Mon Sep 17 00:00:00 2001 From: alec Date: Mon, 30 May 2011 15:08:26 +0000 Subject: - Provided rcube_spellchecker class, simplified code in utils task (less spell* files) git-svn-id: https://svn.roundcube.net/trunk@4815 208e9e7b-5314-0410-a742-e7e81cd9613c --- .../program/steps/utils/spell_html_pspell.inc | 76 ---------------------- 1 file changed, 76 deletions(-) delete mode 100644 roundcubemail/program/steps/utils/spell_html_pspell.inc (limited to 'roundcubemail/program/steps/utils/spell_html_pspell.inc') diff --git a/roundcubemail/program/steps/utils/spell_html_pspell.inc b/roundcubemail/program/steps/utils/spell_html_pspell.inc deleted file mode 100644 index f8c3d38cd..000000000 --- a/roundcubemail/program/steps/utils/spell_html_pspell.inc +++ /dev/null @@ -1,76 +0,0 @@ - | - +-----------------------------------------------------------------------+ - - $Id: spell_pspell.inc 3780 2010-06-23 09:55:08Z alec $ - -*/ - -function json_error($str) -{ - echo '{"error":{"errstr":"' . addslashes($str) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'; - exit; -} - -if (!extension_loaded('pspell')) { - raise_error(array( - 'code' => 500, - 'type' => 'php', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Pspell extension not available"), true, false); - - json_error("Pspell extension not available"); -} - -// read input -$data = file_get_contents('php://input'); - -// Decode JSON input -$request = json_decode($data, true); -$result = array(); - -$lang = $request['params'][0]; -$data = $request['params'][1]; -$result['id'] = $request['id']; - -// init spellchecker -$plink = pspell_new($lang, null, null, RCMAIL_CHARSET, PSPELL_FAST); - -if (!$plink) { - json_error("Unable to load Pspell engine for selected language"); -} - -if ($request['method'] == 'checkWords') { - $result['result'] = array(); - foreach ((array)$data as $word) { - if ($word && preg_match('/[^0-9\.]/', $word) - && !pspell_check($plink, $word)) { - $result['result'][] = $word; - } - } -} -else if ($request['method'] == 'getSuggestions') { - $suggestions = pspell_suggest($plink, $data); - if (sizeof($suggestions)>MAX_SUGGESTIONS) - $suggestions = array_slice($suggestions, 0, MAX_SUGGESTIONS); - $result['result'] = $suggestions; -} - -// send output -header("Content-Type: text/xml; charset=".RCMAIL_CHARSET); -echo json_encode($result); -exit; - -- cgit v1.2.3