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