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