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 . 'functions/template/message_list_util.php');
73 /* retrieve the template vars */
76 if (!empty($plugin_output['mailbox_index_before'])) echo $plugin_output['mailbox_index_before'];
79 * Calculate string "Viewing message x to y (z total)"
82 if ($pageOffset < $end_msg) {
83 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
84 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
85 } else if ($pageOffset == $end_msg) {
86 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
91 if (!($sort & SQSORT_THREAD) && $enablesort) {
92 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
93 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
94 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
95 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
96 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
97 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
98 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
100 $aSortSupported = array();
103 // figure out which columns should serve as labels for checkbox:
104 // we try to grab the two columns before and after the checkbox,
105 // except the subject column, since it is the link that opens
108 // if $javascript_on is set, then the highlighting code takes
109 // care of this; just skip it
111 $show_label_columns = array();
112 $index_order_part = array();
113 if (!($javascript_on && $fancy_index_highlite)) {
115 $last_order_part = 0;
116 $last_last_order_part = 0;
117 foreach ($aOrder as $index_order_part) {
118 if ($index_order_part == SQM_COL_CHECK) {
120 if ($last_last_order_part != SQM_COL_SUBJ)
121 $show_label_columns[] = $last_last_order_part;
122 if ($last_order_part != SQM_COL_SUBJ)
123 $show_label_columns[] = $last_order_part;
125 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
126 $show_label_columns[] = $index_order_part;
129 $last_last_order_part = $last_order_part;
130 $last_order_part = $index_order_part;
135 * All icon functionality is now handled through $icon_theme_path.
136 * $icon_theme_path will contain the path to the user-selected theme. If it is
137 * NULL, the user and/or admin have turned off icons.
140 // set this to an empty string to turn off extra
141 // highlighting of checked rows
143 //$clickedColor = '';
144 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
147 <div id="message_list">
148 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
149 <table class="table_empty" cellspacing="0">
152 <table class="table_standard" cellspacing="0">
155 <table class="table_empty" cellspacing="0">
157 <td class="links_paginator">
158 <!-- paginator and thread link string -->
161 * because the template is included in the display function we refer to $oTemplate with $this
163 $paginator_str = $this->fetch('paginator.tpl');
164 echo $paginator_str . $thread_link_str ."\n"; ?>
165 <!-- end paginator and thread link string -->
167 <!-- message count string -->
168 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
169 <!-- end message count string -->
175 if (count($aFormElements)) {
177 <!-- start message list form control -->
178 <tr class="message_list_controls">
180 <table class="table_empty" cellspacing="0">
182 <td class="message_control_buttons">
185 foreach ($aFormElements as $key => $value) {
188 if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
190 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />
195 if ($key != 'bypass_trash') {
197 <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>
202 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
209 <td class="message_control_delete">
213 if (isset($aFormElements['delete'])) {
215 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />
217 if (isset($aFormElements['bypass_trash'])) {
219 <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>
222 if (isset($aFormElements['undeleteButton'])) {
224 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />
230 } // if (isset($aFormElements['delete']))
231 if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
233 <td class="message_control_move">
234 <select name="targetMailbox">
235 <?php echo $aFormElements['targetMailbox'][0];?>
237 <?php if (isset($aFormElements['moveButton'])) { ?>
238 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
240 if (isset($aFormElements['copyButton'])) { ?>
241 <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
246 } // if (isset($aFormElements['move']))
252 <!-- end message list form control -->
254 } // if (count($aFormElements))
258 //FIXME: no hooks in templates!
259 do_hook('mailbox_form_before', $null);
263 <tr><td class="spacer"></td></tr>
266 <table class="table_messageListWrapper" cellspacing="0">
269 <table class="table_messageList" cellspacing="0">
270 <!-- table header start -->
273 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
274 * rendering this table if we use THEAD and TH tags. No other browser or platform has
275 * this issue. We will use TR/TD w/ another CSS class to work around this.
278 <tr class="headerRow">
280 $aWidth = calcMessageListColumnWidth($aOrder);
281 foreach($aOrder as $iCol) {
283 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
287 if ($javascript_on) {
288 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
290 $link = $baseurl . "&startMessage=$pageOffset&checkall=";
291 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
292 $link .= ($checkall) ? '0' : '1';
296 echo "<a href=\"$link\">"._("All").'</a>';
299 case SQM_COL_FROM: echo _("From")."\n"; break;
300 case SQM_COL_DATE: echo _("Date")."\n"; break;
301 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
303 echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n";
305 case SQM_COL_SIZE: echo _("Size")."\n"; break;
307 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
309 case SQM_COL_ATTACHMENT:
310 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
312 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
313 case SQM_COL_TO: echo _("To")."\n"; break;
314 case SQM_COL_CC: echo _("Cc")."\n"; break;
315 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
318 // add the sort buttons
319 if (isset($aSortSupported[$iCol])) {
320 if ($sort == $aSortSupported[$iCol][0]) {
321 $newsort = $aSortSupported[$iCol][1];
322 $img = 'up_pointer.png';
323 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
324 } else if ($sort == $aSortSupported[$iCol][1]) {
326 $img = 'down_pointer.png';
327 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
329 $newsort = $aSortSupported[$iCol][0];
330 $img = 'sort_none.png';
331 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
333 /* Now that we have everything figured out, show the actual button. */
334 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\" style=\"text-decoration:none\">" .
335 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
344 <!-- end table header -->
346 <!-- Message headers start -->
349 $iColCnt = count($aOrder);
352 // this stuff does the auto row highlighting on mouseover
354 if ($javascript_on && $fancy_index_highlite) {
356 $mouseoverColor = $color[5];
358 // set this to an empty string to turn off extra
359 // highlighting of checked rows
361 //$clickedColor = '';
362 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
364 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
366 $checkbox_javascript = '';
368 foreach ($aMessages as $iUid => $aMsg) {
372 * Display message header row in messages list
376 $aColumns = $aMsg['columns'];
380 * Check the flags and set a class var.
382 if (isset($aColumns[SQM_COL_FLAGS])) {
383 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
384 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
386 /* add the flag string to the value index */
387 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
390 * Check the priority column
392 if (isset($aColumns[SQM_COL_PRIO])) {
393 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
394 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
398 * Check the attachment column
400 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
401 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
402 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
407 * If alternating row colors is set, adapt the CSS class
409 if (isset($alt_index_colors) && $alt_index_colors) {
415 if (isset($aMsg['row']['color']))
417 $bgcolor = $aMsg['row']['color'];
424 // this stuff does the auto row highlighting on mouseover
426 if ($javascript_on && $fancy_index_highlite) {
427 $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\');"';
429 // this does the auto-checking of the checkbox no matter
430 // where on the row you click
432 $javascript_auto_click = '';
433 if ($javascript_on && $fancy_index_highlite) {
434 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
435 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
439 * Message Highlighting requires a unique CSS class declaration for proper
440 * mouseover functionality. There is no harm in doing this when the mouseover
441 * functionality is disabled
443 if ($class != 'even' && $class != 'odd')
446 <style type="text/css">
448 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
454 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
456 // flag style mumbo jumbo
458 if (isset($aColumns[SQM_COL_FLAGS])) {
459 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
460 $sPre = '<span class="unread">'; $sEnd = '</span>';
462 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
463 $sPre = '<span class="deleted">' . $sPre;
466 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
467 $sPre = '<span class="flagged">' . $sPre;
473 * Because the order of the columns and which columns to show is a user preference
474 * we have to do some php coding to display the columns in the right order
476 foreach ($aOrder as $iCol) {
477 if (in_array($iCol, $show_label_columns)) {
478 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
479 $sLabelEnd = '</label>';
484 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
485 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
486 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
487 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
488 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
489 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
490 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
491 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
492 if ($iCol !== SQM_COL_CHECK) {
493 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
499 if ($javascript_on) {
500 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
501 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
504 echo '<td class="col_check">';
505 $checked = ($checkall) ? " checked=checked " : " ";
506 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
510 $indent = $aCol['indent'];
511 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
512 if ($align['left'] == 'left') {
513 $sText .= str_repeat(' ',$indent);
515 $sText .= "<a href=\"$link\"";
516 if ($target) { $sText .= " target=\"$target\""; }
517 if ($title) { $sText .= " title=\"$title\""; }
518 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
519 if ($link_extra) { $sText .= " $link_extra"; }
520 if ($javascript_on && $fancy_index_highlite) {
521 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
522 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
523 $clickedColor .'\');"';
526 $sText .= $value . '</a>';
527 if ($align['left'] == 'right') {
528 $sText .= str_repeat(' ',$indent);
530 echo $sText."</td>\n";
534 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
535 $sText .= "$value</td>\n";
538 case SQM_COL_INT_DATE:
540 $sText = " <td class=\"col_date\" $javascript_auto_click>";
541 $sText .= $value. "</td>\n";
545 $sText = " <td class=\"col_text\" $javascript_auto_click";
547 $sText .= "><a href=\"$link\"";
548 if ($target) { $sText .= " target=\"$target\"";}
549 if ($title) { $sText .= " title=\"$title\"" ;}
552 if ($title) {$sText .= " title=\"$title\"";}
556 if ($link) { $sText .= '</a>';}
557 echo $sText."</td>\n";
564 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
568 * End displaying row part
573 <!-- Message headers end -->
580 <tr><td class="spacer"></td></tr>
583 <table class="table_standard" cellspacing="0">
586 <table class="table_empty" cellspacing="0">
588 <td class="links_paginator"><?php echo $paginator_str; ?></td>
589 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
599 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>