forget_me_not.mod 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * forget_me_not.mod
  4. * ------------------
  5. * Squirrelspell module
  6. *
  7. * Copyright (c) 1999-2002 The SquirrelMail development team
  8. * Licensed under the GNU GPL. For full terms see the file COPYING.
  9. *
  10. * This module saves the added words into the user dictionary. Called
  11. * after CHECK_ME module.
  12. *
  13. * $Id$
  14. *
  15. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  16. */
  17. global $words, $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT, $sqspell_use_app;
  18. /**
  19. * Because of the nature of Javascript, there is no way to efficiently
  20. * pass an array. Hence, the words will arrive as a string separated by
  21. * "%". To get the array, we explode the "%"'s.
  22. * Dirty: yes. Is there a better solution? Let me know. ;)
  23. */
  24. $new_words = ereg_replace("%", "\n", $words);
  25. /**
  26. * Load the user dictionary and see if there is anything in it.
  27. */
  28. $words=sqspell_getWords();
  29. if (!$words){
  30. /**
  31. * First time.
  32. */
  33. $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last "
  34. . "Revision: " . date("Y-m-d")
  35. . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n";
  36. $words_dic .= $new_words . "# End\n";
  37. } else {
  38. /**
  39. * Do some fancy stuff in order to save the dictionary and not mangle the
  40. * rest.
  41. */
  42. $langs=sqspell_getSettings($words);
  43. $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
  44. . "Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs)
  45. . "\n";
  46. for ($i=0; $i<sizeof($langs); $i++){
  47. $lang_words=sqspell_getLang($words, $langs[$i]);
  48. if ($langs[$i]==$sqspell_use_app){
  49. if (!$lang_words) {
  50. $lang_words="# $langs[$i]\n";
  51. }
  52. $lang_words .= $new_words;
  53. }
  54. $words_dic .= $lang_words;
  55. }
  56. $words_dic .= "# End\n";
  57. }
  58. /**
  59. * Write out the file
  60. */
  61. sqspell_writeWords($words_dic);
  62. /**
  63. * display the splash screen, then close it automatically after 2 sec.
  64. */
  65. $onload = "setTimeout('self.close()', 2000)";
  66. $msg = '<form onsubmit="return false"><div align="center">'
  67. . '<input type="submit" value=" '
  68. . _("Close") . ' " onclick="self.close()"></div></form>';
  69. sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
  70. /**
  71. * For Emacs weenies:
  72. * Local variables:
  73. * mode: php
  74. * End:
  75. */
  76. ?>