0
|
1 <?php
|
|
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 | |
|
|
10 | Licensed under the GNU General Public License version 3 or |
|
|
11 | any later version with exceptions for skins & plugins. |
|
|
12 | See the README file for a full license statement. |
|
|
13 | |
|
|
14 | PURPOSE: |
|
|
15 | Spellchecker for TinyMCE |
|
|
16 | |
|
|
17 +-----------------------------------------------------------------------+
|
|
18 | Author: Aleksander Machniak <alec@alec.pl> |
|
|
19 +-----------------------------------------------------------------------+
|
|
20 */
|
|
21
|
|
22 $method = rcube_utils::get_input_value('method', rcube_utils::INPUT_POST);
|
|
23 $lang = rcube_utils::get_input_value('lang', rcube_utils::INPUT_POST);
|
|
24 $result = array();
|
|
25
|
|
26 $spellchecker = new rcube_spellchecker($lang);
|
|
27
|
|
28 if ($method == 'addToDictionary') {
|
|
29 $data = rcube_utils::get_input_value('word', rcube_utils::INPUT_POST);
|
|
30
|
|
31 $spellchecker->add_word($data);
|
|
32 $result['result'] = true;
|
|
33 }
|
|
34 else {
|
|
35 $data = rcube_utils::get_input_value('text', rcube_utils::INPUT_POST, true);
|
|
36 $data = html_entity_decode($data, ENT_QUOTES, RCUBE_CHARSET);
|
|
37
|
|
38 if ($data && !$spellchecker->check($data)) {
|
|
39 $result['words'] = $spellchecker->get();
|
|
40 $result['dictionary'] = (bool) $RCMAIL->config->get('spellcheck_dictionary');
|
|
41 }
|
|
42 }
|
|
43
|
|
44 if ($error = $spellchecker->error()) {
|
|
45 rcube::raise_error(array('code' => 500, 'type' => 'php',
|
|
46 'file' => __FILE__, 'line' => __LINE__,
|
|
47 'message' => sprintf("Spell check engine error: " . $error)),
|
|
48 true, false);
|
|
49
|
|
50 echo json_encode(array('error' => $error));
|
|
51 exit;
|
|
52 }
|
|
53
|
|
54 // send output
|
|
55 header("Content-Type: application/json; charset=".RCUBE_CHARSET);
|
|
56 echo json_encode($result);
|
|
57 exit;
|