Getting ready for 1.4.0 RC1
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me_not.mod
1 <?php
2 /**
3 * forget_me_not.mod
4 * ------------------
5 * Squirrelspell module
6 *
7 * Copyright (c) 1999-2003 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
18 global $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT;
19
20 $words = $_POST['words'];
21 $sqspell_use_app = $_POST['sqspell_use_app'];
22
23 /**
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. ;)
28 */
29 $new_words = ereg_replace("%", "\n", $words);
30 /**
31 * Load the user dictionary and see if there is anything in it.
32 */
33 $words=sqspell_getWords();
34 if (!$words){
35 /**
36 * First time.
37 */
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";
42 } else {
43 /**
44 * Do some fancy stuff in order to save the dictionary and not mangle the
45 * rest.
46 */
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)
50 . "\n";
51 for ($i=0; $i<sizeof($langs); $i++){
52 $lang_words=sqspell_getLang($words, $langs[$i]);
53 if ($langs[$i]==$sqspell_use_app){
54 if (!$lang_words) {
55 $lang_words="# $langs[$i]\n";
56 }
57 $lang_words .= $new_words;
58 }
59 $words_dic .= $lang_words;
60 }
61 $words_dic .= "# End\n";
62 }
63
64 /**
65 * Write out the file
66 */
67 sqspell_writeWords($words_dic);
68 /**
69 * display the splash screen, then close it automatically after 2 sec.
70 */
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);
76
77 /**
78 * For Emacs weenies:
79 * Local variables:
80 * mode: php
81 * End:
82 */
83
84 ?>