diff options
author | alecpl <alec@alec.pl> | 2011-09-06 13:39:45 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-09-06 13:39:45 +0000 |
commit | 66df084203a217ab74a416064c459cc3420a648c (patch) | |
tree | 2bcd7c9ffde91f22ed4e10ed3fcf780c7de0ab7b /program/steps | |
parent | eb2365c47814fd1d142da10ca77ed631bd819a89 (diff) |
- Merge devel-spellcheck branch:
- Added spellchecker exceptions dictionary (shared or per-user)
- Added possibility to ignore words containing caps, numbers, symbols (spellcheck_ignore_* options)
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/compose.inc | 11 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 21 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 5 | ||||
-rw-r--r-- | program/steps/utils/spell.inc | 13 | ||||
-rw-r--r-- | program/steps/utils/spell_html.inc | 4 |
5 files changed, 44 insertions, 10 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 38749675e..ddfd62772 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -697,8 +697,8 @@ function rcmail_compose_body($attrib) // include GoogieSpell if (!empty($CONFIG['enable_spellcheck'])) { - - $engine = $RCMAIL->config->get('spellcheck_engine','googie'); + $engine = $RCMAIL->config->get('spellcheck_engine','googie'); + $dictionary = (bool) $RCMAIL->config->get('spellcheck_dictionary'); $spellcheck_langs = (array) $RCMAIL->config->get('spellcheck_languages', array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español', 'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski', @@ -728,25 +728,28 @@ function rcmail_compose_body($attrib) foreach ($spellcheck_langs as $key => $name) { $editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key); } - + $OUTPUT->include_script('googiespell.js'); $OUTPUT->add_script(sprintf( - "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','?_task=utils&_action=spell&lang=');\n". + "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','?_task=utils&_action=spell&lang=', %s);\n". "googie.lang_chck_spell = \"%s\";\n". "googie.lang_rsm_edt = \"%s\";\n". "googie.lang_close = \"%s\";\n". "googie.lang_revert = \"%s\";\n". "googie.lang_no_error_found = \"%s\";\n". + "googie.lang_learn_word = \"%s\";\n". "googie.setLanguages(%s);\n". "googie.setCurrentLanguage('%s');\n". "googie.setSpellContainer('spellcheck-control');\n". "googie.decorateTextarea('%s');\n". "%s.set_env('spellcheck', googie);", + !empty($dictionary) ? 'true' : 'false', JQ(Q(rcube_label('checkspelling'))), JQ(Q(rcube_label('resumeediting'))), JQ(Q(rcube_label('close'))), JQ(Q(rcube_label('revertto'))), JQ(Q(rcube_label('nospellerrors'))), + JQ(Q(rcube_label('addtodict'))), json_serialize($spellcheck_langs), $lang, $attrib['id'], diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 54f955282..9e6b601a1 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -448,8 +448,9 @@ function rcmail_user_prefs($current=null) case 'compose': $blocks = array( - 'main' => array('name' => Q(rcube_label('mainoptions'))), - 'sig' => array('name' => Q(rcube_label('signatureoptions'))), + 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'spellcheck' => array('name' => Q(rcube_label('spellcheckoptions'))), + 'sig' => array('name' => Q(rcube_label('signatureoptions'))), ); // Show checkbox for HTML Editor @@ -549,12 +550,26 @@ function rcmail_user_prefs($current=null) $field_id = 'rcmfd_spellcheck_before_send'; $input_spellcheck = new html_checkbox(array('name' => '_spellcheck_before_send', 'id' => $field_id, 'value' => 1)); - $blocks['main']['options']['spellcheck_before_send'] = array( + $blocks['spellcheck']['options']['spellcheck_before_send'] = array( 'title' => html::label($field_id, Q(rcube_label('spellcheckbeforesend'))), 'content' => $input_spellcheck->show($config['spellcheck_before_send']?1:0), ); } + if ($config['enable_spellcheck']) { + foreach (array('syms', 'nums', 'caps') as $key) { + $key = 'spellcheck_ignore_'.$key; + if (!isset($no_override[$key])) { + $input_spellcheck = new html_checkbox(array('name' => '_'.$key, 'id' => 'rcmfd_'.$key, 'value' => 1)); + + $blocks['spellcheck']['options'][$key] = array( + 'title' => html::label($field_id, Q(rcube_label(str_replace('_', '', $key)))), + 'content' => $input_spellcheck->show($config[$key]?1:0), + ); + } + } + } + if (!isset($no_override['show_sig'])) { $field_id = 'rcmfd_show_sig'; $select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id)); diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index 208874f5d..7155575fc 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -71,6 +71,9 @@ switch ($CURR_SECTION) 'dsn_default' => isset($_POST['_dsn_default']) ? TRUE : FALSE, 'reply_same_folder' => isset($_POST['_reply_same_folder']) ? TRUE : FALSE, 'spellcheck_before_send' => isset($_POST['_spellcheck_before_send']) ? TRUE : FALSE, + 'spellcheck_ignore_syms' => isset($_POST['_spellcheck_ignore_syms']) ? TRUE : FALSE, + 'spellcheck_ignore_nums' => isset($_POST['_spellcheck_ignore_nums']) ? TRUE : FALSE, + 'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']) ? TRUE : FALSE, 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1, 'top_posting' => !empty($_POST['_top_posting']), 'strip_existing_sig' => isset($_POST['_strip_existing_sig']), @@ -167,7 +170,7 @@ switch ($CURR_SECTION) $a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p]; } } - + break; } 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"}}'; |