Adding more index.php files
[squirrelmail.git] / templates / default / message_list.tpl
CommitLineData
49db257d 1<?php
2
3/**
4 * message_list.tpl
5 *
f2e2aa7f 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
49db257d 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Template for viewing a messages list
10 *
11 * @version $Id$
12 * @package squirrelmail
57d06b39 13 * @subpackage templates
49db257d 14 */
15
f2e2aa7f 16/** add required includes */
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)"),
30 '<b>'.$pageOffset.'</b>', '<b>'.$end_msg.'</b>', $iNumberOfMessages);
31} else if ($pageOffset == $end_msg) {
32 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$pageOffset.'</b>', $iNumberOfMessages);
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/**
81 * Check usage of images for attachments, flags and priority
82 */
83$bIcons = ($use_icons && $icon_theme) ? true : false;
84
85/**
86 * Location of icon images
87 */
88if ($bIcons) {
89 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
90}
91
49db257d 92// set this to an empty string to turn off extra
93// highlighting of checked rows
94//
95//$clickedColor = '';
583db309 96$clickedColor = (empty($color[16])) ? $color[2] : $color[16];
49db257d 97
98?>
99<form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
100<table border="0" width="100%" cellpadding="0" cellspacing="0">
101 <tr>
102 <td>
a69c8eb2 103 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
49db257d 104 <tr>
105 <td>
106 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
107 <tr>
108 <td align="<?php echo $align['left']; ?>">
109 <small>
110<!-- paginator and thread link string -->
111 <?php
112 /**
113 * because the template is included in the display function we refer to $oTemplate with $this
114 */
115 $paginator_str = $this->fetch('paginator.tpl');
116 echo $paginator_str . $thread_link_str ."\n"; ?>
117<!-- end paginator and thread link string -->
118 </small>
119 </td>
120<!-- message count string -->
121 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
122<!-- end message count string -->
123 </tr>
124 </table>
125 </td>
126 </tr>
127<?php
128 if (count($aFormElements)) {
129?>
130<!-- start message list form control -->
131 <tr bgcolor="<?php echo $color[0]; ?>">
132 <td>
133 <table border="0" width="100%" cellpadding="1" cellspacing="0">
134 <tr>
135 <td align="<?php echo $align['left']; ?>">
136 <small>
137
138<?php
139 foreach ($aFormElements as $key => $value) {
140 switch ($value[1]) {
141 case 'submit':
a5d40e74 142 if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
49db257d 143?>
a69c8eb2 144 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
49db257d 145<?php
a5d40e74 146 }
49db257d 147 break;
148 case 'checkbox':
a5d40e74 149 if ($key != 'bypass_trash') {
49db257d 150?>
151 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
152<?php
a5d40e74 153 }
49db257d 154 break;
155 case 'hidden':
156 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
157 break;
158 default: break;
159 }
160 }
161?>
162 </small>
163 </td>
164 <td align="<?php echo $align['right']; ?>">
165
166
167<?php
a5d40e74 168 if (isset($aFormElements['delete'])) {
169?>
170 <td align="<?php echo $align['right']; ?>">
171 <small>
172 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
173 <?php
174 if (isset($aFormElements['bypass_trash'])) {
175?>
176 <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>&nbsp;
177<?php
178 }
179 if (isset($aFormElements['undeleteButton'])) {
180?>
181 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
182<?php
183 }
184?>
185 </small>
186 </td>
187<?php
188 } // if (isset($aFormElements['delete']))
49db257d 189 if (isset($aFormElements['moveButton'])) {
a5d40e74 190?>
191 <td align="<?php echo $align['right']; ?>">
192 <small>&nbsp;
49db257d 193 <tt>
194 <select name="targetMailbox">
195 <?php echo $aFormElements['targetMailbox'][0];?>
196 </select>
197 </tt>
a69c8eb2 198 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px;" />
49db257d 199 </small>
a5d40e74 200 </td>
201
49db257d 202<?php
203 } // if (isset($aFormElements['move']))
204?>
49db257d 205 </tr>
206 </table>
207 </td>
208 </tr>
209<!-- end message list form control -->
210<?php
211 } // if (count($aFormElements))
212?>
213 </table>
214<?php
215 do_hook('mailbox_form_before');
216?>
217 </td>
218 </tr>
219 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
220 <tr>
221 <td>
222 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
223 <tr>
224 <td>
225 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
226 <tr>
227 <td>
228<!-- table header start -->
229 <tr>
230<?php
231 $aWidth = calcMessageListColumnWidth($aOrder);
232 foreach($aOrder as $iCol) {
233
234?>
a69c8eb2 235 <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%" style="white-space: nowrap;">
49db257d 236 <b>
237<?php
238 switch ($iCol) {
239 case SQM_COL_CHECK:
240 if ($javascript_on) {
95e203e9 241 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.",'".$clickedColor.'\');" />';
49db257d 242 } else {
243 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;&amp;checkall=";
244 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
245 $link .= ($checkall) ? '0' : '1';
246 } else {
247 $link .= '1';
248 }
249 echo "<a href=\"$link\">"._("All").'</a>';
250 }
251 break;
252 case SQM_COL_FROM: echo _("From"); break;
253 case SQM_COL_DATE: echo _("Date"); break;
254 case SQM_COL_SUBJ: echo _("Subject"); break;
583db309 255 case SQM_COL_FLAGS:
256 if ($bIcons) {
257 echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />';
258 } else {
259 echo '&nbsp;';
260 }
261 break;
49db257d 262 case SQM_COL_SIZE: echo _("Size"); break;
583db309 263 case SQM_COL_PRIO:
264 if ($bIcons) {
069a91d3 265 echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />';
583db309 266 } else {
267 echo '!';
268 }
269 break;
270 case SQM_COL_ATTACHMENT:
271 if ($bIcons) {
069a91d3 272 echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>';
583db309 273 } else {
274 echo '+';
275 }
276 break;
49db257d 277 case SQM_COL_INT_DATE: echo _("Received"); break;
278 case SQM_COL_TO: echo _("To"); break;
279 case SQM_COL_CC: echo _("Cc"); break;
280 case SQM_COL_BCC: echo _("Bcc"); break;
281 default: break;
282 }
283 // add the sort buttons
284 if (isset($aSortSupported[$iCol])) {
285 if ($sort == $aSortSupported[$iCol][0]) {
286 $newsort = $aSortSupported[$iCol][1];
287 $img = 'up_pointer.png';
288 } else if ($sort == $aSortSupported[$iCol][1]) {
289 $newsort = 0;
290 $img = 'down_pointer.png';
291 } else {
292 $newsort = $aSortSupported[$iCol][0];
293 $img = 'sort_none.png';
294 }
295 /* Now that we have everything figured out, show the actual button. */
296 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">";
297 echo '<img src="../images/' . $img
298 . '" border="0" width="12" height="10" alt="sort" title="'
299 . _("Click here to change the sorting of the message list") .'" /></a>';
300 }
301?>
302 </b>
303 </td>
304<?php
305 }
306?>
307 </tr>
308
309<!-- Message headers start -->
310<?php
311 $i = 0;
312 $iColCnt = count($aOrder);
313 $sLine = '';
314
315 // this stuff does the auto row highlighting on mouseover
316 //
317 if ($javascript_on && $fancy_index_highlite) {
318
319 $mouseoverColor = $color[5];
320
321 // set this to an empty string to turn off extra
322 // highlighting of checked rows
323 //
324 //$clickedColor = '';
325 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
799ee2d5 326
327 $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
328 } else {
329 $checkbox_javascript = '';
49db257d 330 }
331 foreach ($aMessages as $iUid => $aMsg) {
332 echo $sLine;
333
334/**
335* Display message header row in messages list
336*
337*/
338
339 $aColumns = $aMsg['columns'];
340
49db257d 341
342 /**
343 * Check the flags and set a class var.
344 */
345 if (isset($aColumns[SQM_COL_FLAGS])) {
346 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
347 if ($bIcons) {
348
349 $sFlags = getFlagIcon($aFlags, $sImageLocation);
350 } else {
351 $sFlags = getFlagText($aFlags);
352 }
353 /* add the flag string to the value index */
354 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
355 }
356 /**
357 * Check the priority column
358 */
359 if (isset($aColumns[SQM_COL_PRIO])) {
360 /* FIX ME, we should use separate templates for icons */
361 if ($bIcons) {
362 $sValue = '<img src="' . $sImageLocation;
363 switch ($aColumns[SQM_COL_PRIO]['value']) {
364 case 1:
365 case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
366 case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
367 default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
368 }
369 } else {
370 $sValue = '';
371 switch ($aColumns[SQM_COL_PRIO]['value']) {
372 case 1:
373 case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break;
a5d40e74 374 // use downwards arrow for low priority emails
57d06b39 375 case 5: $sValue .= "<font color=\"$color[8]\">&#8595;</font>"; break;
49db257d 376 default: break;
377 }
378 }
379 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
380 }
381
382 /**
383 * Check the attachment column
384 */
385 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
386 /* FIX ME, we should use separate templates for icons */
387 if ($bIcons) {
388 $sValue = '<img src="' . $sImageLocation;
389 $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
390 ? 'attach.png" border="0" height="10" width="6" alt=""/>'
391 : 'transparent.png" border="0" width="6" alt="" />';
392 } else {
393 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
394 }
395 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
396 }
397
398
399 $bgcolor = $color[4];
400
401 /**
402 * If alternating row colors is set, adapt the bgcolor
403 */
404 if (isset($alt_index_colors) && $alt_index_colors) {
405 if (!($i % 2)) {
406 if (!isset($color[12])) {
407 $color[12] = '#EAEAEA';
408 }
409 $bgcolor = $color[12];
410 }
411
412 }
413 $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
414 $class = 'msg_row';
415
416 $row_extra = '';
417
418 // this stuff does the auto row highlighting on mouseover
419 //
420 if ($javascript_on && $fancy_index_highlite) {
421 $row_extra .= ' onmouseover="rowOver(\''.$form_id . "_msg$i','". $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
422 }
423 // this does the auto-checking of the checkbox no matter
424 // where on the row you click
425 //
426 $javascript_auto_click = '';
427 if ($javascript_on && $fancy_index_highlite) {
428 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
429 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
430 }
431
432?>
433<tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
434<?php
435 // flag style mumbo jumbo
436 $sPre = $sEnd = '';
bf9e5efb 437 if (isset($aColumns[SQM_COL_FLAGS])) {
f2e2aa7f 438 if (!in_array('seen',$aFlags)) {
439 $sPre = '<b>'; $sEnd = '</b>';
440 }
441 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
442 $sPre = "<font color=\"$color[9]\">" . $sPre;
49db257d 443 $sEnd .= '</font>';
f2e2aa7f 444 } else {
445 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
446 $sPre = "<font color=\"$color[2]\">" . $sPre;
447 $sEnd .= '</font>';
448 }
49db257d 449 }
450 }
451 /**
452 * Because the order of the columns and which columns to show is a user preference
453 * we have to do some php coding to display the columns in the right order
454 */
455 foreach ($aOrder as $iCol) {
6547ab43 456 if (in_array($iCol, $show_label_columns)) {
6d34ad62 457 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
49db257d 458 $sLabelEnd = '</label>';
459 } else {
460 $sLabelStart = '';
461 $sLabelEnd = '';
462 }
2bca4fda 463 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
49db257d 464 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
465 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
466 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
467 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
468 if ($iCol !== SQM_COL_CHECK) {
469 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
470 }
471
472
473 switch ($iCol) {
474 case SQM_COL_CHECK:
a69c8eb2 475 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space: nowrap;">' ?>
49db257d 476 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
477 <?php
478 break;
479 case SQM_COL_SUBJ:
480 $indent = $aCol['indent'];
481 $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
482 if ($align['left'] == 'left') {
483 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
484 }
485 $sText .= "<a href=\"$link\"";
486 if ($target) { $sText .= " target=\"$target\"";}
487 if ($title) { $sText .= " title=\"$title\"" ;}
488 if ($javascript_on && $fancy_index_highlite) {
489 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
490 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
491 $clickedColor .'\');"';
492 }
493 $sText .= ">";
494 $sText .= $value . '</a>';
495 if ($align['left'] == 'right') {
496 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
497 }
498 echo $sText."</td>\n";
499 break;
500 case SQM_COL_SIZE:
501 case SQM_COL_FLAGS:
583db309 502 $sText = " <td class=\"col_flags\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
49db257d 503 $sText .= "<small>$value</small></td>\n";
504 echo $sText;
505 break;
506 case SQM_COL_INT_DATE:
507 case SQM_COL_DATE:
a69c8eb2 508 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
49db257d 509 $sText .= $value. "</td>\n";
510 echo $sText;
511 break;
512 default:
a69c8eb2 513 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space: nowrap;\" $javascript_auto_click bgcolor=\"$bgcolor\"";
49db257d 514 if ($link) {
515 $sText .= "><a href=\"$link\"";
516 if ($target) { $sText .= " target=\"$target\"";}
517 if ($title) { $sText .= " title=\"$title\"" ;}
518 $sText .= ">";
519 } else {
520 if ($title) {$sText .= " title=\"$title\"";}
521 $sText .= ">";
522 }
523 $sText .= $value;
524 if ($link) { $sText .= '</a>';}
525 echo $sText."</td>\n";
526 break;
527 }
528 }
529?>
530 </tr>
531<?php
532 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
533 ++$i;
534
535/*
536 * End displaying row part
537 */
538 }
539
540?>
541<!-- Message headers end -->
542 </table>
543 </td>
544 </tr>
545 </table>
546 </td>
547 </tr>
548 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
549 <tr>
550 <td>
a69c8eb2 551 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
49db257d 552 <tr>
553 <td>
554 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
555 <tr>
556 <td align="left"><small><?php echo $paginator_str; ?></small></td>
557 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
558 </tr>
559 </table>
560 </td>
561 </tr>
562 </table>
563 </td>
564 </tr>
565 <tr>
566 <td>
567 <?php do_hook('mailbox_index_after');?>
568 </td>
569 </tr>
570 </table>
cb220c9f 571</form>