849bdf42 |
1 | <?php |
d112ed5a |
2 | /** |
3 | * forget_me.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 deletes the words from the user dictionary. Called |
11 | * after EDIT_DIC module. |
12 | * |
44d661aa |
13 | * |
d112ed5a |
14 | * |
44d661aa |
15 | * @author Konstantin Riabitsev <icon@duke.edu> |
16 | * @version $Id$ |
17 | * @package plugins |
18 | * @subpackage squirrelspell |
d112ed5a |
19 | */ |
849bdf42 |
20 | |
d8aa9efe |
21 | global $SQSPELL_VERSION; |
22 | |
23 | $words_ary = $_POST['words_ary']; |
24 | $sqspell_use_app = $_POST['sqspell_use_app']; |
25 | |
d112ed5a |
26 | /** |
27 | * If something needs to be deleted, then $words_ary will be |
28 | * non-zero length. |
29 | */ |
30 | if (sizeof($words_ary)){ |
31 | $words=sqspell_getWords(); |
32 | $lang_words = sqspell_getLang($words, $sqspell_use_app); |
33 | $msg = '<p>' |
74091b64 |
34 | . sprintf(_("Deleting the following entries from %s dictionary:"), '<strong>'.$sqspell_use_app.'</strong>') |
d112ed5a |
35 | . '</p>' |
36 | . "<ul>\n"; |
37 | for ($i=0; $i<sizeof($words_ary); $i++){ |
38 | /** |
39 | * Remove word by word... |
40 | */ |
41 | $lang_words=str_replace("$words_ary[$i]\n", "", $lang_words); |
2b6b400e |
42 | $msg .= '<li>' . htmlspecialchars($words_ary[$i]) . "</li>\n"; |
d112ed5a |
43 | } |
44 | $new_words_ary=split("\n", $lang_words); |
45 | /** |
46 | * Wipe this lang, if only 2 members in array (no words left). |
47 | * # Language |
48 | * # End |
49 | */ |
50 | if (sizeof($new_words_ary)<=2) { |
51 | $lang_words=''; |
52 | } |
53 | $new_lang_words = $lang_words; |
54 | /** |
55 | * Write the dictionary back to the disk. |
56 | */ |
57 | $langs=sqspell_getSettings($words); |
58 | $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# " |
59 | . "Last Revision: " . date("Y-m-d") . "\n# LANG: " |
60 | . join(", ", $langs) . "\n"; |
61 | for ($i=0; $i<sizeof($langs); $i++){ |
62 | /** |
63 | * Only rewrite the contents of the selected language. |
64 | * Otherwise just write the contents back. |
65 | */ |
66 | if ($langs[$i]==$sqspell_use_app) { |
67 | $lang_words = $new_lang_words; |
2b5a7157 |
68 | } else { |
d112ed5a |
69 | $lang_words = sqspell_getLang($words, $langs[$i]); |
70 | } |
71 | if ($lang_words) { |
72 | $words_dic .= $lang_words; |
2b5a7157 |
73 | } |
d112ed5a |
74 | } |
75 | $words_dic .= "# End\n"; |
76 | sqspell_writeWords($words_dic); |
2a917bbc |
77 | $msg .= '</ul><p>' . _("All done!") . "</p>\n"; |
d112ed5a |
78 | sqspell_makePage(_("Personal Dictionary Updated"), null, $msg); |
79 | } else { |
80 | /** |
81 | * Click on some words first, Einstein! |
82 | */ |
83 | sqspell_makePage(_("Personal Dictionary"), null, |
44d661aa |
84 | '<p>' . _("No changes requested.") . '</p>'); |
d112ed5a |
85 | } |
86 | |
87 | /** |
88 | * For Emacs weenies: |
89 | * Local variables: |
90 | * mode: php |
91 | * End: |
2b6b400e |
92 | * vim: syntax=php |
d112ed5a |
93 | */ |
3392dc86 |
94 | ?> |