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 //FIXME: no hooks in templates!
23 do_hook('mailbox_index_before', $null);
26 * Calculate string "Viewing message x to y (z total)"
29 if ($pageOffset < $end_msg) {
30 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
31 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
32 } else if ($pageOffset == $end_msg) {
33 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
38 if (!($sort & SQSORT_THREAD) && $enablesort) {
39 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
40 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
41 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
42 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
43 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
44 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
45 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
47 $aSortSupported = array();
50 // figure out which columns should serve as labels for checkbox:
51 // we try to grab the two columns before and after the checkbox,
52 // except the subject column, since it is the link that opens
55 // if $javascript_on is set, then the highlighting code takes
56 // care of this; just skip it
58 $show_label_columns = array();
59 $index_order_part = array();
60 if (!($javascript_on && $fancy_index_highlite)) {
63 $last_last_order_part = 0;
64 foreach ($aOrder as $index_order_part) {
65 if ($index_order_part == SQM_COL_CHECK) {
67 if ($last_last_order_part != SQM_COL_SUBJ)
68 $show_label_columns[] = $last_last_order_part;
69 if ($last_order_part != SQM_COL_SUBJ)
70 $show_label_columns[] = $last_order_part;
72 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
73 $show_label_columns[] = $index_order_part;
76 $last_last_order_part = $last_order_part;
77 $last_order_part = $index_order_part;
82 * All icon functionality is now handled through $icon_theme_path.
83 * $icon_theme_path will contain the path to the user-selected theme. If it is
84 * NULL, the user and/or admin have turned off icons.
87 // set this to an empty string to turn off extra
88 // highlighting of checked rows
91 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
94 <div id="message_list">
95 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
96 <table class="table_empty" cellspacing="0">
99 <table class="table_standard" cellspacing="0">
102 <table class="table_empty" cellspacing="0">
104 <td class="links_paginator">
105 <!-- paginator and thread link string -->
108 * because the template is included in the display function we refer to $oTemplate with $this
110 $paginator_str = $this->fetch('paginator.tpl');
111 echo $paginator_str . $thread_link_str ."\n"; ?>
112 <!-- end paginator and thread link string -->
114 <!-- message count string -->
115 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
116 <!-- end message count string -->
122 if (count($aFormElements)) {
124 <!-- start message list form control -->
125 <tr class="message_list_controls">
127 <table class="table_empty" cellspacing="0">
129 <td class="message_control_buttons">
132 foreach ($aFormElements as $key => $value) {
135 if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
137 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />
142 if ($key != 'bypass_trash') {
144 <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>
149 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
156 <td class="message_control_delete">
160 if (isset($aFormElements['delete'])) {
162 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />
164 if (isset($aFormElements['bypass_trash'])) {
166 <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>
169 if (isset($aFormElements['undeleteButton'])) {
171 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />
177 } // if (isset($aFormElements['delete']))
178 if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
180 <td class="message_control_move">
181 <select name="targetMailbox">
182 <?php echo $aFormElements['targetMailbox'][0];?>
184 <?php if (isset($aFormElements['moveButton'])) { ?>
185 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
187 if (isset($aFormElements['copyButton'])) { ?>
188 <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
193 } // if (isset($aFormElements['move']))
199 <!-- end message list form control -->
201 } // if (count($aFormElements))
205 //FIXME: no hooks in templates!
206 do_hook('mailbox_form_before', $null);
210 <tr><td class="spacer"></td></tr>
213 <table class="table_messageListWrapper" cellspacing="0">
216 <table class="table_messageList" cellspacing="0">
217 <!-- table header start -->
220 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
221 * rendering this table if we use THEAD and TH tags. No other browser or platform has
222 * this issue. We will use TR/TD w/ another CSS class to work around this.
225 <tr class="headerRow">
227 $aWidth = calcMessageListColumnWidth($aOrder);
228 foreach($aOrder as $iCol) {
230 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
234 if ($javascript_on) {
235 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
237 $link = $baseurl . "&startMessage=$pageOffset&checkall=";
238 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
239 $link .= ($checkall) ? '0' : '1';
243 echo "<a href=\"$link\">"._("All").'</a>';
246 case SQM_COL_FROM: echo _("From")."\n"; break;
247 case SQM_COL_DATE: echo _("Date")."\n"; break;
248 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
250 echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n";
252 case SQM_COL_SIZE: echo _("Size")."\n"; break;
254 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
256 case SQM_COL_ATTACHMENT:
257 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
259 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
260 case SQM_COL_TO: echo _("To")."\n"; break;
261 case SQM_COL_CC: echo _("Cc")."\n"; break;
262 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
265 // add the sort buttons
266 if (isset($aSortSupported[$iCol])) {
267 if ($sort == $aSortSupported[$iCol][0]) {
268 $newsort = $aSortSupported[$iCol][1];
269 $img = 'up_pointer.png';
270 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
271 } else if ($sort == $aSortSupported[$iCol][1]) {
273 $img = 'down_pointer.png';
274 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
276 $newsort = $aSortSupported[$iCol][0];
277 $img = 'sort_none.png';
278 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
280 /* Now that we have everything figured out, show the actual button. */
281 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\" style=\"text-decoration:none\">" .
282 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
291 <!-- end table header -->
293 <!-- Message headers start -->
296 $iColCnt = count($aOrder);
299 // this stuff does the auto row highlighting on mouseover
301 if ($javascript_on && $fancy_index_highlite) {
303 $mouseoverColor = $color[5];
305 // set this to an empty string to turn off extra
306 // highlighting of checked rows
308 //$clickedColor = '';
309 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
311 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
313 $checkbox_javascript = '';
315 foreach ($aMessages as $iUid => $aMsg) {
319 * Display message header row in messages list
323 $aColumns = $aMsg['columns'];
327 * Check the flags and set a class var.
329 if (isset($aColumns[SQM_COL_FLAGS])) {
330 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
331 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
333 /* add the flag string to the value index */
334 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
337 * Check the priority column
339 if (isset($aColumns[SQM_COL_PRIO])) {
340 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
341 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
345 * Check the attachment column
347 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
348 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
349 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
354 * If alternating row colors is set, adapt the CSS class
356 if (isset($alt_index_colors) && $alt_index_colors) {
362 if (isset($aMsg['row']['color']))
364 $bgcolor = $aMsg['row']['color'];
371 // this stuff does the auto row highlighting on mouseover
373 if ($javascript_on && $fancy_index_highlite) {
374 $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\');"';
376 // this does the auto-checking of the checkbox no matter
377 // where on the row you click
379 $javascript_auto_click = '';
380 if ($javascript_on && $fancy_index_highlite) {
381 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
382 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
386 * Message Highlighting requires a unique CSS class declaration for proper
387 * mouseover functionality. There is no harm in doing this when the mouseover
388 * functionality is disabled
390 if ($class != 'even' && $class != 'odd')
393 <style type="text/css">
395 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
401 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
403 // flag style mumbo jumbo
405 if (isset($aColumns[SQM_COL_FLAGS])) {
406 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
407 $sPre = '<span class="unread">'; $sEnd = '</span>';
409 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
410 $sPre = '<span class="deleted">' . $sPre;
413 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
414 $sPre = '<span class="flagged">' . $sPre;
420 * Because the order of the columns and which columns to show is a user preference
421 * we have to do some php coding to display the columns in the right order
423 foreach ($aOrder as $iCol) {
424 if (in_array($iCol, $show_label_columns)) {
425 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
426 $sLabelEnd = '</label>';
431 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
432 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
433 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
434 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
435 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
436 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
437 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
438 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
439 if ($iCol !== SQM_COL_CHECK) {
440 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
446 if ($javascript_on) {
447 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
448 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
451 echo '<td class="col_check">';
452 $checked = ($checkall) ? " checked=checked " : " ";
453 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
457 $indent = $aCol['indent'];
458 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
459 if ($align['left'] == 'left') {
460 $sText .= str_repeat(' ',$indent);
462 $sText .= "<a href=\"$link\"";
463 if ($target) { $sText .= " target=\"$target\""; }
464 if ($title) { $sText .= " title=\"$title\""; }
465 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
466 if ($link_extra) { $sText .= " $link_extra"; }
467 if ($javascript_on && $fancy_index_highlite) {
468 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
469 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
470 $clickedColor .'\');"';
473 $sText .= $value . '</a>';
474 if ($align['left'] == 'right') {
475 $sText .= str_repeat(' ',$indent);
477 echo $sText."</td>\n";
481 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
482 $sText .= "$value</td>\n";
485 case SQM_COL_INT_DATE:
487 $sText = " <td class=\"col_date\" $javascript_auto_click>";
488 $sText .= $value. "</td>\n";
492 $sText = " <td class=\"col_text\" $javascript_auto_click";
494 $sText .= "><a href=\"$link\"";
495 if ($target) { $sText .= " target=\"$target\"";}
496 if ($title) { $sText .= " title=\"$title\"" ;}
499 if ($title) {$sText .= " title=\"$title\"";}
503 if ($link) { $sText .= '</a>';}
504 echo $sText."</td>\n";
511 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
515 * End displaying row part
520 <!-- Message headers end -->
527 <tr><td class="spacer"></td></tr>
530 <table class="table_standard" cellspacing="0">
533 <table class="table_empty" cellspacing="0">
535 <td class="links_paginator"><?php echo $paginator_str; ?></td>
536 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
546 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>