7 * Copyright (c) 1999-2002 The SquirrelMail development team
8 * Licensed under the GNU GPL. For full terms see the file COPYING.
10 * This module saves the added words into the user dictionary. Called
11 * after CHECK_ME module.
15 * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
18 global $words, $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT, $sqspell_use_app;
20 * Because of the nature of Javascript, there is no way to efficiently
21 * pass an array. Hence, the words will arrive as a string separated by
22 * "%". To get the array, we explode the "%"'s.
23 * Dirty: yes. Is there a better solution? Let me know. ;)
25 $new_words = ereg_replace("%", "\n", $words);
27 * Load the user dictionary and see if there is anything in it.
29 $words=sqspell_getWords();
34 $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last "
35 . "Revision: " . date("Y-m-d")
36 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n";
37 $words_dic .= $new_words . "# End\n";
40 * Do some fancy stuff in order to save the dictionary and not mangle the
43 $langs=sqspell_getSettings($words);
44 $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
45 . "Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs)
47 for ($i=0; $i<sizeof($langs); $i++){
48 $lang_words=sqspell_getLang($words, $langs[$i]);
49 if ($langs[$i]==$sqspell_use_app){
51 $lang_words="# $langs[$i]\n";
53 $lang_words .= $new_words;
55 $words_dic .= $lang_words;
57 $words_dic .= "# End\n";
63 sqspell_writeWords($words_dic);
65 * display the splash screen, then close it automatically after 2 sec.
67 $onload = "setTimeout('self.close()', 2000)";
68 $msg = '<form onsubmit="return false"><div align="center">'
69 . '<input type="submit" value=" '
70 . _("Close") . ' " onclick="self.close()"></div></form>';
71 sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);