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