summaryrefslogtreecommitdiff
path: root/program/steps/utils
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/utils')
-rw-r--r--program/steps/utils/spell.inc13
-rw-r--r--program/steps/utils/spell_html.inc4
2 files changed, 15 insertions, 2 deletions
diff --git a/program/steps/utils/spell.inc b/program/steps/utils/spell.inc
index 358576c7c..b485545be 100644
--- a/program/steps/utils/spell.inc
+++ b/program/steps/utils/spell.inc
@@ -23,6 +23,8 @@
$lang = get_input_value('lang', RCUBE_INPUT_GET);
$data = file_get_contents('php://input');
+$learn_word = strpos($data, '<learnword>');
+
// Get data string
$left = strpos($data, '<text>');
$right = strrpos($data, '</text>');
@@ -30,8 +32,15 @@ $data = substr($data, $left+6, $right-($left+6));
$data = html_entity_decode($data, ENT_QUOTES, RCMAIL_CHARSET);
$spellchecker = new rcube_spellchecker($lang);
-$spellchecker->check($data);
-$result = $spellchecker->get_xml();
+
+if ($learn_word) {
+ $spellchecker->add_word($data);
+ $result = '<?xml version="1.0" encoding="'.RCMAIL_CHARSET.'"?><learnwordresult></learnwordresult>';
+}
+else {
+ $spellchecker->check($data);
+ $result = $spellchecker->get_xml();
+}
// set response length
header("Content-Length: " . strlen($result));
diff --git a/program/steps/utils/spell_html.inc b/program/steps/utils/spell_html.inc
index d69c73f37..2af30ba00 100644
--- a/program/steps/utils/spell_html.inc
+++ b/program/steps/utils/spell_html.inc
@@ -40,6 +40,10 @@ if ($request['method'] == 'checkWords') {
else if ($request['method'] == 'getSuggestions') {
$result['result'] = $spellchecker->get_suggestions($data);
}
+else if ($request['method'] == 'learnWord') {
+ $spellchecker->add_word($data);
+ $result['result'] = true;
+}
if ($error = $spellchecker->error()) {
echo '{"error":{"errstr":"' . addslashes($error) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}';