]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/utils/spell.inc
Imported Upstream version 0.7
[roundcube.git] / program / steps / utils / spell.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/utils/spell.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  |   Invoke the configured or default spell checking engine.             |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Kris Steinhoff <steinhof@umich.edu>                           |
16  +-----------------------------------------------------------------------+
17
18  $Id: spell.inc 5181 2011-09-06 13:39:45Z alec $
19
20 */
21
22 // read input
23 $lang = get_input_value('lang', RCUBE_INPUT_GET);
24 $data = file_get_contents('php://input');
25
26 $learn_word = strpos($data, '<learnword>');
27
28 // Get data string
29 $left = strpos($data, '<text>');
30 $right = strrpos($data, '</text>');
31 $data = substr($data, $left+6, $right-($left+6));
32 $data = html_entity_decode($data, ENT_QUOTES, RCMAIL_CHARSET);
33
34 $spellchecker = new rcube_spellchecker($lang);
35
36 if ($learn_word) {
37     $spellchecker->add_word($data);
38     $result = '<?xml version="1.0" encoding="'.RCMAIL_CHARSET.'"?><learnwordresult></learnwordresult>';
39 }
40 else {
41     $spellchecker->check($data);
42     $result = $spellchecker->get_xml();
43 }
44
45 // set response length
46 header("Content-Length: " . strlen($result));
47
48 // Don't use server's default Content-Type charset (#1486406)
49 header("Content-Type: text/xml; charset=" . RCMAIL_CHARSET);
50 print $result;
51 exit;