7 * Copyright (c) 1999-2004 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.
13 * @author Konstantin Riabitsev <icon@duke.edu>
16 * @subpackage squirrelspell
19 global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
21 $words = $_POST['words'];
22 $sqspell_use_app = $_POST['sqspell_use_app'];
25 * Because of the nature of Javascript, there is no way to efficiently
26 * pass an array. Hence, the words will arrive as a string separated by
27 * "%". To get the array, we explode the "%"'s.
28 * Dirty: yes. Is there a better solution? Let me know. ;)
30 $new_words = ereg_replace("%", "\n", $words);
32 * Load the user dictionary and see if there is anything in it.
34 $words=sqspell_getWords();
39 $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last "
40 . "Revision: " . date("Y-m-d")
41 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n";
42 $words_dic .= $new_words . "# End\n";
45 * Do some fancy stuff in order to save the dictionary and not mangle the
48 $langs=sqspell_getSettings($words);
49 $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
50 . "Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs)
52 for ($i=0; $i<sizeof($langs); $i++){
53 $lang_words=sqspell_getLang($words, $langs[$i]);
54 if ($langs[$i]==$sqspell_use_app){
56 $lang_words="# $langs[$i]\n";
58 $lang_words .= $new_words;
60 $words_dic .= $lang_words;
62 $words_dic .= "# End\n";
68 sqspell_writeWords($words_dic);
70 * display the splash screen, then close it automatically after 2 sec.
72 $onload = "setTimeout('self.close()', 2000)";
73 $msg = '<form onsubmit="return false"><div align="center">'
74 . '<input type="submit" value=" '
75 . _("Close") . ' " onclick="self.close()" /></div></form>';
76 sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);