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