X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Fsteps%2Futils%2Fspell_html.inc;fp=program%2Fsteps%2Futils%2Fspell_html.inc;h=d0324c6176174f36aa6be59ef4341e44f09e3b47;hb=a2dd2e41259a5e90016efcd7d083020b95e25527;hp=0000000000000000000000000000000000000000;hpb=fe4a852cd4335d3d2089b13e10d409fa2fa816d8;p=roundcube.git diff --git a/program/steps/utils/spell_html.inc b/program/steps/utils/spell_html.inc new file mode 100644 index 0000000..d0324c6 --- /dev/null +++ b/program/steps/utils/spell_html.inc @@ -0,0 +1,53 @@ + | + +-----------------------------------------------------------------------+ + + $Id: spell_html.inc 4815 2011-05-30 15:08:26Z alec $ + +*/ + +// read input data +$data = file_get_contents('php://input'); + +// Decode JSON input +$request = json_decode($data, true); +$result = array(); + +$lang = $request['params'][0]; +$data = $request['params'][1]; +$data = implode("\n", (array) $data); + +$result['id'] = $request['id']; + +$spellchecker = new rcube_spellchecker($lang); + +if ($request['method'] == 'checkWords') { + $result['result'] = $spellchecker->get_words($data); +} +else if ($request['method'] == 'getSuggestions') { + $result['result'] = $spellchecker->get_suggestions($data); +} + +if ($error = $spellchecker->error()) { + echo '{"error":{"errstr":"' . addslashes($error) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'; + exit; +} + +// send output +header("Content-Type: text/xml; charset=".RCMAIL_CHARSET); +echo json_encode($result); +exit; +