Add FIXME
[squirrelmail.git] / templates / default / message_list.tpl
CommitLineData
49db257d 1<?php
2
3/**
4 * message_list.tpl
5 *
49db257d 6 * Template for viewing a messages list
7 *
83d1e1af 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
10 * $sTemplateID
11 * $icon_theme_path
12 * $javascript_on
13 * $delayed_errors
14 * $frames
15 * $lang
16 * $page_title
17 * $header_tags
18 * $plugin_output
19 * $header_sent
20 * $body_tag_js
21 * $shortBoxName
e6e2e7fd 22 * $provider_link
83d1e1af 23 * $frame_top
24 * $urlMailbox
25 * $startMessage
26 * $hide_sm_attributions
27 * $uri
28 * $text
29 * $onclick
30 * $class
31 * $id
32 * $target
33 * $color
34 * $form_name
35 * $form_id
36 * $page_selector
37 * $page_selector_max
38 * $messagesPerPage
39 * $showall
40 * $end_msg
41 * $align
42 * $iNumberOfMessages
43 * $aOrder
44 * $aFormElements
45 * $sort
46 * $pageOffset
47 * $baseurl
48 * $aMessages
49 * $trash_folder
50 * $sent_folder
51 * $draft_folder
cd693cf4 52 * $thread_link_uri
53 * $thread_name
83d1e1af 54 * $php_self
55 * $mailbox
56 * $enablesort
57 * $icon_theme
58 * $use_icons
59 * $alt_index_colors
60 * $fancy_index_highlite
4127171c 61 * $aSortSupported
62 * $show_label_columns
83d1e1af 63 * $compact_paginator
64 * $aErrors
e0a6645e 65 * $checkall
02def6a1 66 * $preselected
83d1e1af 67 *
47ccfad4 68 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 69 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
49db257d 70 * @version $Id$
71 * @package squirrelmail
57d06b39 72 * @subpackage templates
49db257d 73 */
74
4127171c 75
f2e2aa7f 76/** add required includes */
a1d29fb8 77include_once(SM_PATH . 'functions/template/message_list_util.php');
49db257d 78
4127171c 79
49db257d 80/* retrieve the template vars */
81extract($t);
82
4127171c 83
a1d29fb8 84if (!empty($plugin_output['mailbox_index_before'])) echo $plugin_output['mailbox_index_before'];
49db257d 85
4127171c 86
49db257d 87/**
88 * Calculate string "Viewing message x to y (z total)"
89 */
90$msg_cnt_str = '';
91if ($pageOffset < $end_msg) {
92 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
4127171c 93 '<em>' . $pageOffset . '</em>',
94 '<em>' . $end_msg . '</em>',
95 $iNumberOfMessages);
49db257d 96} else if ($pageOffset == $end_msg) {
4127171c 97 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"),
98 '<em>' . $pageOffset . '</em>',
99 $iNumberOfMessages);
49db257d 100}
101
49db257d 102
583db309 103/**
29997535 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.
4127171c 107 */
108
583db309 109
49db257d 110?>
e3812cb2 111<div id="message_list">
a73c1312 112<form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
e3812cb2 113<table class="table_empty" cellspacing="0">
49db257d 114 <tr>
e3812cb2 115 <td>
116 <table class="table_standard" cellspacing="0">
49db257d 117 <tr>
118 <td>
e3812cb2 119 <table class="table_empty" cellspacing="0">
49db257d 120 <tr>
e3812cb2 121 <td class="links_paginator">
49db257d 122<!-- paginator and thread link string -->
123 <?php
4127171c 124 /**
125 * The following line gets the output from a separate
126 * template altogether (called "paginator.tpl").
127 * $this is the Template class object.
49db257d 128 */
129 $paginator_str = $this->fetch('paginator.tpl');
cd693cf4 130 echo $paginator_str . '<small>[<a href="' . $thread_link_uri
cad0ba1a 131 . '">' . $thread_name . '</a>]</small>&nbsp;&nbsp;';
00d0bdda 132 if (!empty($plugin_output['mailbox_paginator_after'])) echo $plugin_output['mailbox_paginator_after'];
133 ?>
49db257d 134<!-- end paginator and thread link string -->
49db257d 135 </td>
136<!-- message count string -->
e3812cb2 137 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
49db257d 138<!-- end message count string -->
139 </tr>
140 </table>
141 </td>
142 </tr>
143<?php
144 if (count($aFormElements)) {
145?>
146<!-- start message list form control -->
d915a2ca 147 <tr class="message_list_controls">
49db257d 148 <td>
69a023cf 149 <?php
150 /**
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.
154 */
155 $message_list_controls = $this->fetch('message_list_controls.tpl');
156 echo $message_list_controls ."\n"; ?>
49db257d 157 </td>
158 </tr>
159<!-- end message list form control -->
160<?php
161 } // if (count($aFormElements))
162?>
163 </table>
4127171c 164<?php if (!empty($plugin_output['mailbox_form_before'])) echo $plugin_output['mailbox_form_before']; ?>
49db257d 165 </td>
166 </tr>
e3812cb2 167 <tr><td class="spacer"></td></tr>
49db257d 168 <tr>
169 <td>
e3812cb2 170 <table class="table_messageListWrapper" cellspacing="0">
49db257d 171 <tr>
172 <td>
e3812cb2 173 <table class="table_messageList" cellspacing="0">
49db257d 174<!-- table header start -->
e3812cb2 175<?php
176/*
177 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
ac858073 178 * rendering this table if we use THEAD and TH tags. No other browser or platform has
e3812cb2 179 * this issue. We will use TR/TD w/ another CSS class to work around this.
180 */
181?>
4127171c 182
e3812cb2 183 <tr class="headerRow">
4127171c 184
49db257d 185<?php
186 $aWidth = calcMessageListColumnWidth($aOrder);
187 foreach($aOrder as $iCol) {
49db257d 188?>
4127171c 189
e3812cb2 190 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
4127171c 191
49db257d 192<?php
193 switch ($iCol) {
194 case SQM_COL_CHECK:
195 if ($javascript_on) {
e0a6645e 196 $checked = ($checkall ? ' checked="checked" ' : '');
63d19712 197 echo '<input type="checkbox" name="toggleAll" id="toggleAll" title="'
198 . _("Toggle All") . '" onclick="toggle_all(\''
199 . $form_name . '\', \'msg\', ' . $fancy_index_highlite
9ce7076c 200 . '); return false;" ' . $checked . '/>' . "\n";
49db257d 201 } else {
e0a6645e 202 $link = $baseurl
203 . "&amp;startMessage=$pageOffset&amp;checkall="
204 . ($checkall ? '0' : '1');
63d19712 205 echo "<a href=\"$link\">" . _("All") . '</a>';
49db257d 206 }
207 break;
ddf0ebe1 208 case SQM_COL_FROM:
209 echo '<label for="toggleAll">' . _("From") . "</label>\n";
210 break;
211 case SQM_COL_DATE: echo _("Date") . "\n"; break;
212 case SQM_COL_SUBJ: echo _("Subject") . "\n"; break;
583db309 213 case SQM_COL_FLAGS:
29997535 214 echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
215 break;
ddf0ebe1 216 case SQM_COL_SIZE: echo _("Size") . "\n"; break;
583db309 217 case SQM_COL_PRIO:
29997535 218 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
219 break;
583db309 220 case SQM_COL_ATTACHMENT:
29997535 221 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
222 break;
ddf0ebe1 223 case SQM_COL_INT_DATE: echo _("Received") . "\n"; break;
e8b30fd3 224 case SQM_COL_TO:
225 echo '<label for="toggleAll">' . _("To") . "</label>\n";
226 break;
ddf0ebe1 227 case SQM_COL_CC: echo _("Cc") . "\n"; break;
228 case SQM_COL_BCC: echo _("Bcc") . "\n"; break;
49db257d 229 default: break;
230 }
231 // add the sort buttons
232 if (isset($aSortSupported[$iCol])) {
233 if ($sort == $aSortSupported[$iCol][0]) {
29997535 234 $newsort = $aSortSupported[$iCol][1];
235 $img = 'up_pointer.png';
8af5b50c 236 $text_icon = '&#8679;'; // U+21E7 UPWARDS WHITE ARROW
49db257d 237 } else if ($sort == $aSortSupported[$iCol][1]) {
29997535 238 $newsort = 0;
239 $img = 'down_pointer.png';
8af5b50c 240 $text_icon = '&#8681;'; // U+21E9 DOWNWARDS WHITE ARROW
49db257d 241 } else {
29997535 242 $newsort = $aSortSupported[$iCol][0];
243 $img = 'sort_none.png';
8af5b50c 244 $text_icon = '&#9723;'; // U+25FB WHITE MEDIUM SQUARE
49db257d 245 }
246 /* Now that we have everything figured out, show the actual button. */
8af5b50c 247 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\" style=\"text-decoration:none\">" .
6c68e276 248 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
29997535 249 '</a>';
49db257d 250 }
251?>
49db257d 252 </td>
253<?php
254 }
255?>
e3812cb2 256 </tr>
257<!-- end table header -->
49db257d 258
259<!-- Message headers start -->
260<?php
3d621333 261
49db257d 262 $i = 0;
263 $iColCnt = count($aOrder);
264 $sLine = '';
265
3d621333 266
49db257d 267 // this stuff does the auto row highlighting on mouseover
268 //
109e876c 269 if (!empty($plugin_output['checkbox_javascript_onclick'])) $checkbox_javascript_onclick = $plugin_output['checkbox_javascript_onclick'];
270 else $checkbox_javascript_onclick = '';
271
49db257d 272 if ($javascript_on && $fancy_index_highlite) {
109e876c 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 . '"';
799ee2d5 276 } else {
277 $checkbox_javascript = '';
49db257d 278 }
3d621333 279
280
281 /**
282 * main message iteration loop
283 */
49db257d 284 foreach ($aMessages as $iUid => $aMsg) {
3d621333 285
49db257d 286 echo $sLine;
287
3d621333 288
49db257d 289/**
290* Display message header row in messages list
291*
292*/
293
294 $aColumns = $aMsg['columns'];
295
49db257d 296
297 /**
298 * Check the flags and set a class var.
299 */
300 if (isset($aColumns[SQM_COL_FLAGS])) {
301 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
29997535 302 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
49db257d 303
49db257d 304 /* add the flag string to the value index */
305 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
306 }
307 /**
308 * Check the priority column
309 */
310 if (isset($aColumns[SQM_COL_PRIO])) {
29997535 311 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
49db257d 312 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
313 }
314
315 /**
316 * Check the attachment column
317 */
318 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
29997535 319 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
49db257d 320 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
321 }
322
02def6a1 323 $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even');
e0a6645e 324 $non_clicked_class = 'even';
325
49db257d 326 /**
e3812cb2 327 * If alternating row colors is set, adapt the CSS class
49db257d 328 */
329 if (isset($alt_index_colors) && $alt_index_colors) {
330 if (!($i % 2)) {
02def6a1 331 $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd');
e0a6645e 332 $non_clicked_class = 'odd';
49db257d 333 }
334
335 }
9c928f05 336
337 /**
338 * Message Highlighting Functionality
339 */
e3812cb2 340 if (isset($aMsg['row']['color']))
341 {
02def6a1 342 if (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite) {
9c928f05 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;
346 } else {
347 $bgcolor = $aMsg['row']['color'];
348 $class = 'misc'.$i;
349 }
350 $non_clicked_class = 'misc'.$i;
351 $non_clicked_bgcolor = $aMsg['row']['color'];
352 }
353 else
354 {
355 $bgcolor = '';
356 $non_clicked_bgcolor = '';
e3812cb2 357 }
49db257d 358
359 $row_extra = '';
360
361 // this stuff does the auto row highlighting on mouseover
362 //
363 if ($javascript_on && $fancy_index_highlite) {
e0a6645e 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\');"';
49db257d 365 }
366 // this does the auto-checking of the checkbox no matter
367 // where on the row you click
368 //
369 $javascript_auto_click = '';
109e876c 370 $row_click_extra = '';
371 if (!empty($plugin_output['row_click_extra'])) $row_click_extra = $plugin_output['row_click_extra'];
49db257d 372 if ($javascript_on && $fancy_index_highlite) {
373 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
109e876c 374 $javascript_auto_click = " onmousedown=\"row_click('$form_id"."_msg$i', event, '$form_name', 'msg[' + $i + ']', '$row_click_extra')\"";
49db257d 375 }
376
9c928f05 377
e3812cb2 378/*
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
382 */
e0a6645e 383if ($class != 'even' && $class != 'odd'
9c928f05 384 && $class != 'clicked_even' && $class != 'clicked_odd')
e3812cb2 385{
386?>
387<style type="text/css">
388<!--
389.table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
390-->
391</style>
d7f26e6e 392<?php
e3812cb2 393}
9c928f05 394if ($non_clicked_class != 'even' && $non_clicked_class != 'odd'
395 && $non_clicked_class != 'clicked_even' && $non_clicked_class != 'clicked_odd')
396{
397?>
398<style type="text/css">
399<!--
400.table_messageList tr.<?php echo $non_clicked_class; ?> { background:<?php echo $non_clicked_bgcolor; ?> }
401-->
402</style>
403<?php
404}
405
406
49db257d 407?>
e3812cb2 408<tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
49db257d 409<?php
410 // flag style mumbo jumbo
411 $sPre = $sEnd = '';
bf9e5efb 412 if (isset($aColumns[SQM_COL_FLAGS])) {
1be82af6 413 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
e3812cb2 414 $sPre = '<span class="unread">'; $sEnd = '</span>';
f2e2aa7f 415 }
416 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
e3812cb2 417 $sPre = '<span class="deleted">' . $sPre;
418 $sEnd .= '</span>';
f2e2aa7f 419 } else {
420 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
e3812cb2 421 $sPre = '<span class="flagged">' . $sPre;
422 $sEnd .= '</span>';
f2e2aa7f 423 }
49db257d 424 }
425 }
426 /**
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
429 */
430 foreach ($aOrder as $iCol) {
6547ab43 431 if (in_array($iCol, $show_label_columns)) {
6d34ad62 432 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
49db257d 433 $sLabelEnd = '</label>';
434 } else {
435 $sLabelStart = '';
436 $sLabelEnd = '';
437 }
02e830bd 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'] : '';
02e830bd 443 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
444 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
49db257d 445 if ($iCol !== SQM_COL_CHECK) {
446 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
447 }
448
449
450 switch ($iCol) {
451 case SQM_COL_CHECK:
02def6a1 452 $checked = (($checkall || in_array($iUid, $preselected)) ? ' checked="checked" ' : '');
ac858073 453 if ($javascript_on) {
454 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
e0a6645e 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>
49db257d 456 <?php
ac858073 457 } else {
458 echo '<td class="col_check">';
ac858073 459 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
460 }
49db257d 461 break;
462 case SQM_COL_SUBJ:
463 $indent = $aCol['indent'];
e3812cb2 464 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
49db257d 465 if ($align['left'] == 'left') {
466 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
467 }
468 $sText .= "<a href=\"$link\"";
02e830bd 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"; }
49db257d 473 if ($javascript_on && $fancy_index_highlite) {
109e876c 474 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i', event, '$form_name', 'msg[' + $i + ']', '$row_click_extra'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
e0a6645e 475 'parentNode.parentNode, ' . $i . ', \'click\', \''. $non_clicked_class. '\', \'mouse_over\', \'clicked\');"';
49db257d 476 }
3d621333 477 $sText .= ">"
478 . $value . '</a>';
49db257d 479 if ($align['left'] == 'right') {
480 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
481 }
482 echo $sText."</td>\n";
483 break;
484 case SQM_COL_SIZE:
485 case SQM_COL_FLAGS:
3d621333 486 $sText = " <td class=\"col_flags\" $javascript_auto_click>"
487 . "$value</td>\n";
49db257d 488 echo $sText;
489 break;
490 case SQM_COL_INT_DATE:
491 case SQM_COL_DATE:
3d621333 492 $sText = " <td class=\"col_date\" $javascript_auto_click>"
493 . $value. "</td>\n";
49db257d 494 echo $sText;
495 break;
496 default:
e3812cb2 497 $sText = " <td class=\"col_text\" $javascript_auto_click";
49db257d 498 if ($link) {
499 $sText .= "><a href=\"$link\"";
500 if ($target) { $sText .= " target=\"$target\"";}
501 if ($title) { $sText .= " title=\"$title\"" ;}
502 $sText .= ">";
503 } else {
504 if ($title) {$sText .= " title=\"$title\"";}
505 $sText .= ">";
506 }
507 $sText .= $value;
508 if ($link) { $sText .= '</a>';}
509 echo $sText."</td>\n";
510 break;
511 }
512 }
3d621333 513
514 echo '</tr>';
e3812cb2 515 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
49db257d 516 ++$i;
517
518/*
519 * End displaying row part
520 */
521 }
522
523?>
524<!-- Message headers end -->
525 </table>
526 </td>
527 </tr>
528 </table>
529 </td>
530 </tr>
e3812cb2 531 <tr><td class="spacer"></td></tr>
49db257d 532 <tr>
533 <td>
e3812cb2 534 <table class="table_standard" cellspacing="0">
49db257d 535 <tr>
536 <td>
e3812cb2 537 <table class="table_empty" cellspacing="0">
49db257d 538 <tr>
0399a40b 539 <td class="links_paginator"><?php
540 /**
541 * The following line gets the output from a separate
542 * template altogether (called "paginator.tpl").
543 * $this is the Template class object.
544 */
545 $paginator_str = $this->fetch('paginator.tpl');
546 echo $paginator_str;
00d0bdda 547 if (!empty($plugin_output['mailbox_paginator_after'])) echo $plugin_output['mailbox_paginator_after'];
0399a40b 548 ?></td>
e3812cb2 549 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
49db257d 550 </tr>
551 </table>
552 </td>
553 </tr>
554 </table>
555 </td>
556 </tr>
557 <tr>
0ab04626 558 <td align="right">
3d621333 559<?php if (!empty($plugin_output['mailbox_index_after'])) echo $plugin_output['mailbox_index_after']; ?>
49db257d 560 </td>
561 </tr>
562 </table>
cd0a9317 563</form>
e3812cb2 564</div>
e6e2e7fd 565
566<?php if (!$hide_sm_attributions): ?>
aff09f80 567<p class="sqm_squirrelcopyright">&copy; <?php echo SM_COPYRIGHT ?> The SquirrelMail Project Team - <a href="about.php">About SquirrelMail</a></p>
e6e2e7fd 568<?php endif; ?>