849bdf42 |
1 | <?php |
d112ed5a |
2 | /** |
3 | * edit_dic.mod |
4 | * ------------- |
5 | * Squirrelspell module |
6 | * |
6c84ba1e |
7 | * Copyright (c) 1999-2005 The SquirrelMail development team |
d112ed5a |
8 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
9 | * |
10 | * This module lets the user edit his/her personal dictionary. |
11 | * |
44d661aa |
12 | * @author Konstantin Riabitsev <icon@duke.edu> |
13 | * @version $Id$ |
14 | * @package plugins |
15 | * @subpackage squirrelspell |
d112ed5a |
16 | */ |
2b5a7157 |
17 | |
d112ed5a |
18 | global $color; |
19 | /** |
20 | * Get the user dictionary and see if it's empty or not. |
21 | */ |
22 | $words=sqspell_getWords(); |
23 | if (!$words){ |
24 | /** |
25 | * Agt. Smith: "You're empty." |
26 | * Neo: "So are you." |
27 | */ |
91e0dccc |
28 | sqspell_makePage(_("Personal Dictionary"), null, |
29 | '<p>' . _("No words in your personal dictionary.") |
44d661aa |
30 | . '</p>'); |
d112ed5a |
31 | } else { |
32 | /** |
33 | * We're loaded with booty. |
34 | */ |
91e0dccc |
35 | $pre_msg = '<p>' |
36 | . _("Please check any words you wish to delete from your dictionary.") |
d112ed5a |
37 | . "</p>\n"; |
38 | $pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n"; |
39 | /** |
40 | * Get how many dictionaries this user has defined. |
41 | */ |
42 | $langs=sqspell_getSettings($words); |
43 | for ($i=0; $i<sizeof($langs); $i++){ |
44 | /** |
45 | * Get all words from this language dictionary. |
46 | */ |
47 | $lang_words = sqspell_getLang($words, $langs[$i]); |
48 | if ($lang_words){ |
49 | /** |
50 | * There are words in this dictionary. If this is the first |
51 | * language we're processing, prepend the output with the |
52 | * "header" message. |
53 | */ |
48a1015b |
54 | if (!isset($msg) || !$msg) { |
44d661aa |
55 | $msg = $pre_msg; |
d112ed5a |
56 | } |
57 | $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>" |
44d661aa |
58 | . sprintf( _("%s dictionary"), $langs[$i] ) . '</th></tr>' |
59 | . '<tr><td align="center">' |
60 | . '<form method="post">' |
61 | . '<input type="hidden" name="MOD" value="forget_me" />' |
91e0dccc |
62 | . '<input type="hidden" name="sqspell_use_app" value="' |
44d661aa |
63 | . $langs[$i] . '" />' |
64 | . '<table border="0" width="95%" align="center">' |
65 | . '<tr>' |
66 | . "<td valign=\"top\">\n"; |
d112ed5a |
67 | $words_ary=explode("\n", $lang_words); |
68 | /** |
69 | * There are two lines we need to remove: |
70 | * 1st: # Language |
71 | * last: # End |
72 | */ |
73 | array_pop($words_ary); |
74 | array_shift($words_ary); |
75 | /** |
91e0dccc |
76 | * Do some fancy stuff to separate the words into three |
d112ed5a |
77 | * columns. |
78 | */ |
79 | for ($j=0; $j<sizeof($words_ary); $j++){ |
91e0dccc |
80 | if ($j==intval(sizeof($words_ary)/3) |
44d661aa |
81 | || $j==intval(sizeof($words_ary)/3*2)){ |
82 | $msg .= "</td><td valign=\"top\">\n"; |
83 | } |
84 | $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" " |
85 | . 'value="'.htmlspecialchars($words_ary[$j]). '" /> ' |
86 | . htmlspecialchars($words_ary[$j]) . "<br />\n"; |
d112ed5a |
87 | } |
88 | $msg .= '</td></tr></table></td></tr>' |
44d661aa |
89 | . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>" |
91e0dccc |
90 | . '<input type="submit" value="' . _("Delete checked words") |
44d661aa |
91 | . '" /></form>' |
92 | . '</td></tr><tr><td><hr />' |
93 | . "</td></tr>\n"; |
2b5a7157 |
94 | } |
d112ed5a |
95 | } |
96 | /** |
97 | * Check if all dictionaries were empty. |
98 | */ |
44d661aa |
99 | if (! isset($msg)) { |
d112ed5a |
100 | $msg = '<p>' . _("No words in your personal dictionary.") . '</p>'; |
101 | } else { |
102 | $msg .= '</table>'; |
103 | } |
104 | sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg); |
105 | } |
106 | |
107 | /** |
108 | * For Emacs weenies: |
109 | * Local variables: |
110 | * mode: php |
111 | * End: |
2b6b400e |
112 | * vim: syntax=php |
d112ed5a |
113 | */ |
2b5a7157 |
114 | |
04fa3c41 |
115 | ?> |