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