adding address book block
[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 *
44d661aa 7 * Copyright (c) 1999-2004 The SquirrelMail development team
d112ed5a 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 *
44d661aa 13 * @author Konstantin Riabitsev <icon@duke.edu>
14 * @version $Id$
15 * @package plugins
16 * @subpackage squirrelspell
d112ed5a 17 */
849bdf42 18
847d7c93 19global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
d8aa9efe 20
21$words = $_POST['words'];
22$sqspell_use_app = $_POST['sqspell_use_app'];
23
d112ed5a 24/**
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. ;)
29 */
30$new_words = ereg_replace("%", "\n", $words);
31/**
32 * Load the user dictionary and see if there is anything in it.
33 */
34$words=sqspell_getWords();
35if (!$words){
36 /**
37 * First time.
38 */
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";
43} else {
44 /**
45 * Do some fancy stuff in order to save the dictionary and not mangle the
46 * rest.
47 */
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)
51 . "\n";
52 for ($i=0; $i<sizeof($langs); $i++){
53 $lang_words=sqspell_getLang($words, $langs[$i]);
54 if ($langs[$i]==$sqspell_use_app){
55 if (!$lang_words) {
44d661aa 56 $lang_words="# $langs[$i]\n";
d112ed5a 57 }
58 $lang_words .= $new_words;
2b5a7157 59 }
d112ed5a 60 $words_dic .= $lang_words;
61 }
62 $words_dic .= "# End\n";
63}
2b5a7157 64
d112ed5a 65/**
66 * Write out the file
67 */
68sqspell_writeWords($words_dic);
69/**
70 * display the splash screen, then close it automatically after 2 sec.
71 */
72$onload = "setTimeout('self.close()', 2000)";
73$msg = '<form onsubmit="return false"><div align="center">'
74 . '<input type="submit" value=" '
04fa3c41 75 . _("Close") . ' " onclick="self.close()" /></div></form>';
d112ed5a 76sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
77
78/**
79 * For Emacs weenies:
80 * Local variables:
81 * mode: php
82 * End:
2b6b400e 83 * vim: syntax=php
d112ed5a 84 */
85
04fa3c41 86?>