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