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