Getting ready for 1.4.0 RC1
[squirrelmail.git] / plugins / squirrelspell / modules / edit_dic.mod
CommitLineData
849bdf42 1<?php
d112ed5a 2/**
3 * edit_dic.mod
4 * -------------
5 * Squirrelspell module
6 *
76911253 7 * Copyright (c) 1999-2003 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 *
12 * $Id$
13 *
14 * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
15 * @version $Date
16 */
2b5a7157 17
d112ed5a 18global $color;
19/**
20 * Get the user dictionary and see if it's empty or not.
21 */
22$words=sqspell_getWords();
23if (!$words){
24 /**
25 * Agt. Smith: "You're empty."
26 * Neo: "So are you."
27 */
28 sqspell_makePage(_("Personal Dictionary"), null,
29 '<p>' . _("No words in your personal dictionary.")
30 . '</p>');
31} else {
32 /**
33 * We're loaded with booty.
34 */
35 $pre_msg = '<p>'
36 . _("Please check any words you wish to delete from your dictionary.")
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) {
d112ed5a 55 $msg = $pre_msg;
56 }
57 $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>"
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">'
62 . '<input type="hidden" name="sqspell_use_app" value="'
63 . $langs[$i] . '">'
64 . '<table border="0" width="95%" align="center">'
65 . '<tr>'
66 . "<td valign=\"top\">\n";
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 /**
76 * Do some fancy stuff to separate the words into three
77 * columns.
78 */
79 for ($j=0; $j<sizeof($words_ary); $j++){
80 if ($j==intval(sizeof($words_ary)/3)
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=\"$words_ary[$j]\"> $words_ary[$j]<br>";
86 }
87 $msg .= '</td></tr></table></td></tr>'
2a917bbc 88 . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>"
d112ed5a 89 . '<input type="submit" value="' . _("Delete checked words")
90 . '"></form>'
91 . '</td></tr><tr><td><hr>'
92 . "</td></tr>\n";
2b5a7157 93 }
d112ed5a 94 }
95 /**
96 * Check if all dictionaries were empty.
97 */
98 if (!$msg) {
99 $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
100 } else {
101 $msg .= '</table>';
102 }
103 sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg);
104}
105
106/**
107 * For Emacs weenies:
108 * Local variables:
109 * mode: php
110 * End:
111 */
2b5a7157 112
15e6162e 113?>