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