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 if ($javascript_on) {
274 // $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
276 foreach ($aMessages as $iUid => $aMsg) {
280 * Display message header row in messages list
284 $aColumns = $aMsg['columns'];
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
290 $bIcons = ($use_icons && $icon_theme) ? true : false;
293 * Location of icon images
296 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
300 * Check the flags and set a class var.
302 if (isset($aColumns[SQM_COL_FLAGS])) {
303 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
306 $sFlags = getFlagIcon($aFlags, $sImageLocation);
308 $sFlags = getFlagText($aFlags);
310 /* add the flag string to the value index */
311 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
314 * Check the priority column
316 if (isset($aColumns[SQM_COL_PRIO])) {
317 /* FIX ME, we should use separate templates for icons */
319 $sValue = '<img src="' . $sImageLocation;
320 switch ($aColumns[SQM_COL_PRIO]['value']) {
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;
328 switch ($aColumns[SQM_COL_PRIO]['value']) {
330 case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break;
331 case 5: $sValue .= "<font color=\"$color[8]\">?</font>"; break;
335 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
339 * Check the attachment column
341 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
342 /* FIX ME, we should use separate templates for icons */
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="" />';
349 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
351 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
355 $bgcolor = $color[4];
358 * If alternating row colors is set, adapt the bgcolor
360 if (isset($alt_index_colors) && $alt_index_colors) {
362 if (!isset($color[12])) {
363 $color[12] = '#EAEAEA';
365 $bgcolor = $color[12];
369 $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
374 // this stuff does the auto row highlighting on mouseover
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 . '\');"';
379 // this does the auto-checking of the checkbox no matter
380 // where on the row you click
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')\"";
389 <tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
391 // flag style mumbo jumbo
393 if (!in_array('seen',$aFlags)) {
394 $sPre = '<b>'; $sEnd = '</b>';
396 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
397 $sPre = "<font color=\"$color[9]\">" . $sPre;
400 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
401 $sPre = "<font color=\"$color[2]\">" . $sPre;
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
409 foreach ($aOrder as $iCol) {
410 if (in_array($index_order_part, $show_label_columns)) {
411 $sLabelStart = '<label for="msg[' . $i . ']">';
412 $sLabelEnd = '</label>';
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;
429 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space:nowrap">' ?>
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>
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);
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 .'\');"';
448 $sText .= $value . '</a>';
449 if ($align['left'] == 'right') {
450 $sText .= str_repeat(' ',$indent);
452 echo $sText."</td>\n";
456 $sText = " <td class=\"col_flags\" align=\"$align[right]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
457 $sText .= "<small>$value</small></td>\n";
460 case SQM_COL_INT_DATE:
462 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
463 $sText .= $value. "</td>\n";
467 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space:nowrap\" $javascript_auto_click bgcolor=\"$bgcolor\"";
469 $sText .= "><a href=\"$link\"";
470 if ($target) { $sText .= " target=\"$target\"";}
471 if ($title) { $sText .= " title=\"$title\"" ;}
474 if ($title) {$sText .= " title=\"$title\"";}
478 if ($link) { $sText .= '</a>';}
479 echo $sText."</td>\n";
486 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
490 * End displaying row part
495 <!-- Message headers end -->
502 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
505 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
508 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
510 <td align="left"><small><?php echo $paginator_str; ?></small></td>
511 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
521 <?php do_hook('mailbox_index_after');?>