Update for new location of global template utilities. Note that templates/util_globa...
[squirrelmail.git] / templates / default / message_list.tpl
1 <?php
2
3 /**
4 * message_list.tpl
5 *
6 * Template for viewing a messages list
7 *
8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 * @subpackage templates
13 */
14
15 /** add required includes */
16 include_once(SM_PATH . 'templates/util_message_list.php');
17
18 /* retrieve the template vars */
19 extract($t);
20
21 //FIXME: no hooks in templates!
22 global $null;
23 do_hook('mailbox_index_before', $null);
24
25 /**
26 * Calculate string "Viewing message x to y (z total)"
27 */
28 $msg_cnt_str = '';
29 if ($pageOffset < $end_msg) {
30 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
31 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
32 } else if ($pageOffset == $end_msg) {
33 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
34 }
35
36
37
38 if (!($sort & SQSORT_THREAD) && $enablesort) {
39 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
40 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
41 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
42 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
43 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
44 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
45 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
46 } else {
47 $aSortSupported = array();
48 }
49
50 // figure out which columns should serve as labels for checkbox:
51 // we try to grab the two columns before and after the checkbox,
52 // except the subject column, since it is the link that opens
53 // the message view
54 //
55 // if $javascript_on is set, then the highlighting code takes
56 // care of this; just skip it
57 //
58 $show_label_columns = array();
59 $index_order_part = array();
60 if (!($javascript_on && $fancy_index_highlite)) {
61 $get_next_two = 0;
62 $last_order_part = 0;
63 $last_last_order_part = 0;
64 foreach ($aOrder as $index_order_part) {
65 if ($index_order_part == SQM_COL_CHECK) {
66 $get_next_two = 1;
67 if ($last_last_order_part != SQM_COL_SUBJ)
68 $show_label_columns[] = $last_last_order_part;
69 if ($last_order_part != SQM_COL_SUBJ)
70 $show_label_columns[] = $last_order_part;
71
72 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
73 $show_label_columns[] = $index_order_part;
74 $get_next_two++;
75 }
76 $last_last_order_part = $last_order_part;
77 $last_order_part = $index_order_part;
78 }
79 }
80
81 /**
82 * All icon functionality is now handled through $icon_theme_path.
83 * $icon_theme_path will contain the path to the user-selected theme. If it is
84 * NULL, the user and/or admin have turned off icons.
85 */
86
87 // set this to an empty string to turn off extra
88 // highlighting of checked rows
89 //
90 //$clickedColor = '';
91 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
92
93 ?>
94 <div id="message_list">
95 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
96 <table class="table_empty" cellspacing="0">
97 <tr>
98 <td>
99 <table class="table_standard" cellspacing="0">
100 <tr>
101 <td>
102 <table class="table_empty" cellspacing="0">
103 <tr>
104 <td class="links_paginator">
105 <!-- paginator and thread link string -->
106 <?php
107 /**
108 * because the template is included in the display function we refer to $oTemplate with $this
109 */
110 $paginator_str = $this->fetch('paginator.tpl');
111 echo $paginator_str . $thread_link_str ."\n"; ?>
112 <!-- end paginator and thread link string -->
113 </td>
114 <!-- message count string -->
115 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
116 <!-- end message count string -->
117 </tr>
118 </table>
119 </td>
120 </tr>
121 <?php
122 if (count($aFormElements)) {
123 ?>
124 <!-- start message list form control -->
125 <tr class="message_list_controls">
126 <td>
127 <table class="table_empty" cellspacing="0">
128 <tr>
129 <td class="message_control_buttons">
130
131 <?php
132 foreach ($aFormElements as $key => $value) {
133 switch ($value[1]) {
134 case 'submit':
135 if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
136 ?>
137 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />&nbsp;
138 <?php
139 }
140 break;
141 case 'checkbox':
142 if ($key != 'bypass_trash') {
143 ?>
144 <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>&nbsp;
145 <?php
146 }
147 break;
148 case 'hidden':
149 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
150 break;
151 default: break;
152 }
153 }
154 ?>
155 </td>
156 <td class="message_control_delete">
157
158
159 <?php
160 if (isset($aFormElements['delete'])) {
161 ?>
162 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />&nbsp;
163 <?php
164 if (isset($aFormElements['bypass_trash'])) {
165 ?>
166 <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>&nbsp;
167 <?php
168 }
169 if (isset($aFormElements['undeleteButton'])) {
170 ?>
171 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />&nbsp;
172 <?php
173 }
174 ?>
175 </td>
176 <?php
177 } // if (isset($aFormElements['delete']))
178 if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
179 ?>
180 <td class="message_control_move">
181 <select name="targetMailbox">
182 <?php echo $aFormElements['targetMailbox'][0];?>
183 </select>
184 <?php if (isset($aFormElements['moveButton'])) { ?>
185 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
186 <?php }
187 if (isset($aFormElements['copyButton'])) { ?>
188 <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
189 <?php } ?>
190 </td>
191
192 <?php
193 } // if (isset($aFormElements['move']))
194 ?>
195 </tr>
196 </table>
197 </td>
198 </tr>
199 <!-- end message list form control -->
200 <?php
201 } // if (count($aFormElements))
202 ?>
203 </table>
204 <?php
205 //FIXME: no hooks in templates!
206 do_hook('mailbox_form_before', $null);
207 ?>
208 </td>
209 </tr>
210 <tr><td class="spacer"></td></tr>
211 <tr>
212 <td>
213 <table class="table_messageListWrapper" cellspacing="0">
214 <tr>
215 <td>
216 <table class="table_messageList" cellspacing="0">
217 <!-- table header start -->
218 <?php
219 /*
220 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
221 * rendering this table if we use THEAD and TH tags. No other browser or platform has
222 * this issue. We will use TR/TD w/ another CSS class to work around this.
223 */
224 ?>
225 <tr class="headerRow">
226 <?php
227 $aWidth = calcMessageListColumnWidth($aOrder);
228 foreach($aOrder as $iCol) {
229 ?>
230 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
231 <?php
232 switch ($iCol) {
233 case SQM_COL_CHECK:
234 if ($javascript_on) {
235 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
236 } else {
237 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;checkall=";
238 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
239 $link .= ($checkall) ? '0' : '1';
240 } else {
241 $link .= '1';
242 }
243 echo "<a href=\"$link\">"._("All").'</a>';
244 }
245 break;
246 case SQM_COL_FROM: echo _("From")."\n"; break;
247 case SQM_COL_DATE: echo _("Date")."\n"; break;
248 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
249 case SQM_COL_FLAGS:
250 echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
251 break;
252 case SQM_COL_SIZE: echo _("Size")."\n"; break;
253 case SQM_COL_PRIO:
254 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
255 break;
256 case SQM_COL_ATTACHMENT:
257 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
258 break;
259 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
260 case SQM_COL_TO: echo _("To")."\n"; break;
261 case SQM_COL_CC: echo _("Cc")."\n"; break;
262 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
263 default: break;
264 }
265 // add the sort buttons
266 if (isset($aSortSupported[$iCol])) {
267 if ($sort == $aSortSupported[$iCol][0]) {
268 $newsort = $aSortSupported[$iCol][1];
269 $img = 'up_pointer.png';
270 $text_icon = '&#8679;'; // U+21E7 UPWARDS WHITE ARROW
271 } else if ($sort == $aSortSupported[$iCol][1]) {
272 $newsort = 0;
273 $img = 'down_pointer.png';
274 $text_icon = '&#8681;'; // U+21E9 DOWNWARDS WHITE ARROW
275 } else {
276 $newsort = $aSortSupported[$iCol][0];
277 $img = 'sort_none.png';
278 $text_icon = '&#9723;'; // U+25FB WHITE MEDIUM SQUARE
279 }
280 /* Now that we have everything figured out, show the actual button. */
281 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\" style=\"text-decoration:none\">" .
282 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
283 '</a>';
284 }
285 ?>
286 </td>
287 <?php
288 }
289 ?>
290 </tr>
291 <!-- end table header -->
292
293 <!-- Message headers start -->
294 <?php
295 $i = 0;
296 $iColCnt = count($aOrder);
297 $sLine = '';
298
299 // this stuff does the auto row highlighting on mouseover
300 //
301 if ($javascript_on && $fancy_index_highlite) {
302
303 $mouseoverColor = $color[5];
304
305 // set this to an empty string to turn off extra
306 // highlighting of checked rows
307 //
308 //$clickedColor = '';
309 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
310
311 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
312 } else {
313 $checkbox_javascript = '';
314 }
315 foreach ($aMessages as $iUid => $aMsg) {
316 echo $sLine;
317
318 /**
319 * Display message header row in messages list
320 *
321 */
322
323 $aColumns = $aMsg['columns'];
324
325
326 /**
327 * Check the flags and set a class var.
328 */
329 if (isset($aColumns[SQM_COL_FLAGS])) {
330 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
331 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
332
333 /* add the flag string to the value index */
334 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
335 }
336 /**
337 * Check the priority column
338 */
339 if (isset($aColumns[SQM_COL_PRIO])) {
340 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
341 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
342 }
343
344 /**
345 * Check the attachment column
346 */
347 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
348 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
349 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
350 }
351
352 $class = 'even';
353 /**
354 * If alternating row colors is set, adapt the CSS class
355 */
356 if (isset($alt_index_colors) && $alt_index_colors) {
357 if (!($i % 2)) {
358 $class = 'odd';
359 }
360
361 }
362 if (isset($aMsg['row']['color']))
363 {
364 $bgcolor = $aMsg['row']['color'];
365 $class = 'misc'.$i;
366 }
367 else $bgcolor = '';
368
369 $row_extra = '';
370
371 // this stuff does the auto row highlighting on mouseover
372 //
373 if ($javascript_on && $fancy_index_highlite) {
374 $row_extra .= ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $class . '\', \'mouse_over\', \'clicked\');"';
375 }
376 // this does the auto-checking of the checkbox no matter
377 // where on the row you click
378 //
379 $javascript_auto_click = '';
380 if ($javascript_on && $fancy_index_highlite) {
381 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
382 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
383 }
384
385 /*
386 * Message Highlighting requires a unique CSS class declaration for proper
387 * mouseover functionality. There is no harm in doing this when the mouseover
388 * functionality is disabled
389 */
390 if ($class != 'even' && $class != 'odd')
391 {
392 ?>
393 <style type="text/css">
394 <!--
395 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
396 -->
397 </style>
398 <?php
399 }
400 ?>
401 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
402 <?php
403 // flag style mumbo jumbo
404 $sPre = $sEnd = '';
405 if (isset($aColumns[SQM_COL_FLAGS])) {
406 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
407 $sPre = '<span class="unread">'; $sEnd = '</span>';
408 }
409 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
410 $sPre = '<span class="deleted">' . $sPre;
411 $sEnd .= '</span>';
412 } else {
413 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
414 $sPre = '<span class="flagged">' . $sPre;
415 $sEnd .= '</span>';
416 }
417 }
418 }
419 /**
420 * Because the order of the columns and which columns to show is a user preference
421 * we have to do some php coding to display the columns in the right order
422 */
423 foreach ($aOrder as $iCol) {
424 if (in_array($iCol, $show_label_columns)) {
425 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
426 $sLabelEnd = '</label>';
427 } else {
428 $sLabelStart = '';
429 $sLabelEnd = '';
430 }
431 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
432 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
433 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
434 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
435 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
436 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
437 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
438 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
439 if ($iCol !== SQM_COL_CHECK) {
440 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
441 }
442
443
444 switch ($iCol) {
445 case SQM_COL_CHECK:
446 if ($javascript_on) {
447 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
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 } else {
451 echo '<td class="col_check">';
452 $checked = ($checkall) ? " checked=checked " : " ";
453 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
454 }
455 break;
456 case SQM_COL_SUBJ:
457 $indent = $aCol['indent'];
458 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
459 if ($align['left'] == 'left') {
460 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
461 }
462 $sText .= "<a href=\"$link\"";
463 if ($target) { $sText .= " target=\"$target\""; }
464 if ($title) { $sText .= " title=\"$title\""; }
465 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
466 if ($link_extra) { $sText .= " $link_extra"; }
467 if ($javascript_on && $fancy_index_highlite) {
468 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
469 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
470 $clickedColor .'\');"';
471 }
472 $sText .= ">";
473 $sText .= $value . '</a>';
474 if ($align['left'] == 'right') {
475 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
476 }
477 echo $sText."</td>\n";
478 break;
479 case SQM_COL_SIZE:
480 case SQM_COL_FLAGS:
481 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
482 $sText .= "$value</td>\n";
483 echo $sText;
484 break;
485 case SQM_COL_INT_DATE:
486 case SQM_COL_DATE:
487 $sText = " <td class=\"col_date\" $javascript_auto_click>";
488 $sText .= $value. "</td>\n";
489 echo $sText;
490 break;
491 default:
492 $sText = " <td class=\"col_text\" $javascript_auto_click";
493 if ($link) {
494 $sText .= "><a href=\"$link\"";
495 if ($target) { $sText .= " target=\"$target\"";}
496 if ($title) { $sText .= " title=\"$title\"" ;}
497 $sText .= ">";
498 } else {
499 if ($title) {$sText .= " title=\"$title\"";}
500 $sText .= ">";
501 }
502 $sText .= $value;
503 if ($link) { $sText .= '</a>';}
504 echo $sText."</td>\n";
505 break;
506 }
507 }
508 ?>
509 </tr>
510 <?php
511 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
512 ++$i;
513
514 /*
515 * End displaying row part
516 */
517 }
518
519 ?>
520 <!-- Message headers end -->
521 </table>
522 </td>
523 </tr>
524 </table>
525 </td>
526 </tr>
527 <tr><td class="spacer"></td></tr>
528 <tr>
529 <td>
530 <table class="table_standard" cellspacing="0">
531 <tr>
532 <td>
533 <table class="table_empty" cellspacing="0">
534 <tr>
535 <td class="links_paginator"><?php echo $paginator_str; ?></td>
536 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
537 </tr>
538 </table>
539 </td>
540 </tr>
541 </table>
542 </td>
543 </tr>
544 <tr>
545 <td>
546 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>
547 </td>
548 </tr>
549 </table>
550 </form>
551 </div>