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