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
60 * $fancy_index_highlite
68 * @copyright © 1999-2006 The SquirrelMail Project Team
69 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
71 * @package squirrelmail
72 * @subpackage templates
76 /** add required includes */
77 include_once(SM_PATH . 'functions/template/message_list_util.php');
80 /* retrieve the template vars */
84 if (!empty($plugin_output['mailbox_index_before'])) echo $plugin_output['mailbox_index_before'];
88 * Calculate string "Viewing message x to y (z total)"
91 if ($pageOffset < $end_msg) {
92 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
93 '<em>' . $pageOffset . '</em>',
94 '<em>' . $end_msg . '</em>',
96 } else if ($pageOffset == $end_msg) {
97 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"),
98 '<em>' . $pageOffset . '</em>',
104 * All icon functionality is now handled through $icon_theme_path.
105 * $icon_theme_path will contain the path to the user-selected theme. If it is
106 * NULL, the user and/or admin have turned off icons.
111 <div id="message_list">
112 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
113 <table class="table_empty" cellspacing="0">
116 <table class="table_standard" cellspacing="0">
119 <table class="table_empty" cellspacing="0">
121 <td class="links_paginator">
122 <!-- paginator and thread link string -->
125 * The following line gets the output from a separate
126 * template altogether (called "paginator.tpl").
127 * $this is the Template class object.
129 $paginator_str = $this->fetch('paginator.tpl');
130 echo $paginator_str . '<small>[<a href="' . $thread_link_uri
131 . '">' . $thread_name . '</a>]</small> ';
132 if (!empty($plugin_output['mailbox_paginator_after'])) echo $plugin_output['mailbox_paginator_after'];
134 <!-- end paginator and thread link string -->
136 <!-- message count string -->
137 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
138 <!-- end message count string -->
144 if (count($aFormElements)) {
146 <!-- start message list form control -->
147 <tr class="message_list_controls">
151 * The following line gets the output from a separate
152 * template altogether (called "message_list_controls.tpl").
153 * $this is the Template class object.
155 $message_list_controls = $this->fetch('message_list_controls.tpl');
156 echo $message_list_controls ."\n"; ?>
159 <!-- end message list form control -->
161 } // if (count($aFormElements))
164 <?php if (!empty($plugin_output['mailbox_form_before'])) echo $plugin_output['mailbox_form_before']; ?>
167 <tr><td class="spacer"></td></tr>
170 <table class="table_messageListWrapper" cellspacing="0">
173 <table class="table_messageList" cellspacing="0">
174 <!-- table header start -->
177 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
178 * rendering this table if we use THEAD and TH tags. No other browser or platform has
179 * this issue. We will use TR/TD w/ another CSS class to work around this.
183 <tr class="headerRow">
186 $aWidth = calcMessageListColumnWidth($aOrder);
187 foreach($aOrder as $iCol) {
190 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
195 if ($javascript_on) {
196 $checked = ($checkall ? ' checked="checked" ' : '');
197 echo '<input type="checkbox" name="toggleAll" id="toggleAll" title="'
198 . _("Toggle All") . '" onclick="toggle_all(\''
199 . $form_name . '\', \'msg\', ' . $fancy_index_highlite
200 . '); return false;" ' . $checked . '/>' . "\n";
203 . "&startMessage=$pageOffset&checkall="
204 . ($checkall ? '0' : '1');
205 echo "<a href=\"$link\">" . _("All") . '</a>';
209 echo '<label for="toggleAll">' . _("From") . "</label>\n";
211 case SQM_COL_DATE: echo _("Date") . "\n"; break;
212 case SQM_COL_SUBJ: echo _("Subject") . "\n"; break;
214 echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n";
216 case SQM_COL_SIZE: echo _("Size") . "\n"; break;
218 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
220 case SQM_COL_ATTACHMENT:
221 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
223 case SQM_COL_INT_DATE: echo _("Received") . "\n"; break;
225 echo '<label for="toggleAll">' . _("To") . "</label>\n";
227 case SQM_COL_CC: echo _("Cc") . "\n"; break;
228 case SQM_COL_BCC: echo _("Bcc") . "\n"; break;
231 // add the sort buttons
232 if (isset($aSortSupported[$iCol])) {
233 if ($sort == $aSortSupported[$iCol][0]) {
234 $newsort = $aSortSupported[$iCol][1];
235 $img = 'up_pointer.png';
236 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
237 } else if ($sort == $aSortSupported[$iCol][1]) {
239 $img = 'down_pointer.png';
240 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
242 $newsort = $aSortSupported[$iCol][0];
243 $img = 'sort_none.png';
244 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
246 /* Now that we have everything figured out, show the actual button. */
247 echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\" style=\"text-decoration:none\">" .
248 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
257 <!-- end table header -->
259 <!-- Message headers start -->
263 $iColCnt = count($aOrder);
267 // this stuff does the auto row highlighting on mouseover
269 if (!empty($plugin_output['checkbox_javascript_onclick'])) $checkbox_javascript_onclick = $plugin_output['checkbox_javascript_onclick'];
270 else $checkbox_javascript_onclick = '';
272 if ($javascript_on && $fancy_index_highlite) {
273 $checkbox_javascript = ' onclick="this.checked = !this.checked; ' . $checkbox_javascript_onclick . '"';
274 } else if (!empty($checkbox_javascript_onclick)) {
275 $checkbox_javascript = ' onclick="' . $checkbox_javascript_onclick . '"';
277 $checkbox_javascript = '';
282 * main message iteration loop
284 foreach ($aMessages as $iUid => $aMsg) {
290 * Display message header row in messages list
294 $aColumns = $aMsg['columns'];
298 * Check the flags and set a class var.
300 if (isset($aColumns[SQM_COL_FLAGS])) {
301 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
302 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
304 /* add the flag string to the value index */
305 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
308 * Check the priority column
310 if (isset($aColumns[SQM_COL_PRIO])) {
311 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
312 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
316 * Check the attachment column
318 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
319 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
320 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
323 $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even');
324 $non_clicked_class = 'even';
327 * If alternating row colors is set, adapt the CSS class
329 if (isset($alt_index_colors) && $alt_index_colors) {
331 $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd');
332 $non_clicked_class = 'odd';
338 * Message Highlighting Functionality
340 if (isset($aMsg['row']['color']))
342 if (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite) {
343 //FIXME: would be best not to use $color directly here; want to move this to be a CSS style-defined value only, but the problem is that this CSS class is being defined on the fly right here
344 $bgcolor = $color[16];
345 $class = 'clicked_misc'.$i;
347 $bgcolor = $aMsg['row']['color'];
350 $non_clicked_class = 'misc'.$i;
351 $non_clicked_bgcolor = $aMsg['row']['color'];
356 $non_clicked_bgcolor = '';
361 // this stuff does the auto row highlighting on mouseover
363 if ($javascript_on && $fancy_index_highlite) {
364 $row_extra = ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');"';
366 // this does the auto-checking of the checkbox no matter
367 // where on the row you click
369 $javascript_auto_click = '';
370 $row_click_extra = '';
371 if (!empty($plugin_output['row_click_extra'])) $row_click_extra = $plugin_output['row_click_extra'];
372 if ($javascript_on && $fancy_index_highlite) {
373 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
374 $javascript_auto_click = " onmousedown=\"row_click('$form_id"."_msg$i', event, '$form_name', 'msg[' + $i + ']', '$row_click_extra')\"";
379 * Message Highlighting requires a unique CSS class declaration for proper
380 * mouseover functionality. There is no harm in doing this when the mouseover
381 * functionality is disabled
383 if ($class != 'even' && $class != 'odd'
384 && $class != 'clicked_even' && $class != 'clicked_odd')
387 <style type="text/css">
389 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
394 if ($non_clicked_class != 'even' && $non_clicked_class != 'odd'
395 && $non_clicked_class != 'clicked_even' && $non_clicked_class != 'clicked_odd')
398 <style type="text/css">
400 .table_messageList tr.<?php echo $non_clicked_class; ?> { background:<?php echo $non_clicked_bgcolor; ?> }
408 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
410 // flag style mumbo jumbo
412 if (isset($aColumns[SQM_COL_FLAGS])) {
413 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
414 $sPre = '<span class="unread">'; $sEnd = '</span>';
416 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
417 $sPre = '<span class="deleted">' . $sPre;
420 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
421 $sPre = '<span class="flagged">' . $sPre;
427 * Because the order of the columns and which columns to show is a user preference
428 * we have to do some php coding to display the columns in the right order
430 foreach ($aOrder as $iCol) {
431 if (in_array($iCol, $show_label_columns)) {
432 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
433 $sLabelEnd = '</label>';
438 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
439 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
440 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
441 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
442 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
443 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
444 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
445 if ($iCol !== SQM_COL_CHECK) {
446 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
452 $checked = (($checkall || in_array($iUid, $preselected)) ? ' checked="checked" ' : '');
453 if ($javascript_on) {
454 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
455 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript . $checked;?> /></td>
458 echo '<td class="col_check">';
459 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
463 $indent = $aCol['indent'];
464 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
465 if ($align['left'] == 'left') {
466 $sText .= str_repeat(' ',$indent);
468 $sText .= "<a href=\"$link\"";
469 if ($target) { $sText .= " target=\"$target\""; }
470 if ($title) { $sText .= " title=\"$title\""; }
471 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
472 if ($link_extra) { $sText .= " $link_extra"; }
473 if ($javascript_on && $fancy_index_highlite) {
474 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i', event, '$form_name', 'msg[' + $i + ']', '$row_click_extra'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
475 'parentNode.parentNode, ' . $i . ', \'click\', \''. $non_clicked_class. '\', \'mouse_over\', \'clicked\');"';
479 if ($align['left'] == 'right') {
480 $sText .= str_repeat(' ',$indent);
482 echo $sText."</td>\n";
486 $sText = " <td class=\"col_flags\" $javascript_auto_click>"
490 case SQM_COL_INT_DATE:
492 $sText = " <td class=\"col_date\" $javascript_auto_click>"
497 $sText = " <td class=\"col_text\" $javascript_auto_click";
499 $sText .= "><a href=\"$link\"";
500 if ($target) { $sText .= " target=\"$target\"";}
501 if ($title) { $sText .= " title=\"$title\"" ;}
504 if ($title) {$sText .= " title=\"$title\"";}
508 if ($link) { $sText .= '</a>';}
509 echo $sText."</td>\n";
515 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
519 * End displaying row part
524 <!-- Message headers end -->
531 <tr><td class="spacer"></td></tr>
534 <table class="table_standard" cellspacing="0">
537 <table class="table_empty" cellspacing="0">
539 <td class="links_paginator"><?php
541 * The following line gets the output from a separate
542 * template altogether (called "paginator.tpl").
543 * $this is the Template class object.
545 $paginator_str = $this->fetch('paginator.tpl');
547 if (!empty($plugin_output['mailbox_paginator_after'])) echo $plugin_output['mailbox_paginator_after'];
549 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
559 <?php if (!empty($plugin_output['mailbox_index_after'])) echo $plugin_output['mailbox_index_after']; ?>
566 <?php if (!$hide_sm_attributions): ?>
567 <p class="sqm_squirrelcopyright">© <?php echo SM_COPYRIGHT ?> The SquirrelMail Project Team - <a href="about.php">About SquirrelMail</a></p>