6 * Template for viewing a messages list
8 * The following variables are available in this template:
9 //FIXME: need to clean (and document) this list, it is just a dump of the array keys of $t
26 * $hide_sm_attributions
59 * $fancy_index_highlite
63 * @copyright © 1999-2006 The SquirrelMail Project Team
64 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
66 * @package squirrelmail
67 * @subpackage templates
70 /** add required includes */
71 include_once(SM_PATH . 'templates/util_message_list.php');
73 /* retrieve the template vars */
76 //FIXME: no hooks in templates!
78 do_hook('mailbox_index_before', $null);
81 * Calculate string "Viewing message x to y (z total)"
84 if ($pageOffset < $end_msg) {
85 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
86 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
87 } else if ($pageOffset == $end_msg) {
88 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
93 if (!($sort & SQSORT_THREAD) && $enablesort) {
94 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
95 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
96 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
97 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
98 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
99 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
100 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
102 $aSortSupported = array();
105 // figure out which columns should serve as labels for checkbox:
106 // we try to grab the two columns before and after the checkbox,
107 // except the subject column, since it is the link that opens
110 // if $javascript_on is set, then the highlighting code takes
111 // care of this; just skip it
113 $show_label_columns = array();
114 $index_order_part = array();
115 if (!($javascript_on && $fancy_index_highlite)) {
117 $last_order_part = 0;
118 $last_last_order_part = 0;
119 foreach ($aOrder as $index_order_part) {
120 if ($index_order_part == SQM_COL_CHECK) {
122 if ($last_last_order_part != SQM_COL_SUBJ)
123 $show_label_columns[] = $last_last_order_part;
124 if ($last_order_part != SQM_COL_SUBJ)
125 $show_label_columns[] = $last_order_part;
127 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
128 $show_label_columns[] = $index_order_part;
131 $last_last_order_part = $last_order_part;
132 $last_order_part = $index_order_part;
137 * All icon functionality is now handled through $icon_theme_path.
138 * $icon_theme_path will contain the path to the user-selected theme. If it is
139 * NULL, the user and/or admin have turned off icons.
142 // set this to an empty string to turn off extra
143 // highlighting of checked rows
145 //$clickedColor = '';
146 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
149 <div id="message_list">
150 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
151 <table class="table_empty" cellspacing="0">
154 <table class="table_standard" cellspacing="0">
157 <table class="table_empty" cellspacing="0">
159 <td class="links_paginator">
160 <!-- paginator and thread link string -->
163 * because the template is included in the display function we refer to $oTemplate with $this
165 $paginator_str = $this->fetch('paginator.tpl');
166 echo $paginator_str . $thread_link_str ."\n"; ?>
167 <!-- end paginator and thread link string -->
169 <!-- message count string -->
170 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
171 <!-- end message count string -->
177 if (count($aFormElements)) {
179 <!-- start message list form control -->
180 <tr class="message_list_controls">
182 <table class="table_empty" cellspacing="0">
184 <td class="message_control_buttons">
187 foreach ($aFormElements as $key => $value) {
190 if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
192 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />
197 if ($key != 'bypass_trash') {
199 <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>
204 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
211 <td class="message_control_delete">
215 if (isset($aFormElements['delete'])) {
217 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />
219 if (isset($aFormElements['bypass_trash'])) {
221 <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>
224 if (isset($aFormElements['undeleteButton'])) {
226 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />
232 } // if (isset($aFormElements['delete']))
233 if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
235 <td class="message_control_move">
236 <select name="targetMailbox">
237 <?php echo $aFormElements['targetMailbox'][0];?>
239 <?php if (isset($aFormElements['moveButton'])) { ?>
240 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
242 if (isset($aFormElements['copyButton'])) { ?>
243 <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
248 } // if (isset($aFormElements['move']))
254 <!-- end message list form control -->
256 } // if (count($aFormElements))
260 //FIXME: no hooks in templates!
261 do_hook('mailbox_form_before', $null);
265 <tr><td class="spacer"></td></tr>
268 <table class="table_messageListWrapper" cellspacing="0">
271 <table class="table_messageList" cellspacing="0">
272 <!-- table header start -->
275 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
276 * rendering this table if we use THEAD and TH tags. No other browser or platform has
277 * this issue. We will use TR/TD w/ another CSS class to work around this.
280 <tr class="headerRow">
282 $aWidth = calcMessageListColumnWidth($aOrder);
283 foreach($aOrder as $iCol) {
285 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
289 if ($javascript_on) {
290 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
292 $link = $baseurl . "&startMessage=$pageOffset&checkall=";
293 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
294 $link .= ($checkall) ? '0' : '1';
298 echo "<a href=\"$link\">"._("All").'</a>';
301 case SQM_COL_FROM: echo _("From")."\n"; break;
302 case SQM_COL_DATE: echo _("Date")."\n"; break;
303 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
305 echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n";
307 case SQM_COL_SIZE: echo _("Size")."\n"; break;
309 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
311 case SQM_COL_ATTACHMENT:
312 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
314 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
315 case SQM_COL_TO: echo _("To")."\n"; break;
316 case SQM_COL_CC: echo _("Cc")."\n"; break;
317 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
320 // add the sort buttons
321 if (isset($aSortSupported[$iCol])) {
322 if ($sort == $aSortSupported[$iCol][0]) {
323 $newsort = $aSortSupported[$iCol][1];
324 $img = 'up_pointer.png';
325 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
326 } else if ($sort == $aSortSupported[$iCol][1]) {
328 $img = 'down_pointer.png';
329 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
331 $newsort = $aSortSupported[$iCol][0];
332 $img = 'sort_none.png';
333 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
335 /* Now that we have everything figured out, show the actual button. */
336 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\" style=\"text-decoration:none\">" .
337 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
346 <!-- end table header -->
348 <!-- Message headers start -->
351 $iColCnt = count($aOrder);
354 // this stuff does the auto row highlighting on mouseover
356 if ($javascript_on && $fancy_index_highlite) {
358 $mouseoverColor = $color[5];
360 // set this to an empty string to turn off extra
361 // highlighting of checked rows
363 //$clickedColor = '';
364 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
366 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
368 $checkbox_javascript = '';
370 foreach ($aMessages as $iUid => $aMsg) {
374 * Display message header row in messages list
378 $aColumns = $aMsg['columns'];
382 * Check the flags and set a class var.
384 if (isset($aColumns[SQM_COL_FLAGS])) {
385 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
386 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
388 /* add the flag string to the value index */
389 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
392 * Check the priority column
394 if (isset($aColumns[SQM_COL_PRIO])) {
395 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
396 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
400 * Check the attachment column
402 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
403 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
404 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
409 * If alternating row colors is set, adapt the CSS class
411 if (isset($alt_index_colors) && $alt_index_colors) {
417 if (isset($aMsg['row']['color']))
419 $bgcolor = $aMsg['row']['color'];
426 // this stuff does the auto row highlighting on mouseover
428 if ($javascript_on && $fancy_index_highlite) {
429 $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\');"';
431 // this does the auto-checking of the checkbox no matter
432 // where on the row you click
434 $javascript_auto_click = '';
435 if ($javascript_on && $fancy_index_highlite) {
436 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
437 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
441 * Message Highlighting requires a unique CSS class declaration for proper
442 * mouseover functionality. There is no harm in doing this when the mouseover
443 * functionality is disabled
445 if ($class != 'even' && $class != 'odd')
448 <style type="text/css">
450 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
456 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
458 // flag style mumbo jumbo
460 if (isset($aColumns[SQM_COL_FLAGS])) {
461 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
462 $sPre = '<span class="unread">'; $sEnd = '</span>';
464 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
465 $sPre = '<span class="deleted">' . $sPre;
468 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
469 $sPre = '<span class="flagged">' . $sPre;
475 * Because the order of the columns and which columns to show is a user preference
476 * we have to do some php coding to display the columns in the right order
478 foreach ($aOrder as $iCol) {
479 if (in_array($iCol, $show_label_columns)) {
480 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
481 $sLabelEnd = '</label>';
486 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
487 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
488 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
489 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
490 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
491 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
492 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
493 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
494 if ($iCol !== SQM_COL_CHECK) {
495 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
501 if ($javascript_on) {
502 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
503 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
506 echo '<td class="col_check">';
507 $checked = ($checkall) ? " checked=checked " : " ";
508 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
512 $indent = $aCol['indent'];
513 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
514 if ($align['left'] == 'left') {
515 $sText .= str_repeat(' ',$indent);
517 $sText .= "<a href=\"$link\"";
518 if ($target) { $sText .= " target=\"$target\""; }
519 if ($title) { $sText .= " title=\"$title\""; }
520 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
521 if ($link_extra) { $sText .= " $link_extra"; }
522 if ($javascript_on && $fancy_index_highlite) {
523 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
524 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
525 $clickedColor .'\');"';
528 $sText .= $value . '</a>';
529 if ($align['left'] == 'right') {
530 $sText .= str_repeat(' ',$indent);
532 echo $sText."</td>\n";
536 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
537 $sText .= "$value</td>\n";
540 case SQM_COL_INT_DATE:
542 $sText = " <td class=\"col_date\" $javascript_auto_click>";
543 $sText .= $value. "</td>\n";
547 $sText = " <td class=\"col_text\" $javascript_auto_click";
549 $sText .= "><a href=\"$link\"";
550 if ($target) { $sText .= " target=\"$target\"";}
551 if ($title) { $sText .= " title=\"$title\"" ;}
554 if ($title) {$sText .= " title=\"$title\"";}
558 if ($link) { $sText .= '</a>';}
559 echo $sText."</td>\n";
566 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
570 * End displaying row part
575 <!-- Message headers end -->
582 <tr><td class="spacer"></td></tr>
585 <table class="table_standard" cellspacing="0">
588 <table class="table_empty" cellspacing="0">
590 <td class="links_paginator"><?php echo $paginator_str; ?></td>
591 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
601 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>