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