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