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