49db257d |
1 | <?php |
2 | |
3 | /** |
4 | * message_list.tpl |
5 | * |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Template for viewing a messages list |
10 | * |
11 | * @version $Id$ |
12 | * @package squirrelmail |
13 | */ |
14 | |
15 | include_once(SM_PATH . 'templates/util_message_list.php'); |
16 | |
17 | /* retrieve the template vars */ |
18 | extract($t); |
19 | |
20 | do_hook('mailbox_index_before'); |
21 | |
22 | /** |
23 | * Calculate string "Viewing message x to y (z total)" |
24 | */ |
25 | $msg_cnt_str = ''; |
26 | if ($pageOffset < $end_msg) { |
27 | $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"), |
28 | '<b>'.$pageOffset.'</b>', '<b>'.$end_msg.'</b>', $iNumberOfMessages); |
29 | } else if ($pageOffset == $end_msg) { |
30 | $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$pageOffset.'</b>', $iNumberOfMessages); |
31 | } |
32 | |
33 | |
34 | |
35 | if (!($sort & SQSORT_THREAD) && $enablesort) { |
36 | $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC), |
37 | SQM_COL_DATE => array(SQSORT_DATE_ASC , SQSORT_DATE_DESC), |
38 | SQM_COL_INT_DATE => array(SQSORT_INT_DATE_ASC, SQSORT_INT_DATE_DESC), |
39 | SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC), |
40 | SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC), |
41 | SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC), |
42 | SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC)); |
43 | } else { |
44 | $aSortSupported = array(); |
45 | } |
46 | |
47 | // figure out which columns should serve as labels for checkbox: |
48 | // we try to grab the two columns before and after the checkbox, |
49 | // except the subject column, since it is the link that opens |
50 | // the message view |
51 | // |
52 | // if $javascript_on is set, then the highlighting code takes |
53 | // care of this; just skip it |
54 | // |
55 | $show_label_columns = array(); |
56 | $index_order_part = array(); |
57 | if (!($javascript_on && $fancy_index_highlite)) { |
58 | $get_next_two = 0; |
59 | $last_order_part = 0; |
60 | $last_last_order_part = 0; |
61 | foreach ($aOrder as $index_order_part) { |
62 | if ($index_order_part == SQM_COL_CHECK) { |
63 | $get_next_two = 1; |
64 | if ($last_last_order_part != SQM_COL_SUBJ) |
65 | $show_label_columns[] = $last_last_order_part; |
66 | if ($last_order_part != SQM_COL_SUBJ) |
67 | $show_label_columns[] = $last_order_part; |
68 | |
69 | } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) { |
70 | $show_label_columns[] = $index_order_part; |
71 | $get_next_two++; |
72 | } |
73 | $last_last_order_part = $last_order_part; |
74 | $last_order_part = $index_order_part; |
75 | } |
76 | } |
77 | |
78 | // set this to an empty string to turn off extra |
79 | // highlighting of checked rows |
80 | // |
81 | //$clickedColor = ''; |
82 | if (!empty($color[16])) |
83 | $clickedColor = $color[16]; |
84 | else |
85 | $clickedColor = $color[2]; |
86 | |
87 | |
88 | ?> |
89 | <form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>"> |
90 | <table border="0" width="100%" cellpadding="0" cellspacing="0"> |
91 | <tr> |
92 | <td> |
93 | <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>"> |
94 | <tr> |
95 | <td> |
96 | <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0"> |
97 | <tr> |
98 | <td align="<?php echo $align['left']; ?>"> |
99 | <small> |
100 | <!-- paginator and thread link string --> |
101 | <?php |
102 | /** |
103 | * because the template is included in the display function we refer to $oTemplate with $this |
104 | */ |
105 | $paginator_str = $this->fetch('paginator.tpl'); |
106 | echo $paginator_str . $thread_link_str ."\n"; ?> |
107 | <!-- end paginator and thread link string --> |
108 | </small> |
109 | </td> |
110 | <!-- message count string --> |
111 | <td align="right"><small><?php echo $msg_cnt_str; ?></small></td> |
112 | <!-- end message count string --> |
113 | </tr> |
114 | </table> |
115 | </td> |
116 | </tr> |
117 | <?php |
118 | if (count($aFormElements)) { |
119 | ?> |
120 | <!-- start message list form control --> |
121 | <tr bgcolor="<?php echo $color[0]; ?>"> |
122 | <td> |
123 | <table border="0" width="100%" cellpadding="1" cellspacing="0"> |
124 | <tr> |
125 | <td align="<?php echo $align['left']; ?>"> |
126 | <small> |
127 | |
128 | <?php |
129 | foreach ($aFormElements as $key => $value) { |
130 | switch ($value[1]) { |
131 | case 'submit': |
132 | if ($key != 'moveButton') { // add move in a different table cell |
133 | ?> |
134 | <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px" /> |
135 | <?php |
136 | } |
137 | break; |
138 | case 'checkbox': |
139 | ?> |
140 | <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?> |
141 | <?php |
142 | break; |
143 | case 'hidden': |
144 | echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n"; |
145 | break; |
146 | default: break; |
147 | } |
148 | } |
149 | ?> |
150 | </small> |
151 | </td> |
152 | <td align="<?php echo $align['right']; ?>"> |
153 | |
154 | |
155 | <?php |
156 | if (isset($aFormElements['moveButton'])) { |
157 | ?> <small> |
158 | <tt> |
159 | <select name="targetMailbox"> |
160 | <?php echo $aFormElements['targetMailbox'][0];?> |
161 | </select> |
162 | </tt> |
163 | <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px" /> |
164 | </small> |
165 | <?php |
166 | } // if (isset($aFormElements['move'])) |
167 | ?> |
168 | </td> |
169 | </tr> |
170 | </table> |
171 | </td> |
172 | </tr> |
173 | <!-- end message list form control --> |
174 | <?php |
175 | } // if (count($aFormElements)) |
176 | ?> |
177 | </table> |
178 | <?php |
179 | do_hook('mailbox_form_before'); |
180 | ?> |
181 | </td> |
182 | </tr> |
183 | <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr> |
184 | <tr> |
185 | <td> |
186 | <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>"> |
187 | <tr> |
188 | <td> |
189 | <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>"> |
190 | <tr> |
191 | <td> |
192 | <!-- table header start --> |
193 | <tr> |
194 | <?php |
195 | $aWidth = calcMessageListColumnWidth($aOrder); |
196 | foreach($aOrder as $iCol) { |
197 | |
198 | ?> |
199 | <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%"> |
200 | <b> |
201 | <?php |
202 | switch ($iCol) { |
203 | case SQM_COL_CHECK: |
204 | if ($javascript_on) { |
205 | echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."','".$fancy_index_highlite."','".$clickedColor.'\');" />'; |
206 | } else { |
207 | $link = $baseurl . "&startMessage=$pageOffset&&checkall="; |
208 | if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) { |
209 | $link .= ($checkall) ? '0' : '1'; |
210 | } else { |
211 | $link .= '1'; |
212 | } |
213 | echo "<a href=\"$link\">"._("All").'</a>'; |
214 | } |
215 | break; |
216 | case SQM_COL_FROM: echo _("From"); break; |
217 | case SQM_COL_DATE: echo _("Date"); break; |
218 | case SQM_COL_SUBJ: echo _("Subject"); break; |
219 | case SQM_COL_FLAGS: echo ' '; break; |
220 | case SQM_COL_SIZE: echo _("Size"); break; |
221 | case SQM_COL_PRIO: echo '!'; break; |
222 | case SQM_COL_ATTACHMENT: echo '+'; break; |
223 | case SQM_COL_INT_DATE: echo _("Received"); break; |
224 | case SQM_COL_TO: echo _("To"); break; |
225 | case SQM_COL_CC: echo _("Cc"); break; |
226 | case SQM_COL_BCC: echo _("Bcc"); break; |
227 | default: break; |
228 | } |
229 | // add the sort buttons |
230 | if (isset($aSortSupported[$iCol])) { |
231 | if ($sort == $aSortSupported[$iCol][0]) { |
232 | $newsort = $aSortSupported[$iCol][1]; |
233 | $img = 'up_pointer.png'; |
234 | } else if ($sort == $aSortSupported[$iCol][1]) { |
235 | $newsort = 0; |
236 | $img = 'down_pointer.png'; |
237 | } else { |
238 | $newsort = $aSortSupported[$iCol][0]; |
239 | $img = 'sort_none.png'; |
240 | } |
241 | /* Now that we have everything figured out, show the actual button. */ |
242 | echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\">"; |
243 | echo '<img src="../images/' . $img |
244 | . '" border="0" width="12" height="10" alt="sort" title="' |
245 | . _("Click here to change the sorting of the message list") .'" /></a>'; |
246 | } |
247 | ?> |
248 | </b> |
249 | </td> |
250 | <?php |
251 | } |
252 | ?> |
253 | </tr> |
254 | |
255 | <!-- Message headers start --> |
256 | <?php |
257 | $i = 0; |
258 | $iColCnt = count($aOrder); |
259 | $sLine = ''; |
260 | |
261 | // this stuff does the auto row highlighting on mouseover |
262 | // |
263 | if ($javascript_on && $fancy_index_highlite) { |
264 | |
265 | $mouseoverColor = $color[5]; |
266 | |
267 | // set this to an empty string to turn off extra |
268 | // highlighting of checked rows |
269 | // |
270 | //$clickedColor = ''; |
271 | $clickedColor = (!empty($color[16])) ? $color[16] : $color[2]; |
272 | } |
273 | if ($javascript_on) { |
274 | $checkbox_javascript = ' onClick="this.checked = !this.checked;"'; |
275 | } |
276 | foreach ($aMessages as $iUid => $aMsg) { |
277 | echo $sLine; |
278 | |
279 | /** |
280 | * Display message header row in messages list |
281 | * |
282 | */ |
283 | |
284 | $aColumns = $aMsg['columns']; |
285 | |
286 | /** |
287 | * Check usage of images for attachments, flags and priority |
288 | * Aaaaaaaaaah fix me. DO NOT USE the string "None" if you mean FALSE, no icon theme |
289 | */ |
290 | $bIcons = ($use_icons && $icon_theme) ? true : false; |
291 | |
292 | /** |
293 | * Location of icon images |
294 | */ |
295 | if ($bIcons) { |
296 | $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/'; |
297 | } |
298 | |
299 | /** |
300 | * Check the flags and set a class var. |
301 | */ |
302 | if (isset($aColumns[SQM_COL_FLAGS])) { |
303 | $aFlags = $aColumns[SQM_COL_FLAGS]['value']; |
304 | if ($bIcons) { |
305 | |
306 | $sFlags = getFlagIcon($aFlags, $sImageLocation); |
307 | } else { |
308 | $sFlags = getFlagText($aFlags); |
309 | } |
310 | /* add the flag string to the value index */ |
311 | $aColumns[SQM_COL_FLAGS]['value'] = $sFlags; |
312 | } |
313 | /** |
314 | * Check the priority column |
315 | */ |
316 | if (isset($aColumns[SQM_COL_PRIO])) { |
317 | /* FIX ME, we should use separate templates for icons */ |
318 | if ($bIcons) { |
319 | $sValue = '<img src="' . $sImageLocation; |
320 | switch ($aColumns[SQM_COL_PRIO]['value']) { |
321 | case 1: |
322 | case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break; |
323 | case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break; |
324 | default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break; |
325 | } |
326 | } else { |
327 | $sValue = ''; |
328 | switch ($aColumns[SQM_COL_PRIO]['value']) { |
329 | case 1: |
330 | case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break; |
331 | case 5: $sValue .= "<font color=\"$color[8]\">?</font>"; break; |
332 | default: break; |
333 | } |
334 | } |
335 | $aColumns[SQM_COL_PRIO]['value'] = $sValue; |
336 | } |
337 | |
338 | /** |
339 | * Check the attachment column |
340 | */ |
341 | if (isset($aColumns[SQM_COL_ATTACHMENT])) { |
342 | /* FIX ME, we should use separate templates for icons */ |
343 | if ($bIcons) { |
344 | $sValue = '<img src="' . $sImageLocation; |
345 | $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value']) |
346 | ? 'attach.png" border="0" height="10" width="6" alt=""/>' |
347 | : 'transparent.png" border="0" width="6" alt="" />'; |
348 | } else { |
349 | $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : ''; |
350 | } |
351 | $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue; |
352 | } |
353 | |
354 | |
355 | $bgcolor = $color[4]; |
356 | |
357 | /** |
358 | * If alternating row colors is set, adapt the bgcolor |
359 | */ |
360 | if (isset($alt_index_colors) && $alt_index_colors) { |
361 | if (!($i % 2)) { |
362 | if (!isset($color[12])) { |
363 | $color[12] = '#EAEAEA'; |
364 | } |
365 | $bgcolor = $color[12]; |
366 | } |
367 | |
368 | } |
369 | $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor; |
370 | $class = 'msg_row'; |
371 | |
372 | $row_extra = ''; |
373 | |
374 | // this stuff does the auto row highlighting on mouseover |
375 | // |
376 | if ($javascript_on && $fancy_index_highlite) { |
377 | $row_extra .= ' onmouseover="rowOver(\''.$form_id . "_msg$i','". $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"'; |
378 | } |
379 | // this does the auto-checking of the checkbox no matter |
380 | // where on the row you click |
381 | // |
382 | $javascript_auto_click = ''; |
383 | if ($javascript_on && $fancy_index_highlite) { |
384 | // include the form_id in order to show multiple messages lists. Otherwise id isn't unique |
385 | $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\""; |
386 | } |
387 | |
388 | ?> |
389 | <tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>> |
390 | <?php |
391 | // flag style mumbo jumbo |
392 | $sPre = $sEnd = ''; |
393 | if (!in_array('seen',$aFlags)) { |
394 | $sPre = '<b>'; $sEnd = '</b>'; |
395 | } |
396 | if (in_array('deleted',$aFlags) && $aFlags['deleted']) { |
397 | $sPre = "<font color=\"$color[9]\">" . $sPre; |
398 | $sEnd .= '</font>'; |
399 | } else { |
400 | if (in_array('flagged',$aFlags) && $aFlags['flagged']) { |
401 | $sPre = "<font color=\"$color[2]\">" . $sPre; |
402 | $sEnd .= '</font>'; |
403 | } |
404 | } |
405 | /** |
406 | * Because the order of the columns and which columns to show is a user preference |
407 | * we have to do some php coding to display the columns in the right order |
408 | */ |
409 | foreach ($aOrder as $iCol) { |
410 | if (in_array($index_order_part, $show_label_columns)) { |
411 | $sLabelStart = '<label for="msg[' . $i . ']">'; |
412 | $sLabelEnd = '</label>'; |
413 | } else { |
414 | $sLabelStart = ''; |
415 | $sLabelEnd = ''; |
416 | } |
417 | $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : ''; |
418 | $title = (isset($aCol['title'])) ? $aCol['title'] : ''; |
419 | $link = (isset($aCol['link'])) ? $aCol['link'] : ''; |
420 | $value = (isset($aCol['value'])) ? $aCol['value'] : ''; |
421 | $target = (isset($aCol['target'])) ? $aCol['target'] : ''; |
422 | if ($iCol !== SQM_COL_CHECK) { |
423 | $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd; |
424 | } |
425 | |
426 | |
427 | switch ($iCol) { |
428 | case SQM_COL_CHECK: |
429 | echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'">' ?> |
430 | <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td> |
431 | <?php |
432 | break; |
433 | case SQM_COL_SUBJ: |
434 | $indent = $aCol['indent']; |
435 | $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">"; |
436 | if ($align['left'] == 'left') { |
437 | $sText .= str_repeat(' ',$indent); |
438 | } |
439 | $sText .= "<a href=\"$link\""; |
440 | if ($target) { $sText .= " target=\"$target\"";} |
441 | if ($title) { $sText .= " title=\"$title\"" ;} |
442 | if ($javascript_on && $fancy_index_highlite) { |
443 | $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') . |
444 | 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . |
445 | $clickedColor .'\');"'; |
446 | } |
447 | $sText .= ">"; |
448 | $sText .= $value . '</a>'; |
449 | if ($align['left'] == 'right') { |
450 | $sText .= str_repeat(' ',$indent); |
451 | } |
452 | echo $sText."</td>\n"; |
453 | break; |
454 | case SQM_COL_SIZE: |
455 | case SQM_COL_FLAGS: |
456 | $sText = " <td class=\"col_\" align=\"$align[right]\" $javascript_auto_click bgcolor=\"$bgcolor\">"; |
457 | $sText .= "<small>$value</small></td>\n"; |
458 | echo $sText; |
459 | break; |
460 | case SQM_COL_INT_DATE: |
461 | case SQM_COL_DATE: |
462 | $sText = " <td class=\"col_\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\">"; |
463 | $sText .= $value. "</td>\n"; |
464 | echo $sText; |
465 | break; |
466 | default: |
467 | $sText = " <td class=\"col_\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\""; |
468 | if ($link) { |
469 | $sText .= "><a href=\"$link\""; |
470 | if ($target) { $sText .= " target=\"$target\"";} |
471 | if ($title) { $sText .= " title=\"$title\"" ;} |
472 | $sText .= ">"; |
473 | } else { |
474 | if ($title) {$sText .= " title=\"$title\"";} |
475 | $sText .= ">"; |
476 | } |
477 | $sText .= $value; |
478 | if ($link) { $sText .= '</a>';} |
479 | echo $sText."</td>\n"; |
480 | break; |
481 | } |
482 | } |
483 | ?> |
484 | </tr> |
485 | <?php |
486 | $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>"; |
487 | ++$i; |
488 | |
489 | /* |
490 | * End displaying row part |
491 | */ |
492 | } |
493 | |
494 | ?> |
495 | <!-- Message headers end --> |
496 | </table> |
497 | </td> |
498 | </tr> |
499 | </table> |
500 | </td> |
501 | </tr> |
502 | <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr> |
503 | <tr> |
504 | <td> |
505 | <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>"> |
506 | <tr> |
507 | <td> |
508 | <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0"> |
509 | <tr> |
510 | <td align="left"><small><?php echo $paginator_str; ?></small></td> |
511 | <td align="right"><small><?php echo $msg_cnt_str; ?></small></td> |
512 | </tr> |
513 | </table> |
514 | </td> |
515 | </tr> |
516 | </table> |
517 | </td> |
518 | </tr> |
519 | <tr> |
520 | <td> |
521 | <?php do_hook('mailbox_index_after');?> |
522 | </td> |
523 | </tr> |
524 | </table> |
525 | </form> |