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