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