Some uniformity into the sec index.php flavor
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me_not.mod
CommitLineData
849bdf42 1<?php
d112ed5a 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 */
849bdf42 17
d112ed5a 18global $words, $SQSPELL_VERSION, $SQSPELL_APP_DEFFAULT, $sqspell_use_app;
19/**
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. ;)
24 */
25$new_words = ereg_replace("%", "\n", $words);
26/**
27 * Load the user dictionary and see if there is anything in it.
28 */
29$words=sqspell_getWords();
30if (!$words){
31 /**
32 * First time.
33 */
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";
38} else {
39 /**
40 * Do some fancy stuff in order to save the dictionary and not mangle the
41 * rest.
42 */
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)
46 . "\n";
47 for ($i=0; $i<sizeof($langs); $i++){
48 $lang_words=sqspell_getLang($words, $langs[$i]);
49 if ($langs[$i]==$sqspell_use_app){
50 if (!$lang_words) {
51 $lang_words="# $langs[$i]\n";
52 }
53 $lang_words .= $new_words;
2b5a7157 54 }
d112ed5a 55 $words_dic .= $lang_words;
56 }
57 $words_dic .= "# End\n";
58}
2b5a7157 59
d112ed5a 60/**
61 * Write out the file
62 */
63sqspell_writeWords($words_dic);
64/**
65 * display the splash screen, then close it automatically after 2 sec.
66 */
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>';
71sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
72
73/**
74 * For Emacs weenies:
75 * Local variables:
76 * mode: php
77 * End:
78 */
79
15e6162e 80?>