6 * Template for viewing a messages list
8 * @copyright © 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
12 * @subpackage templates
15 /** add required includes */
16 include_once(SM_PATH . 'templates/util_message_list.php');
18 /* retrieve the template vars */
21 do_hook('mailbox_index_before');
24 * Calculate string "Viewing message x to y (z total)"
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);
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));
45 $aSortSupported = array();
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
53 // if $javascript_on is set, then the highlighting code takes
54 // care of this; just skip it
56 $show_label_columns = array();
57 $index_order_part = array();
58 if (!($javascript_on && $fancy_index_highlite)) {
61 $last_last_order_part = 0;
62 foreach ($aOrder as $index_order_part) {
63 if ($index_order_part == SQM_COL_CHECK) {
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;
70 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
71 $show_label_columns[] = $index_order_part;
74 $last_last_order_part = $last_order_part;
75 $last_order_part = $index_order_part;
80 * Check usage of images for attachments, flags and priority
82 $bIcons = ($use_icons && $icon_theme) ? true : false;
85 * Location of icon images
88 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
91 // set this to an empty string to turn off extra
92 // highlighting of checked rows
95 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
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">
102 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
105 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
107 <td align="<?php echo $align['left']; ?>">
109 <!-- paginator and thread link string -->
112 * because the template is included in the display function we refer to $oTemplate with $this
114 $paginator_str = $this->fetch('paginator.tpl');
115 echo $paginator_str . $thread_link_str ."\n"; ?>
116 <!-- end paginator and thread link string -->
119 <!-- message count string -->
120 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
121 <!-- end message count string -->
127 if (count($aFormElements)) {
129 <!-- start message list form control -->
130 <tr bgcolor="<?php echo $color[0]; ?>">
132 <table border="0" width="100%" cellpadding="1" cellspacing="0">
134 <td align="<?php echo $align['left']; ?>">
138 foreach ($aFormElements as $key => $value) {
141 if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
143 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px;" />
148 if ($key != 'bypass_trash') {
150 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>
155 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
163 <td align="<?php echo $align['right']; ?>">
167 if (isset($aFormElements['delete'])) {
169 <td align="<?php echo $align['right']; ?>">
171 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" style="padding: 0px; margin: 0px;" />
173 if (isset($aFormElements['bypass_trash'])) {
175 <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>
178 if (isset($aFormElements['undeleteButton'])) {
180 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" style="padding: 0px; margin: 0px;" />
187 } // if (isset($aFormElements['delete']))
188 if (isset($aFormElements['moveButton'])) {
190 <td align="<?php echo $align['right']; ?>">
193 <select name="targetMailbox">
194 <?php echo $aFormElements['targetMailbox'][0];?>
197 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px;" />
202 } // if (isset($aFormElements['move']))
208 <!-- end message list form control -->
210 } // if (count($aFormElements))
214 do_hook('mailbox_form_before');
218 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
221 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
224 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
227 <!-- table header start -->
230 $aWidth = calcMessageListColumnWidth($aOrder);
231 foreach($aOrder as $iCol) {
234 <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%" style="white-space: nowrap;">
239 if ($javascript_on) {
240 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.",'".$clickedColor.'\');" />';
242 $link = $baseurl . "&startMessage=$pageOffset&&checkall=";
243 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
244 $link .= ($checkall) ? '0' : '1';
248 echo "<a href=\"$link\">"._("All").'</a>';
251 case SQM_COL_FROM: echo _("From"); break;
252 case SQM_COL_DATE: echo _("Date"); break;
253 case SQM_COL_SUBJ: echo _("Subject"); break;
256 echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />';
261 case SQM_COL_SIZE: echo _("Size"); break;
264 echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />';
269 case SQM_COL_ATTACHMENT:
271 echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>';
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;
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]) {
289 $img = 'down_pointer.png';
291 $newsort = $aSortSupported[$iCol][0];
292 $img = 'sort_none.png';
294 /* Now that we have everything figured out, show the actual button. */
295 echo " <a href=\"$baseurl&startMessage=1&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>';
308 <!-- Message headers start -->
311 $iColCnt = count($aOrder);
314 // this stuff does the auto row highlighting on mouseover
316 if ($javascript_on && $fancy_index_highlite) {
318 $mouseoverColor = $color[5];
320 // set this to an empty string to turn off extra
321 // highlighting of checked rows
323 //$clickedColor = '';
324 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
326 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
328 $checkbox_javascript = '';
330 foreach ($aMessages as $iUid => $aMsg) {
334 * Display message header row in messages list
338 $aColumns = $aMsg['columns'];
342 * Check the flags and set a class var.
344 if (isset($aColumns[SQM_COL_FLAGS])) {
345 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
348 $sFlags = getFlagIcon($aFlags, $sImageLocation);
350 $sFlags = getFlagText($aFlags);
352 /* add the flag string to the value index */
353 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
356 * Check the priority column
358 if (isset($aColumns[SQM_COL_PRIO])) {
359 /* FIX ME, we should use separate templates for icons */
361 $sValue = '<img src="' . $sImageLocation;
362 switch ($aColumns[SQM_COL_PRIO]['value']) {
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;
370 switch ($aColumns[SQM_COL_PRIO]['value']) {
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]\">↓</font>"; break;
378 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
382 * Check the attachment column
384 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
385 /* FIX ME, we should use separate templates for icons */
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="" />';
392 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
394 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
398 $bgcolor = $color[4];
401 * If alternating row colors is set, adapt the bgcolor
403 if (isset($alt_index_colors) && $alt_index_colors) {
405 if (!isset($color[12])) {
406 $color[12] = '#EAEAEA';
408 $bgcolor = $color[12];
412 $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
417 // this stuff does the auto row highlighting on mouseover
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 . '\');"';
422 // this does the auto-checking of the checkbox no matter
423 // where on the row you click
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')\"";
432 <tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
434 // flag style mumbo jumbo
436 if (isset($aColumns[SQM_COL_FLAGS])) {
437 if (!in_array('seen',$aFlags)) {
438 $sPre = '<b>'; $sEnd = '</b>';
440 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
441 $sPre = "<font color=\"$color[9]\">" . $sPre;
444 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
445 $sPre = "<font color=\"$color[2]\">" . $sPre;
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
454 foreach ($aOrder as $iCol) {
455 if (in_array($iCol, $show_label_columns)) {
456 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
457 $sLabelEnd = '</label>';
462 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
463 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
464 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
465 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
466 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
467 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
468 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
469 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
470 if ($iCol !== SQM_COL_CHECK) {
471 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
477 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space: nowrap;">' ?>
478 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
482 $indent = $aCol['indent'];
483 $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
484 if ($align['left'] == 'left') {
485 $sText .= str_repeat(' ',$indent);
487 $sText .= "<a href=\"$link\"";
488 if ($target) { $sText .= " target=\"$target\""; }
489 if ($title) { $sText .= " title=\"$title\""; }
490 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
491 if ($link_extra) { $sText .= " $link_extra"; }
492 if ($javascript_on && $fancy_index_highlite) {
493 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
494 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
495 $clickedColor .'\');"';
498 $sText .= $value . '</a>';
499 if ($align['left'] == 'right') {
500 $sText .= str_repeat(' ',$indent);
502 echo $sText."</td>\n";
506 $sText = " <td class=\"col_flags\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
507 $sText .= "<small>$value</small></td>\n";
510 case SQM_COL_INT_DATE:
512 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
513 $sText .= $value. "</td>\n";
517 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space: nowrap;\" $javascript_auto_click bgcolor=\"$bgcolor\"";
519 $sText .= "><a href=\"$link\"";
520 if ($target) { $sText .= " target=\"$target\"";}
521 if ($title) { $sText .= " title=\"$title\"" ;}
524 if ($title) {$sText .= " title=\"$title\"";}
528 if ($link) { $sText .= '</a>';}
529 echo $sText."</td>\n";
536 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
540 * End displaying row part
545 <!-- Message headers end -->
552 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
555 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
558 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
560 <td align="left"><small><?php echo $paginator_str; ?></small></td>
561 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
571 <?php do_hook('mailbox_index_after');?>