7 * Copyright (c) 1999-2003 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 $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT;
20 $words = $_POST['words'];
21 $sqspell_use_app = $_POST['sqspell_use_app'];
24 * Because of the nature of Javascript, there is no way to efficiently
25 * pass an array. Hence, the words will arrive as a string separated by
26 * "%". To get the array, we explode the "%"'s.
27 * Dirty: yes. Is there a better solution? Let me know. ;)
29 $new_words = ereg_replace("%", "\n", $words);
31 * Load the user dictionary and see if there is anything in it.
33 $words=sqspell_getWords();
38 $words_dic="# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last "
39 . "Revision: " . date("Y-m-d")
40 . "\n# LANG: $SQSPELL_APP_DEFAULT\n# $SQSPELL_APP_DEFAULT\n";
41 $words_dic .= $new_words . "# End\n";
44 * Do some fancy stuff in order to save the dictionary and not mangle the
47 $langs=sqspell_getSettings($words);
48 $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
49 . "Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs)
51 for ($i=0; $i<sizeof($langs); $i++){
52 $lang_words=sqspell_getLang($words, $langs[$i]);
53 if ($langs[$i]==$sqspell_use_app){
55 $lang_words="# $langs[$i]\n";
57 $lang_words .= $new_words;
59 $words_dic .= $lang_words;
61 $words_dic .= "# End\n";
67 sqspell_writeWords($words_dic);
69 * display the splash screen, then close it automatically after 2 sec.
71 $onload = "setTimeout('self.close()', 2000)";
72 $msg = '<form onsubmit="return false"><div align="center">'
73 . '<input type="submit" value=" '
74 . _("Close") . ' " onclick="self.close()"></div></form>';
75 sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);