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