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