You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spell_html.inc 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/utils/spell_html.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2011, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Spellchecker for TinyMCE |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Aleksander Machniak <alec@alec.pl> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. $method = rcube_utils::get_input_value('method', rcube_utils::INPUT_POST);
  21. $lang = rcube_utils::get_input_value('lang', rcube_utils::INPUT_POST);
  22. $result = array();
  23. $spellchecker = new rcube_spellchecker($lang);
  24. if ($method == 'addToDictionary') {
  25. $data = rcube_utils::get_input_value('word', rcube_utils::INPUT_POST);
  26. $spellchecker->add_word($data);
  27. $result['result'] = true;
  28. }
  29. else {
  30. $data = rcube_utils::get_input_value('text', rcube_utils::INPUT_POST, true);
  31. $data = html_entity_decode($data, ENT_QUOTES, RCUBE_CHARSET);
  32. if ($data && !$spellchecker->check($data)) {
  33. $result['words'] = $spellchecker->get();
  34. $result['dictionary'] = (bool) $RCMAIL->config->get('spellcheck_dictionary');
  35. }
  36. }
  37. if ($error = $spellchecker->error()) {
  38. rcube::raise_error(array('code' => 500, 'type' => 'php',
  39. 'file' => __FILE__, 'line' => __LINE__,
  40. 'message' => sprintf("Spell check engine error: " . $error)),
  41. true, false);
  42. echo json_encode(array('error' => $error));
  43. exit;
  44. }
  45. // send output
  46. header("Content-Type: application/json; charset=".RCUBE_CHARSET);
  47. echo json_encode($result);
  48. exit;