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 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
30 } else if ($pageOffset == $end_msg) {
31 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $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 <div id="message_list">
99 <form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
100 <table class="table_empty" cellspacing="0">
103 <table class="table_standard" cellspacing="0">
106 <table class="table_empty" cellspacing="0">
108 <td class="links_paginator">
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 -->
118 <!-- message count string -->
119 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
120 <!-- end message count string -->
126 if (count($aFormElements)) {
128 <!-- start message list form control -->
129 <tr class="message_list_controls" cellspacing="0">
131 <table class="table_empty" cellspacing="0">
133 <td class="message_control_buttons" cellspacing="0">
136 foreach ($aFormElements as $key => $value) {
139 if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
141 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />
146 if ($key != 'bypass_trash') {
148 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>
153 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
160 <td class="message_control_delete">
164 if (isset($aFormElements['delete'])) {
166 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />
168 if (isset($aFormElements['bypass_trash'])) {
170 <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>
173 if (isset($aFormElements['undeleteButton'])) {
175 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />
181 } // if (isset($aFormElements['delete']))
182 if (isset($aFormElements['moveButton'])) {
184 <td class="message_control_move">
185 <select name="targetMailbox">
186 <?php echo $aFormElements['targetMailbox'][0];?>
188 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
192 } // if (isset($aFormElements['move']))
198 <!-- end message list form control -->
200 } // if (count($aFormElements))
204 do_hook('mailbox_form_before');
208 <tr><td class="spacer"></td></tr>
211 <table class="table_messageListWrapper" cellspacing="0">
214 <table class="table_messageList" cellspacing="0">
215 <!-- table header start -->
218 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
219 * rendering this table if we use THEAD and TH tags. No other browser or platform has
220 * this issue. We will use TR/TD w/ another CSS class to work around this.
223 <tr class="headerRow">
225 $aWidth = calcMessageListColumnWidth($aOrder);
226 foreach($aOrder as $iCol) {
228 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
232 if ($javascript_on) {
233 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.')" />'."\n";
235 $link = $baseurl . "&startMessage=$pageOffset&&checkall=";
236 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
237 $link .= ($checkall) ? '0' : '1';
241 echo "<a href=\"$link\">"._("All").'</a>';
244 case SQM_COL_FROM: echo _("From")."\n"; break;
245 case SQM_COL_DATE: echo _("Date")."\n"; break;
246 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
249 echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />'."\n";
254 case SQM_COL_SIZE: echo _("Size")."\n"; break;
257 echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />'."\n";
262 case SQM_COL_ATTACHMENT:
264 echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>'."\n";
269 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
270 case SQM_COL_TO: echo _("To")."\n"; break;
271 case SQM_COL_CC: echo _("Cc")."\n"; break;
272 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
275 // add the sort buttons
276 if (isset($aSortSupported[$iCol])) {
277 if ($sort == $aSortSupported[$iCol][0]) {
278 $newsort = $aSortSupported[$iCol][1];
279 $img = 'up_pointer.png';
280 } else if ($sort == $aSortSupported[$iCol][1]) {
282 $img = 'down_pointer.png';
284 $newsort = $aSortSupported[$iCol][0];
285 $img = 'sort_none.png';
287 /* Now that we have everything figured out, show the actual button. */
288 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\">";
289 echo '<img src="../images/' . $img
290 . '" border="0" width="12" height="10" alt="sort" title="'
291 . _("Click here to change the sorting of the message list") .'" /></a>'."\n";
299 <!-- end table header -->
301 <!-- Message headers start -->
304 $iColCnt = count($aOrder);
307 // this stuff does the auto row highlighting on mouseover
309 if ($javascript_on && $fancy_index_highlite) {
311 $mouseoverColor = $color[5];
313 // set this to an empty string to turn off extra
314 // highlighting of checked rows
316 //$clickedColor = '';
317 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
319 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
321 $checkbox_javascript = '';
323 foreach ($aMessages as $iUid => $aMsg) {
327 * Display message header row in messages list
331 $aColumns = $aMsg['columns'];
335 * Check the flags and set a class var.
337 if (isset($aColumns[SQM_COL_FLAGS])) {
338 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
341 $sFlags = getFlagIcon($aFlags, $sImageLocation);
343 $sFlags = getFlagText($aFlags);
345 /* add the flag string to the value index */
346 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
349 * Check the priority column
351 if (isset($aColumns[SQM_COL_PRIO])) {
352 /* FIX ME, we should use separate templates for icons */
354 $sValue = '<img src="' . $sImageLocation;
355 switch ($aColumns[SQM_COL_PRIO]['value']) {
357 case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
358 case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
359 default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
363 switch ($aColumns[SQM_COL_PRIO]['value']) {
365 case 2: $sValue .= '<span class="high_priority">!</span>'; break;
366 // use downwards arrow for low priority emails
367 case 5: $sValue .= '<span class="low_priority">↓</span>'; break;
371 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
375 * Check the attachment column
377 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
378 /* FIX ME, we should use separate templates for icons */
380 $sValue = '<img src="' . $sImageLocation;
381 $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
382 ? 'attach.png" border="0" height="10" width="6" alt=""/>'
383 : 'transparent.png" border="0" width="6" alt="" />';
385 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
387 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
392 * If alternating row colors is set, adapt the CSS class
394 if (isset($alt_index_colors) && $alt_index_colors) {
400 if (isset($aMsg['row']['color']))
402 $bgcolor = $aMsg['row']['color'];
409 // this stuff does the auto row highlighting on mouseover
411 if ($javascript_on && $fancy_index_highlite) {
412 $row_extra .= ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $class . '\', \'mouse_over\', \'clicked\');"';
414 // this does the auto-checking of the checkbox no matter
415 // where on the row you click
417 $javascript_auto_click = '';
418 if ($javascript_on && $fancy_index_highlite) {
419 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
420 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
424 * Message Highlighting requires a unique CSS class declaration for proper
425 * mouseover functionality. There is no harm in doing this when the mouseover
426 * functionality is disabled
428 if ($class != 'even' && $class != 'odd')
431 <style type="text/css">
433 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
439 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
441 // flag style mumbo jumbo
443 if (isset($aColumns[SQM_COL_FLAGS])) {
444 if (!in_array('seen',$aFlags)) {
445 $sPre = '<span class="unread">'; $sEnd = '</span>';
447 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
448 $sPre = '<span class="deleted">' . $sPre;
451 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
452 $sPre = '<span class="flagged">' . $sPre;
458 * Because the order of the columns and which columns to show is a user preference
459 * we have to do some php coding to display the columns in the right order
461 foreach ($aOrder as $iCol) {
462 if (in_array($iCol, $show_label_columns)) {
463 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
464 $sLabelEnd = '</label>';
469 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
470 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
471 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
472 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
473 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
474 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
475 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
476 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
477 if ($iCol !== SQM_COL_CHECK) {
478 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
484 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
485 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
489 $indent = $aCol['indent'];
490 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
491 if ($align['left'] == 'left') {
492 $sText .= str_repeat(' ',$indent);
494 $sText .= "<a href=\"$link\"";
495 if ($target) { $sText .= " target=\"$target\""; }
496 if ($title) { $sText .= " title=\"$title\""; }
497 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
498 if ($link_extra) { $sText .= " $link_extra"; }
499 if ($javascript_on && $fancy_index_highlite) {
500 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
501 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
502 $clickedColor .'\');"';
505 $sText .= $value . '</a>';
506 if ($align['left'] == 'right') {
507 $sText .= str_repeat(' ',$indent);
509 echo $sText."</td>\n";
513 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
514 $sText .= "$value</td>\n";
517 case SQM_COL_INT_DATE:
519 $sText = " <td class=\"col_date\" $javascript_auto_click>";
520 $sText .= $value. "</td>\n";
524 $sText = " <td class=\"col_text\" $javascript_auto_click";
526 $sText .= "><a href=\"$link\"";
527 if ($target) { $sText .= " target=\"$target\"";}
528 if ($title) { $sText .= " title=\"$title\"" ;}
531 if ($title) {$sText .= " title=\"$title\"";}
535 if ($link) { $sText .= '</a>';}
536 echo $sText."</td>\n";
543 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
547 * End displaying row part
552 <!-- Message headers end -->
559 <tr><td class="spacer"></td></tr>
562 <table class="table_standard" cellspacing="0">
565 <table class="table_empty" cellspacing="0">
567 <td class="links_paginator"><?php echo $paginator_str; ?></td>
568 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
578 <?php do_hook('mailbox_index_after');?>