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