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