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