6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Template for viewing a messages list
12 * @package squirrelmail
15 include_once(SM_PATH . 'templates/util_message_list.php');
17 /* retrieve the template vars */
20 do_hook('mailbox_index_before');
23 * Calculate string "Viewing message x to y (z total)"
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);
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));
44 $aSortSupported = array();
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
52 // if $javascript_on is set, then the highlighting code takes
53 // care of this; just skip it
55 $show_label_columns = array();
56 $index_order_part = array();
57 if (!($javascript_on && $fancy_index_highlite)) {
60 $last_last_order_part = 0;
61 foreach ($aOrder as $index_order_part) {
62 if ($index_order_part == SQM_COL_CHECK) {
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;
69 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
70 $show_label_columns[] = $index_order_part;
73 $last_last_order_part = $last_order_part;
74 $last_order_part = $index_order_part;
78 // set this to an empty string to turn off extra
79 // highlighting of checked rows
82 if (!empty($color[16]))
83 $clickedColor = $color[16];
85 $clickedColor = $color[2];
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">
93 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
96 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
98 <td align="<?php echo $align['left']; ?>">
100 <!-- paginator and thread link string -->
103 * because the template is included in the display function we refer to $oTemplate with $this
105 $paginator_str = $this->fetch('paginator.tpl');
106 echo $paginator_str . $thread_link_str ."\n"; ?>
107 <!-- end paginator and thread link string -->
110 <!-- message count string -->
111 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
112 <!-- end message count string -->
118 if (count($aFormElements)) {
120 <!-- start message list form control -->
121 <tr bgcolor="<?php echo $color[0]; ?>">
123 <table border="0" width="100%" cellpadding="1" cellspacing="0">
125 <td align="<?php echo $align['left']; ?>">
129 foreach ($aFormElements as $key => $value) {
132 if ($key != 'moveButton') { // add move in a different table cell
134 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px" />
140 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>
144 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
152 <td align="<?php echo $align['right']; ?>">
156 if (isset($aFormElements['moveButton'])) {
159 <select name="targetMailbox">
160 <?php echo $aFormElements['targetMailbox'][0];?>
163 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px" />
166 } // if (isset($aFormElements['move']))
173 <!-- end message list form control -->
175 } // if (count($aFormElements))
179 do_hook('mailbox_form_before');
183 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
186 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
189 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
192 <!-- table header start -->
195 $aWidth = calcMessageListColumnWidth($aOrder);
196 foreach($aOrder as $iCol) {
199 <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%" style="white-space:nowrap">
204 if ($javascript_on) {
205 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.",'".$clickedColor.'\');" />';
207 $link = $baseurl . "&startMessage=$pageOffset&&checkall=";
208 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
209 $link .= ($checkall) ? '0' : '1';
213 echo "<a href=\"$link\">"._("All").'</a>';
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;
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]) {
236 $img = 'down_pointer.png';
238 $newsort = $aSortSupported[$iCol][0];
239 $img = 'sort_none.png';
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>';
255 <!-- Message headers start -->
258 $iColCnt = count($aOrder);
261 // this stuff does the auto row highlighting on mouseover
263 if ($javascript_on && $fancy_index_highlite) {
265 $mouseoverColor = $color[5];
267 // set this to an empty string to turn off extra
268 // highlighting of checked rows
270 //$clickedColor = '';
271 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
273 $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
275 $checkbox_javascript = '';
277 foreach ($aMessages as $iUid => $aMsg) {
281 * Display message header row in messages list
285 $aColumns = $aMsg['columns'];
288 * Check usage of images for attachments, flags and priority
289 * Aaaaaaaaaah fix me. DO NOT USE the string "None" if you mean FALSE, no icon theme
291 $bIcons = ($use_icons && $icon_theme) ? true : false;
294 * Location of icon images
297 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
301 * Check the flags and set a class var.
303 if (isset($aColumns[SQM_COL_FLAGS])) {
304 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
307 $sFlags = getFlagIcon($aFlags, $sImageLocation);
309 $sFlags = getFlagText($aFlags);
311 /* add the flag string to the value index */
312 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
315 * Check the priority column
317 if (isset($aColumns[SQM_COL_PRIO])) {
318 /* FIX ME, we should use separate templates for icons */
320 $sValue = '<img src="' . $sImageLocation;
321 switch ($aColumns[SQM_COL_PRIO]['value']) {
323 case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
324 case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
325 default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
329 switch ($aColumns[SQM_COL_PRIO]['value']) {
331 case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break;
332 case 5: $sValue .= "<font color=\"$color[8]\">?</font>"; break;
336 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
340 * Check the attachment column
342 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
343 /* FIX ME, we should use separate templates for icons */
345 $sValue = '<img src="' . $sImageLocation;
346 $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
347 ? 'attach.png" border="0" height="10" width="6" alt=""/>'
348 : 'transparent.png" border="0" width="6" alt="" />';
350 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
352 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
356 $bgcolor = $color[4];
359 * If alternating row colors is set, adapt the bgcolor
361 if (isset($alt_index_colors) && $alt_index_colors) {
363 if (!isset($color[12])) {
364 $color[12] = '#EAEAEA';
366 $bgcolor = $color[12];
370 $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
375 // this stuff does the auto row highlighting on mouseover
377 if ($javascript_on && $fancy_index_highlite) {
378 $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 . '\');"';
380 // this does the auto-checking of the checkbox no matter
381 // where on the row you click
383 $javascript_auto_click = '';
384 if ($javascript_on && $fancy_index_highlite) {
385 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
386 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
390 <tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
392 // flag style mumbo jumbo
394 if (!in_array('seen',$aFlags)) {
395 $sPre = '<b>'; $sEnd = '</b>';
397 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
398 $sPre = "<font color=\"$color[9]\">" . $sPre;
401 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
402 $sPre = "<font color=\"$color[2]\">" . $sPre;
407 * Because the order of the columns and which columns to show is a user preference
408 * we have to do some php coding to display the columns in the right order
410 foreach ($aOrder as $iCol) {
411 // FIXME: first parameter cannot be an array in PHP < 4.2
412 if (in_array($index_order_part, $show_label_columns)) {
413 $sLabelStart = '<label for="msg[' . $i . ']">';
414 $sLabelEnd = '</label>';
419 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
420 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
421 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
422 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
423 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
424 if ($iCol !== SQM_COL_CHECK) {
425 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
431 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space:nowrap">' ?>
432 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
436 $indent = $aCol['indent'];
437 $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
438 if ($align['left'] == 'left') {
439 $sText .= str_repeat(' ',$indent);
441 $sText .= "<a href=\"$link\"";
442 if ($target) { $sText .= " target=\"$target\"";}
443 if ($title) { $sText .= " title=\"$title\"" ;}
444 if ($javascript_on && $fancy_index_highlite) {
445 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
446 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
447 $clickedColor .'\');"';
450 $sText .= $value . '</a>';
451 if ($align['left'] == 'right') {
452 $sText .= str_repeat(' ',$indent);
454 echo $sText."</td>\n";
458 $sText = " <td class=\"col_flags\" align=\"$align[right]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
459 $sText .= "<small>$value</small></td>\n";
462 case SQM_COL_INT_DATE:
464 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
465 $sText .= $value. "</td>\n";
469 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space:nowrap\" $javascript_auto_click bgcolor=\"$bgcolor\"";
471 $sText .= "><a href=\"$link\"";
472 if ($target) { $sText .= " target=\"$target\"";}
473 if ($title) { $sText .= " title=\"$title\"" ;}
476 if ($title) {$sText .= " title=\"$title\"";}
480 if ($link) { $sText .= '</a>';}
481 echo $sText."</td>\n";
488 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
492 * End displaying row part
497 <!-- Message headers end -->
504 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
507 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
510 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
512 <td align="left"><small><?php echo $paginator_str; ?></small></td>
513 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
523 <?php do_hook('mailbox_index_after');?>