commit | author | age
|
b4edf7
|
1 |
<?php |
A |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/utils/spell_html.inc | |
|
6 |
| | |
|
7 |
| This file is part of the Roundcube Webmail client | |
|
8 |
| Copyright (C) 2005-2011, The Roundcube Dev Team | |
|
9 |
| Licensed under the GNU GPL | |
|
10 |
| | |
|
11 |
| PURPOSE: | |
|
12 |
| Spellchecker for TinyMCE | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Aleksander Machniak <alec@alec.pl> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
// read input data |
|
23 |
$data = file_get_contents('php://input'); |
|
24 |
|
|
25 |
// Decode JSON input |
|
26 |
$request = json_decode($data, true); |
|
27 |
$result = array(); |
|
28 |
|
|
29 |
$lang = $request['params'][0]; |
|
30 |
$data = $request['params'][1]; |
|
31 |
$data = implode("\n", (array) $data); |
|
32 |
|
|
33 |
$result['id'] = $request['id']; |
|
34 |
|
|
35 |
$spellchecker = new rcube_spellchecker($lang); |
|
36 |
|
|
37 |
if ($request['method'] == 'checkWords') { |
|
38 |
$result['result'] = $spellchecker->get_words($data); |
|
39 |
} |
|
40 |
else if ($request['method'] == 'getSuggestions') { |
|
41 |
$result['result'] = $spellchecker->get_suggestions($data); |
|
42 |
} |
66df08
|
43 |
else if ($request['method'] == 'learnWord') { |
A |
44 |
$spellchecker->add_word($data); |
|
45 |
$result['result'] = true; |
|
46 |
} |
b4edf7
|
47 |
|
A |
48 |
if ($error = $spellchecker->error()) { |
|
49 |
echo '{"error":{"errstr":"' . addslashes($error) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'; |
|
50 |
exit; |
|
51 |
} |
|
52 |
|
|
53 |
// send output |
|
54 |
header("Content-Type: text/xml; charset=".RCMAIL_CHARSET); |
|
55 |
echo json_encode($result); |
|
56 |
exit; |
|
57 |
|