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