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_global.php');
17 include_once(SM_PATH . 'templates/util_message_list.php');
19 /* retrieve the template vars */
22 //FIXME: no hooks in templates!
24 do_hook('mailbox_index_before', $null);
27 * Calculate string "Viewing message x to y (z total)"
30 if ($pageOffset < $end_msg) {
31 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
32 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
33 } else if ($pageOffset == $end_msg) {
34 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
39 if (!($sort & SQSORT_THREAD) && $enablesort) {
40 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
41 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
42 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
43 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
44 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
45 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
46 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
48 $aSortSupported = array();
51 // figure out which columns should serve as labels for checkbox:
52 // we try to grab the two columns before and after the checkbox,
53 // except the subject column, since it is the link that opens
56 // if $javascript_on is set, then the highlighting code takes
57 // care of this; just skip it
59 $show_label_columns = array();
60 $index_order_part = array();
61 if (!($javascript_on && $fancy_index_highlite)) {
64 $last_last_order_part = 0;
65 foreach ($aOrder as $index_order_part) {
66 if ($index_order_part == SQM_COL_CHECK) {
68 if ($last_last_order_part != SQM_COL_SUBJ)
69 $show_label_columns[] = $last_last_order_part;
70 if ($last_order_part != SQM_COL_SUBJ)
71 $show_label_columns[] = $last_order_part;
73 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
74 $show_label_columns[] = $index_order_part;
77 $last_last_order_part = $last_order_part;
78 $last_order_part = $index_order_part;
83 * All icon functionality is now handled through $icon_theme_path.
84 * $icon_theme_path will contain the path to the user-selected theme. If it is
85 * NULL, the user and/or admin have turned off icons.
88 // set this to an empty string to turn off extra
89 // highlighting of checked rows
92 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
95 <div id="message_list">
96 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
97 <table class="table_empty" cellspacing="0">
100 <table class="table_standard" cellspacing="0">
103 <table class="table_empty" cellspacing="0">
105 <td class="links_paginator">
106 <!-- paginator and thread link string -->
109 * because the template is included in the display function we refer to $oTemplate with $this
111 $paginator_str = $this->fetch('paginator.tpl');
112 echo $paginator_str . $thread_link_str ."\n"; ?>
113 <!-- end paginator and thread link string -->
115 <!-- message count string -->
116 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
117 <!-- end message count string -->
123 if (count($aFormElements)) {
125 <!-- start message list form control -->
126 <tr class="message_list_controls">
128 <table class="table_empty" cellspacing="0">
130 <td class="message_control_buttons">
133 foreach ($aFormElements as $key => $value) {
136 if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
138 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />
143 if ($key != 'bypass_trash') {
145 <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>
150 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
157 <td class="message_control_delete">
161 if (isset($aFormElements['delete'])) {
163 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />
165 if (isset($aFormElements['bypass_trash'])) {
167 <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>
170 if (isset($aFormElements['undeleteButton'])) {
172 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />
178 } // if (isset($aFormElements['delete']))
179 if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
181 <td class="message_control_move">
182 <select name="targetMailbox">
183 <?php echo $aFormElements['targetMailbox'][0];?>
185 <?php if (isset($aFormElements['moveButton'])) { ?>
186 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
188 if (isset($aFormElements['copyButton'])) { ?>
189 <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
194 } // if (isset($aFormElements['move']))
200 <!-- end message list form control -->
202 } // if (count($aFormElements))
206 //FIXME: no hooks in templates!
207 do_hook('mailbox_form_before', $null);
211 <tr><td class="spacer"></td></tr>
214 <table class="table_messageListWrapper" cellspacing="0">
217 <table class="table_messageList" cellspacing="0">
218 <!-- table header start -->
221 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
222 * rendering this table if we use THEAD and TH tags. No other browser or platform has
223 * this issue. We will use TR/TD w/ another CSS class to work around this.
226 <tr class="headerRow">
228 $aWidth = calcMessageListColumnWidth($aOrder);
229 foreach($aOrder as $iCol) {
231 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
235 if ($javascript_on) {
236 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
238 $link = $baseurl . "&startMessage=$pageOffset&checkall=";
239 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
240 $link .= ($checkall) ? '0' : '1';
244 echo "<a href=\"$link\">"._("All").'</a>';
247 case SQM_COL_FROM: echo _("From")."\n"; break;
248 case SQM_COL_DATE: echo _("Date")."\n"; break;
249 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
251 echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n";
253 case SQM_COL_SIZE: echo _("Size")."\n"; break;
255 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
257 case SQM_COL_ATTACHMENT:
258 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
260 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
261 case SQM_COL_TO: echo _("To")."\n"; break;
262 case SQM_COL_CC: echo _("Cc")."\n"; break;
263 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
266 // add the sort buttons
267 if (isset($aSortSupported[$iCol])) {
268 if ($sort == $aSortSupported[$iCol][0]) {
269 $newsort = $aSortSupported[$iCol][1];
270 $img = 'up_pointer.png';
271 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
272 } else if ($sort == $aSortSupported[$iCol][1]) {
274 $img = 'down_pointer.png';
275 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
277 $newsort = $aSortSupported[$iCol][0];
278 $img = 'sort_none.png';
279 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
281 /* Now that we have everything figured out, show the actual button. */
282 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\" style=\"text-decoration:none\">" .
283 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
292 <!-- end table header -->
294 <!-- Message headers start -->
297 $iColCnt = count($aOrder);
300 // this stuff does the auto row highlighting on mouseover
302 if ($javascript_on && $fancy_index_highlite) {
304 $mouseoverColor = $color[5];
306 // set this to an empty string to turn off extra
307 // highlighting of checked rows
309 //$clickedColor = '';
310 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
312 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
314 $checkbox_javascript = '';
316 foreach ($aMessages as $iUid => $aMsg) {
320 * Display message header row in messages list
324 $aColumns = $aMsg['columns'];
328 * Check the flags and set a class var.
330 if (isset($aColumns[SQM_COL_FLAGS])) {
331 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
332 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
334 /* add the flag string to the value index */
335 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
338 * Check the priority column
340 if (isset($aColumns[SQM_COL_PRIO])) {
341 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
342 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
346 * Check the attachment column
348 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
349 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
350 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
355 * If alternating row colors is set, adapt the CSS class
357 if (isset($alt_index_colors) && $alt_index_colors) {
363 if (isset($aMsg['row']['color']))
365 $bgcolor = $aMsg['row']['color'];
372 // this stuff does the auto row highlighting on mouseover
374 if ($javascript_on && $fancy_index_highlite) {
375 $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\');"';
377 // this does the auto-checking of the checkbox no matter
378 // where on the row you click
380 $javascript_auto_click = '';
381 if ($javascript_on && $fancy_index_highlite) {
382 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
383 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
387 * Message Highlighting requires a unique CSS class declaration for proper
388 * mouseover functionality. There is no harm in doing this when the mouseover
389 * functionality is disabled
391 if ($class != 'even' && $class != 'odd')
394 <style type="text/css">
396 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
402 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
404 // flag style mumbo jumbo
406 if (isset($aColumns[SQM_COL_FLAGS])) {
407 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
408 $sPre = '<span class="unread">'; $sEnd = '</span>';
410 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
411 $sPre = '<span class="deleted">' . $sPre;
414 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
415 $sPre = '<span class="flagged">' . $sPre;
421 * Because the order of the columns and which columns to show is a user preference
422 * we have to do some php coding to display the columns in the right order
424 foreach ($aOrder as $iCol) {
425 if (in_array($iCol, $show_label_columns)) {
426 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
427 $sLabelEnd = '</label>';
432 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
433 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
434 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
435 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
436 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
437 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
438 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
439 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
440 if ($iCol !== SQM_COL_CHECK) {
441 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
447 if ($javascript_on) {
448 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
449 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
452 echo '<td class="col_check">';
453 $checked = ($checkall) ? " checked=checked " : " ";
454 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
458 $indent = $aCol['indent'];
459 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
460 if ($align['left'] == 'left') {
461 $sText .= str_repeat(' ',$indent);
463 $sText .= "<a href=\"$link\"";
464 if ($target) { $sText .= " target=\"$target\""; }
465 if ($title) { $sText .= " title=\"$title\""; }
466 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
467 if ($link_extra) { $sText .= " $link_extra"; }
468 if ($javascript_on && $fancy_index_highlite) {
469 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
470 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
471 $clickedColor .'\');"';
474 $sText .= $value . '</a>';
475 if ($align['left'] == 'right') {
476 $sText .= str_repeat(' ',$indent);
478 echo $sText."</td>\n";
482 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
483 $sText .= "$value</td>\n";
486 case SQM_COL_INT_DATE:
488 $sText = " <td class=\"col_date\" $javascript_auto_click>";
489 $sText .= $value. "</td>\n";
493 $sText = " <td class=\"col_text\" $javascript_auto_click";
495 $sText .= "><a href=\"$link\"";
496 if ($target) { $sText .= " target=\"$target\"";}
497 if ($title) { $sText .= " title=\"$title\"" ;}
500 if ($title) {$sText .= " title=\"$title\"";}
504 if ($link) { $sText .= '</a>';}
505 echo $sText."</td>\n";
512 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
516 * End displaying row part
521 <!-- Message headers end -->
528 <tr><td class="spacer"></td></tr>
531 <table class="table_standard" cellspacing="0">
534 <table class="table_empty" cellspacing="0">
536 <td class="links_paginator"><?php echo $paginator_str; ?></td>
537 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
547 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>