make sure that $aFlags is set. maybe is_array() is needed too.
[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
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)"),
29 '<b>'.$pageOffset.'</b>', '<b>'.$end_msg.'</b>', $iNumberOfMessages);
30} else if ($pageOffset == $end_msg) {
31 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$pageOffset.'</b>', $iNumberOfMessages);
32}
33
34
35
36if (!($sort & SQSORT_THREAD) && $enablesort) {
37 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
38 SQM_COL_DATE => array(SQSORT_DATE_ASC , SQSORT_DATE_DESC),
39 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_ASC, SQSORT_INT_DATE_DESC),
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));
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
79// set this to an empty string to turn off extra
80// highlighting of checked rows
81//
82//$clickedColor = '';
83if (!empty($color[16]))
84 $clickedColor = $color[16];
85else
86 $clickedColor = $color[2];
87
88
89?>
90<form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
91<table border="0" width="100%" cellpadding="0" cellspacing="0">
92 <tr>
93 <td>
94 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
95 <tr>
96 <td>
97 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
98 <tr>
99 <td align="<?php echo $align['left']; ?>">
100 <small>
101<!-- paginator and thread link string -->
102 <?php
103 /**
104 * because the template is included in the display function we refer to $oTemplate with $this
105 */
106 $paginator_str = $this->fetch('paginator.tpl');
107 echo $paginator_str . $thread_link_str ."\n"; ?>
108<!-- end paginator and thread link string -->
109 </small>
110 </td>
111<!-- message count string -->
112 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
113<!-- end message count string -->
114 </tr>
115 </table>
116 </td>
117 </tr>
118<?php
119 if (count($aFormElements)) {
120?>
121<!-- start message list form control -->
122 <tr bgcolor="<?php echo $color[0]; ?>">
123 <td>
124 <table border="0" width="100%" cellpadding="1" cellspacing="0">
125 <tr>
126 <td align="<?php echo $align['left']; ?>">
127 <small>
128
129<?php
130 foreach ($aFormElements as $key => $value) {
131 switch ($value[1]) {
132 case 'submit':
133 if ($key != 'moveButton') { // add move in a different table cell
134?>
135 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px" />&nbsp;
136<?php
137 }
138 break;
139 case 'checkbox':
140?>
141 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
142<?php
143 break;
144 case 'hidden':
145 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
146 break;
147 default: break;
148 }
149 }
150?>
151 </small>
152 </td>
153 <td align="<?php echo $align['right']; ?>">
154
155
156<?php
157 if (isset($aFormElements['moveButton'])) {
158?> <small>&nbsp;
159 <tt>
160 <select name="targetMailbox">
161 <?php echo $aFormElements['targetMailbox'][0];?>
162 </select>
163 </tt>
164 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px" />
165 </small>
166<?php
167 } // if (isset($aFormElements['move']))
168?>
169 </td>
170 </tr>
171 </table>
172 </td>
173 </tr>
174<!-- end message list form control -->
175<?php
176 } // if (count($aFormElements))
177?>
178 </table>
179<?php
180 do_hook('mailbox_form_before');
181?>
182 </td>
183 </tr>
184 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
185 <tr>
186 <td>
187 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
188 <tr>
189 <td>
190 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
191 <tr>
192 <td>
193<!-- table header start -->
194 <tr>
195<?php
196 $aWidth = calcMessageListColumnWidth($aOrder);
197 foreach($aOrder as $iCol) {
198
199?>
d72dedd2 200 <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%" style="white-space:nowrap">
49db257d 201 <b>
202<?php
203 switch ($iCol) {
204 case SQM_COL_CHECK:
205 if ($javascript_on) {
95e203e9 206 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.",'".$clickedColor.'\');" />';
49db257d 207 } else {
208 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;&amp;checkall=";
209 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
210 $link .= ($checkall) ? '0' : '1';
211 } else {
212 $link .= '1';
213 }
214 echo "<a href=\"$link\">"._("All").'</a>';
215 }
216 break;
217 case SQM_COL_FROM: echo _("From"); break;
218 case SQM_COL_DATE: echo _("Date"); break;
219 case SQM_COL_SUBJ: echo _("Subject"); break;
eac8f942 220 case SQM_COL_FLAGS: echo '&nbsp;'; break;
49db257d 221 case SQM_COL_SIZE: echo _("Size"); break;
222 case SQM_COL_PRIO: echo '!'; break;
223 case SQM_COL_ATTACHMENT: echo '+'; break;
224 case SQM_COL_INT_DATE: echo _("Received"); break;
225 case SQM_COL_TO: echo _("To"); break;
226 case SQM_COL_CC: echo _("Cc"); break;
227 case SQM_COL_BCC: echo _("Bcc"); break;
228 default: break;
229 }
230 // add the sort buttons
231 if (isset($aSortSupported[$iCol])) {
232 if ($sort == $aSortSupported[$iCol][0]) {
233 $newsort = $aSortSupported[$iCol][1];
234 $img = 'up_pointer.png';
235 } else if ($sort == $aSortSupported[$iCol][1]) {
236 $newsort = 0;
237 $img = 'down_pointer.png';
238 } else {
239 $newsort = $aSortSupported[$iCol][0];
240 $img = 'sort_none.png';
241 }
242 /* Now that we have everything figured out, show the actual button. */
243 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">";
244 echo '<img src="../images/' . $img
245 . '" border="0" width="12" height="10" alt="sort" title="'
246 . _("Click here to change the sorting of the message list") .'" /></a>';
247 }
248?>
249 </b>
250 </td>
251<?php
252 }
253?>
254 </tr>
255
256<!-- Message headers start -->
257<?php
258 $i = 0;
259 $iColCnt = count($aOrder);
260 $sLine = '';
261
262 // this stuff does the auto row highlighting on mouseover
263 //
264 if ($javascript_on && $fancy_index_highlite) {
265
266 $mouseoverColor = $color[5];
267
268 // set this to an empty string to turn off extra
269 // highlighting of checked rows
270 //
271 //$clickedColor = '';
272 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
799ee2d5 273
274 $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
275 } else {
276 $checkbox_javascript = '';
49db257d 277 }
278 foreach ($aMessages as $iUid => $aMsg) {
279 echo $sLine;
280
281/**
282* Display message header row in messages list
283*
284*/
285
286 $aColumns = $aMsg['columns'];
287
288 /**
289 * Check usage of images for attachments, flags and priority
49db257d 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 = '';
f2e2aa7f 394 // make sure that flags column is used by end user
395 if (isset($aFlags)) {
396 if (!in_array('seen',$aFlags)) {
397 $sPre = '<b>'; $sEnd = '</b>';
398 }
399 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
400 $sPre = "<font color=\"$color[9]\">" . $sPre;
49db257d 401 $sEnd .= '</font>';
f2e2aa7f 402 } else {
403 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
404 $sPre = "<font color=\"$color[2]\">" . $sPre;
405 $sEnd .= '</font>';
406 }
49db257d 407 }
408 }
409 /**
410 * Because the order of the columns and which columns to show is a user preference
411 * we have to do some php coding to display the columns in the right order
412 */
413 foreach ($aOrder as $iCol) {
6547ab43 414 if (in_array($iCol, $show_label_columns)) {
49db257d 415 $sLabelStart = '<label for="msg[' . $i . ']">';
416 $sLabelEnd = '</label>';
417 } else {
418 $sLabelStart = '';
419 $sLabelEnd = '';
420 }
2bca4fda 421 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
49db257d 422 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
423 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
424 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
425 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
426 if ($iCol !== SQM_COL_CHECK) {
427 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
428 }
429
430
431 switch ($iCol) {
432 case SQM_COL_CHECK:
d72dedd2 433 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space:nowrap">' ?>
49db257d 434 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
435 <?php
436 break;
437 case SQM_COL_SUBJ:
438 $indent = $aCol['indent'];
439 $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
440 if ($align['left'] == 'left') {
441 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
442 }
443 $sText .= "<a href=\"$link\"";
444 if ($target) { $sText .= " target=\"$target\"";}
445 if ($title) { $sText .= " title=\"$title\"" ;}
446 if ($javascript_on && $fancy_index_highlite) {
447 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
448 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
449 $clickedColor .'\');"';
450 }
451 $sText .= ">";
452 $sText .= $value . '</a>';
453 if ($align['left'] == 'right') {
454 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
455 }
456 echo $sText."</td>\n";
457 break;
458 case SQM_COL_SIZE:
459 case SQM_COL_FLAGS:
2d64c3dc 460 $sText = " <td class=\"col_flags\" align=\"$align[right]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
49db257d 461 $sText .= "<small>$value</small></td>\n";
462 echo $sText;
463 break;
464 case SQM_COL_INT_DATE:
465 case SQM_COL_DATE:
2d64c3dc 466 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space:nowrap\">";
49db257d 467 $sText .= $value. "</td>\n";
468 echo $sText;
469 break;
470 default:
4f5e5e94 471 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space:nowrap\" $javascript_auto_click bgcolor=\"$bgcolor\"";
49db257d 472 if ($link) {
473 $sText .= "><a href=\"$link\"";
474 if ($target) { $sText .= " target=\"$target\"";}
475 if ($title) { $sText .= " title=\"$title\"" ;}
476 $sText .= ">";
477 } else {
478 if ($title) {$sText .= " title=\"$title\"";}
479 $sText .= ">";
480 }
481 $sText .= $value;
482 if ($link) { $sText .= '</a>';}
483 echo $sText."</td>\n";
484 break;
485 }
486 }
487?>
488 </tr>
489<?php
490 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
491 ++$i;
492
493/*
494 * End displaying row part
495 */
496 }
497
498?>
499<!-- Message headers end -->
500 </table>
501 </td>
502 </tr>
503 </table>
504 </td>
505 </tr>
506 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
507 <tr>
508 <td>
509 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
510 <tr>
511 <td>
512 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
513 <tr>
514 <td align="left"><small><?php echo $paginator_str; ?></small></td>
515 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
516 </tr>
517 </table>
518 </td>
519 </tr>
520 </table>
521 </td>
522 </tr>
523 <tr>
524 <td>
525 <?php do_hook('mailbox_index_after');?>
526 </td>
527 </tr>
528 </table>
cb220c9f 529</form>