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