Do it the right way
[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 * $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
60 * $aSortSupported
61 * $show_label_columns
62 * $compact_paginator
63 * $aErrors
64 *
65 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
66 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
67 * @version $Id$
68 * @package squirrelmail
69 * @subpackage templates
70 */
71
72
73 /** add required includes */
74 include_once(SM_PATH . 'functions/template/message_list_util.php');
75
76
77 /* retrieve the template vars */
78 extract($t);
79
80
81 if (!empty($plugin_output['mailbox_index_before'])) echo $plugin_output['mailbox_index_before'];
82
83
84 /**
85 * Calculate string "Viewing message x to y (z total)"
86 */
87 $msg_cnt_str = '';
88 if ($pageOffset < $end_msg) {
89 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
90 '<em>' . $pageOffset . '</em>',
91 '<em>' . $end_msg . '</em>',
92 $iNumberOfMessages);
93 } else if ($pageOffset == $end_msg) {
94 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"),
95 '<em>' . $pageOffset . '</em>',
96 $iNumberOfMessages);
97 }
98
99
100 /**
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.
104 */
105
106
107 // set this to an empty string to turn off extra
108 // highlighting of checked rows
109 //
110 //$clickedColor = '';
111 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
112
113
114 ?>
115 <div id="message_list">
116 <form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
117 <table class="table_empty" cellspacing="0">
118 <tr>
119 <td>
120 <table class="table_standard" cellspacing="0">
121 <tr>
122 <td>
123 <table class="table_empty" cellspacing="0">
124 <tr>
125 <td class="links_paginator">
126 <!-- paginator and thread link string -->
127 <?php
128 /**
129 * The following line gets the output from a separate
130 * template altogether (called "paginator.tpl").
131 * $this is the Template class object.
132 */
133 $paginator_str = $this->fetch('paginator.tpl');
134 echo $paginator_str . $thread_link_str ."\n"; ?>
135 <!-- end paginator and thread link string -->
136 </td>
137 <!-- message count string -->
138 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
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 -->
148 <tr class="message_list_controls">
149 <td>
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"; ?>
158 </td>
159 </tr>
160 <!-- end message list form control -->
161 <?php
162 } // if (count($aFormElements))
163 ?>
164 </table>
165 <?php if (!empty($plugin_output['mailbox_form_before'])) echo $plugin_output['mailbox_form_before']; ?>
166 </td>
167 </tr>
168 <tr><td class="spacer"></td></tr>
169 <tr>
170 <td>
171 <table class="table_messageListWrapper" cellspacing="0">
172 <tr>
173 <td>
174 <table class="table_messageList" cellspacing="0">
175 <!-- table header start -->
176 <?php
177 /*
178 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
179 * rendering this table if we use THEAD and TH tags. No other browser or platform has
180 * this issue. We will use TR/TD w/ another CSS class to work around this.
181 */
182 ?>
183
184 <tr class="headerRow">
185
186 <?php
187 $aWidth = calcMessageListColumnWidth($aOrder);
188 foreach($aOrder as $iCol) {
189 ?>
190
191 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
192
193 <?php
194 switch ($iCol) {
195 case SQM_COL_CHECK:
196 if ($javascript_on) {
197 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" />'."\n";
198 } else {
199 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;checkall=";
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;
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;
211 case SQM_COL_FLAGS:
212 echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
213 break;
214 case SQM_COL_SIZE: echo _("Size")."\n"; break;
215 case SQM_COL_PRIO:
216 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
217 break;
218 case SQM_COL_ATTACHMENT:
219 echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
220 break;
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;
225 default: break;
226 }
227 // add the sort buttons
228 if (isset($aSortSupported[$iCol])) {
229 if ($sort == $aSortSupported[$iCol][0]) {
230 $newsort = $aSortSupported[$iCol][1];
231 $img = 'up_pointer.png';
232 $text_icon = '&#8679;'; // U+21E7 UPWARDS WHITE ARROW
233 } else if ($sort == $aSortSupported[$iCol][1]) {
234 $newsort = 0;
235 $img = 'down_pointer.png';
236 $text_icon = '&#8681;'; // U+21E9 DOWNWARDS WHITE ARROW
237 } else {
238 $newsort = $aSortSupported[$iCol][0];
239 $img = 'sort_none.png';
240 $text_icon = '&#9723;'; // U+25FB WHITE MEDIUM SQUARE
241 }
242 /* Now that we have everything figured out, show the actual button. */
243 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\" style=\"text-decoration:none\">" .
244 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
245 '</a>';
246 }
247 ?>
248 </td>
249 <?php
250 }
251 ?>
252 </tr>
253 <!-- end table header -->
254
255 <!-- Message headers start -->
256 <?php
257
258 $i = 0;
259 $iColCnt = count($aOrder);
260 $sLine = '';
261
262
263 // this stuff does the auto row highlighting on mouseover
264 //
265 if ($javascript_on && $fancy_index_highlite) {
266 $mouseoverColor = $color[5];
267 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
268 // $clickedColor is defined at top of this file
269 } else {
270 $checkbox_javascript = '';
271 }
272
273
274 /**
275 * main message iteration loop
276 */
277 foreach ($aMessages as $iUid => $aMsg) {
278
279 echo $sLine;
280
281
282 /**
283 * Display message header row in messages list
284 *
285 */
286
287 $aColumns = $aMsg['columns'];
288
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'];
295 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
296
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])) {
304 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
305 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
306 }
307
308 /**
309 * Check the attachment column
310 */
311 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
312 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
313 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
314 }
315
316 $class = 'even';
317 /**
318 * If alternating row colors is set, adapt the CSS class
319 */
320 if (isset($alt_index_colors) && $alt_index_colors) {
321 if (!($i % 2)) {
322 $class = 'odd';
323 }
324
325 }
326 if (isset($aMsg['row']['color']))
327 {
328 $bgcolor = $aMsg['row']['color'];
329 $class = 'misc'.$i;
330 }
331 else $bgcolor = '';
332
333 $row_extra = '';
334
335 // this stuff does the auto row highlighting on mouseover
336 //
337 if ($javascript_on && $fancy_index_highlite) {
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\');"';
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
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 */
354 if ($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>
362 <?php
363 }
364 ?>
365 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
366 <?php
367 // flag style mumbo jumbo
368 $sPre = $sEnd = '';
369 if (isset($aColumns[SQM_COL_FLAGS])) {
370 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
371 $sPre = '<span class="unread">'; $sEnd = '</span>';
372 }
373 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
374 $sPre = '<span class="deleted">' . $sPre;
375 $sEnd .= '</span>';
376 } else {
377 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
378 $sPre = '<span class="flagged">' . $sPre;
379 $sEnd .= '</span>';
380 }
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) {
388 if (in_array($iCol, $show_label_columns)) {
389 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
390 $sLabelEnd = '</label>';
391 } else {
392 $sLabelStart = '';
393 $sLabelEnd = '';
394 }
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'] : '';
400 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
401 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
402 if ($iCol !== SQM_COL_CHECK) {
403 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
404 }
405
406
407 switch ($iCol) {
408 case SQM_COL_CHECK:
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>
412 <?php
413 } else {
414 echo '<td class="col_check">';
415 $checked = ($checkall) ? ' checked=checked ' : '';
416 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
417 }
418 break;
419 case SQM_COL_SUBJ:
420 $indent = $aCol['indent'];
421 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
422 if ($align['left'] == 'left') {
423 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
424 }
425 $sText .= "<a href=\"$link\"";
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"; }
430 if ($javascript_on && $fancy_index_highlite) {
431 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
432 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
433 $clickedColor .'\');"';
434 }
435 $sText .= ">"
436 . $value . '</a>';
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:
444 $sText = " <td class=\"col_flags\" $javascript_auto_click>"
445 . "$value</td>\n";
446 echo $sText;
447 break;
448 case SQM_COL_INT_DATE:
449 case SQM_COL_DATE:
450 $sText = " <td class=\"col_date\" $javascript_auto_click>"
451 . $value. "</td>\n";
452 echo $sText;
453 break;
454 default:
455 $sText = " <td class=\"col_text\" $javascript_auto_click";
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 }
471
472 echo '</tr>';
473 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
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>
489 <tr><td class="spacer"></td></tr>
490 <tr>
491 <td>
492 <table class="table_standard" cellspacing="0">
493 <tr>
494 <td>
495 <table class="table_empty" cellspacing="0">
496 <tr>
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>
506 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
507 </tr>
508 </table>
509 </td>
510 </tr>
511 </table>
512 </td>
513 </tr>
514 <tr>
515 <td>
516 <?php if (!empty($plugin_output['mailbox_index_after'])) echo $plugin_output['mailbox_index_after']; ?>
517 </td>
518 </tr>
519 </table>
520 </form>
521 </div>