Lots of little UI tweaks and some handsome borders in the Options and Folder areas.
[squirrelmail.git] / src / options_highlight.php
1 <?php
2 /**
3 ** options_highlight.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Displays message highlighting options
9 **
10 ** $Id$
11 **/
12
13 include('../src/validate.php');
14 include('../functions/page_header.php');
15 include('../functions/display_messages.php');
16 include('../functions/imap.php');
17 include('../functions/array.php');
18 include('../functions/plugin.php');
19
20 if (! isset($action))
21 $action = '';
22 if (! isset($message_highlight_list))
23 $message_highlight_list = array();
24
25 if ($action == 'delete' && isset($theid)) {
26 removePref($data_dir, $username, "highlight$theid");
27 } else if ($action == 'save') {
28 if (!$theid) $theid = 0;
29 $identname = ereg_replace(',', ' ', $identname);
30 $identname = str_replace('\\\\', '\\', $identname);
31 $identname = str_replace('\\"', '"', $identname);
32 $identname = str_replace('"', '&quot;', $identname);
33 if ($color_type == 1) $newcolor = $newcolor_choose;
34 else $newcolor = $newcolor_input;
35
36 $newcolor = ereg_replace(',', '', $newcolor);
37 $newcolor = ereg_replace('#', '', $newcolor);
38 $newcolor = "$newcolor";
39 $value = ereg_replace(',', ' ', $value);
40 $value = str_replace('\\\\', '\\', $value);
41 $value = str_replace('\\"', '"', $value);
42 $value = str_replace('"', '&quot;', $value);
43
44 setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type);
45 $message_highlight_list[$theid]['name'] = $identname;
46 $message_highlight_list[$theid]['color'] = $newcolor;
47 $message_highlight_list[$theid]['value'] = $value;
48 $message_highlight_list[$theid]['match_type'] = $match_type;
49 }
50 include('../src/load_prefs.php');
51 displayPageHeader($color, 'None');
52 ?>
53 <br>
54 <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
55 <tr><td bgcolor="<?php echo $color[0] ?>" align="center">
56
57 <b><?php echo _("Options") . ' - ' . _("Message Highlighting"); ?></b>
58
59 <table width="100%" cellpadding="1" cellspacing="1" border="0">
60 <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
61 <?php
62 echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]';
63 echo ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
64 if (count($message_highlight_list) >= 1) {
65 echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n";
66 for ($i=0; $i < count($message_highlight_list); $i++) {
67 echo "<tr>\n";
68 echo ' <td width="1%" bgcolor="' . $color[4] . "\">\n";
69 echo "<nobr><small>[<a href=\"options_highlight.php?action=edit&theid=$i\">" . _("Edit") . "</a>]&nbsp;[<a href=\"options_highlight.php?action=delete&theid=$i\">"._("Delete")."</a>]</small></nobr>\n";
70 echo ' </td>';
71 echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n";
72 echo ' ' . $message_highlight_list[$i]['name'] . '&nbsp;';
73 echo " </td>\n";
74 echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n";
75 echo ' '.$message_highlight_list[$i]['match_type'].' = ' . $message_highlight_list[$i]['value'];
76 echo " </td>\n";
77 echo "</tr>\n";
78 }
79 echo "</table>\n";
80 echo "<br>\n";
81 } else {
82 echo _("No highlighting is defined") . "<br>\n";
83 echo "<br>\n";
84 }
85 if ($action == 'edit' || $action == 'add') {
86 if (!isset($theid))
87 {
88 $theid = count($message_highlight_list);
89 $message_highlight_list[$theid] = array();
90 }
91
92 $color_list[0] = '4444aa';
93 $color_list[1] = '44aa44';
94 $color_list[2] = 'aaaa44';
95 $color_list[3] = '44aaaa';
96 $color_list[4] = 'aa44aa';
97 $color_list[5] = 'aaaaff';
98 $color_list[6] = 'aaffaa';
99 $color_list[7] = 'ffffaa';
100 $color_list[8] = 'aaffff';
101 $color_list[9] = 'ffaaff';
102 $color_list[10] = 'aaaaaa';
103 $color_list[11] = 'bfbfbf';
104 $color_list[12] = 'dfdfdf';
105 $color_list[13] = 'ffffff';
106
107 $selected_input = '';
108 $selected_choose = '';
109
110 for ($i=0; $i < 14; $i++) {
111 ${"selected".$i} = '';
112 }
113 if (isset($message_highlight_list[$theid]['color'])) {
114 for ($i=0; $i < 14; $i++) {
115 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
116 $selected_choose = ' checked';
117 ${"selected".$i} = ' selected';
118 continue;
119 }
120 }
121 }
122 if (!isset($message_highlight_list[$theid]['color']))
123 $selected_choose = ' checked';
124 else if ($selected_choose == '')
125 $selected_input = ' checked';
126
127 echo '<form name="f" action="options_highlight.php">' . "\n";
128 echo '<input type="hidden" value="save" name="action">' . "\n";
129 echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n";
130 echo '<table width="80%" align="center" cellpadding="3" cellspacing="0" border="0">' . "\n";
131 echo " <tr bgcolor=\"$color[0]\">\n";
132 echo " <td align=\"right\" width=\"25%\"><b>\n";
133 echo _("Identifying name") . ":";
134 echo ' </b></td>' . "\n";
135 echo ' <td width="75%">' . "\n";
136 if (isset($message_highlight_list[$theid]['name']))
137 $disp = $message_highlight_list[$theid]['name'];
138 else
139 $disp = '&nbsp;';
140 $disp = str_replace('\\\\', '\\', $disp);
141 $disp = str_replace('\\"', '"', $disp);
142 $disp = str_replace('"', '&quot;', $disp);
143 echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
144 echo " </td>\n";
145 echo " </tr>\n";
146 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
147 echo " <tr bgcolor=\"$color[0]\">\n";
148 echo ' <td align="right" width="25%"><b>' . "\n";
149 echo _("Color") . ':';
150 echo " </b></td>\n";
151 echo ' <td width="75%">' . "\n";
152 echo " <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
153 echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
154 echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
155 echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
156 echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
157 echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
158 echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
159 echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
160 echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
161 echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
162 echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
163 echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
164 echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
165 echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
166 echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
167 echo " </select><br>\n";
168 echo " <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
169 if ($selected_input)
170 echo $message_highlight_list[$theid]["color"];
171 echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n";
172 echo " </td>\n";
173 echo " </tr>\n";
174 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
175 echo " <tr bgcolor=\"$color[0]\">\n";
176 echo ' <td align="right" width="25%"><b>' . "\n";
177 echo _("Match") . ':';
178 echo " </b></td>\n";
179 echo ' <td width="75%">' . "\n";
180 echo " <select name=match_type>\n";
181 if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'from')
182 echo " <option value=\"from\" selected>From\n";
183 else
184 echo " <option value=\"from\">From\n";
185 if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'to')
186 echo " <option value=\"to\" selected>To\n";
187 else
188 echo " <option value=\"to\">To\n";
189 if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'cc')
190 echo " <option value=\"cc\" selected>Cc\n";
191 else
192 echo " <option value=\"cc\">Cc\n";
193 if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'to_cc')
194 echo " <option value=\"to_cc\" selected>To or Cc\n";
195 else
196 echo " <option value=\"to_cc\">To or Cc\n";
197 if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'subject')
198 echo " <option value=\"subject\" selected>Subject\n";
199 else
200 echo " <option value=\"subject\">Subject\n";
201 echo " </select>\n";
202 if (isset($message_highlight_list[$theid]['value']))
203 $disp = $message_highlight_list[$theid]['value'];
204 else
205 $disp = '';
206 $disp = str_replace('\\\\', '\\', $disp);
207 $disp = str_replace('\\"', '"', $disp);
208 $disp = str_replace('"', '&quot;', $disp);
209 echo ' <nobr><input type="text" value="'.$disp.'" name="value">';
210 echo " <nobr></td>\n";
211 echo " </tr>\n";
212 echo "</table>\n";
213 echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
214 echo "</form>\n";
215 }
216 ?>
217
218 <?php do_hook('options_highlight_bottom'); ?>
219
220 </td></tr>
221 </table>
222
223 </td></tr>
224 </table>
225 </body></html>