Refactor message list control widgets into their own template file; useful if we...
[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 $i = 0;
258 $iColCnt = count($aOrder);
259 $sLine = '';
260
261 // this stuff does the auto row highlighting on mouseover
262 //
263 if ($javascript_on && $fancy_index_highlite) {
264
265 $mouseoverColor = $color[5];
266
267 // set this to an empty string to turn off extra
268 // highlighting of checked rows
269 //
270 //$clickedColor = '';
271 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
272
273 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
274 } else {
275 $checkbox_javascript = '';
276 }
277 foreach ($aMessages as $iUid => $aMsg) {
278 echo $sLine;
279
280 /**
281 * Display message header row in messages list
282 *
283 */
284
285 $aColumns = $aMsg['columns'];
286
287
288 /**
289 * Check the flags and set a class var.
290 */
291 if (isset($aColumns[SQM_COL_FLAGS])) {
292 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
293 $sFlags = getFlagIcon($aFlags, $icon_theme_path);
294
295 /* add the flag string to the value index */
296 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
297 }
298 /**
299 * Check the priority column
300 */
301 if (isset($aColumns[SQM_COL_PRIO])) {
302 $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
303 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
304 }
305
306 /**
307 * Check the attachment column
308 */
309 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
310 $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path);
311 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
312 }
313
314 $class = 'even';
315 /**
316 * If alternating row colors is set, adapt the CSS class
317 */
318 if (isset($alt_index_colors) && $alt_index_colors) {
319 if (!($i % 2)) {
320 $class = 'odd';
321 }
322
323 }
324 if (isset($aMsg['row']['color']))
325 {
326 $bgcolor = $aMsg['row']['color'];
327 $class = 'misc'.$i;
328 }
329 else $bgcolor = '';
330
331 $row_extra = '';
332
333 // this stuff does the auto row highlighting on mouseover
334 //
335 if ($javascript_on && $fancy_index_highlite) {
336 $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\');"';
337 }
338 // this does the auto-checking of the checkbox no matter
339 // where on the row you click
340 //
341 $javascript_auto_click = '';
342 if ($javascript_on && $fancy_index_highlite) {
343 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
344 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
345 }
346
347 /*
348 * Message Highlighting requires a unique CSS class declaration for proper
349 * mouseover functionality. There is no harm in doing this when the mouseover
350 * functionality is disabled
351 */
352 if ($class != 'even' && $class != 'odd')
353 {
354 ?>
355 <style type="text/css">
356 <!--
357 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
358 -->
359 </style>
360 <?php
361 }
362 ?>
363 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
364 <?php
365 // flag style mumbo jumbo
366 $sPre = $sEnd = '';
367 if (isset($aColumns[SQM_COL_FLAGS])) {
368 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
369 $sPre = '<span class="unread">'; $sEnd = '</span>';
370 }
371 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
372 $sPre = '<span class="deleted">' . $sPre;
373 $sEnd .= '</span>';
374 } else {
375 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
376 $sPre = '<span class="flagged">' . $sPre;
377 $sEnd .= '</span>';
378 }
379 }
380 }
381 /**
382 * Because the order of the columns and which columns to show is a user preference
383 * we have to do some php coding to display the columns in the right order
384 */
385 foreach ($aOrder as $iCol) {
386 if (in_array($iCol, $show_label_columns)) {
387 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
388 $sLabelEnd = '</label>';
389 } else {
390 $sLabelStart = '';
391 $sLabelEnd = '';
392 }
393 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
394 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
395 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
396 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
397 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
398 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
399 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
400 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
401 if ($iCol !== SQM_COL_CHECK) {
402 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
403 }
404
405
406 switch ($iCol) {
407 case SQM_COL_CHECK:
408 if ($javascript_on) {
409 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
410 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
411 <?php
412 } else {
413 echo '<td class="col_check">';
414 $checked = ($checkall) ? " checked=checked " : " ";
415 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
416 }
417 break;
418 case SQM_COL_SUBJ:
419 $indent = $aCol['indent'];
420 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
421 if ($align['left'] == 'left') {
422 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
423 }
424 $sText .= "<a href=\"$link\"";
425 if ($target) { $sText .= " target=\"$target\""; }
426 if ($title) { $sText .= " title=\"$title\""; }
427 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
428 if ($link_extra) { $sText .= " $link_extra"; }
429 if ($javascript_on && $fancy_index_highlite) {
430 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
431 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
432 $clickedColor .'\');"';
433 }
434 $sText .= ">";
435 $sText .= $value . '</a>';
436 if ($align['left'] == 'right') {
437 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
438 }
439 echo $sText."</td>\n";
440 break;
441 case SQM_COL_SIZE:
442 case SQM_COL_FLAGS:
443 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
444 $sText .= "$value</td>\n";
445 echo $sText;
446 break;
447 case SQM_COL_INT_DATE:
448 case SQM_COL_DATE:
449 $sText = " <td class=\"col_date\" $javascript_auto_click>";
450 $sText .= $value. "</td>\n";
451 echo $sText;
452 break;
453 default:
454 $sText = " <td class=\"col_text\" $javascript_auto_click";
455 if ($link) {
456 $sText .= "><a href=\"$link\"";
457 if ($target) { $sText .= " target=\"$target\"";}
458 if ($title) { $sText .= " title=\"$title\"" ;}
459 $sText .= ">";
460 } else {
461 if ($title) {$sText .= " title=\"$title\"";}
462 $sText .= ">";
463 }
464 $sText .= $value;
465 if ($link) { $sText .= '</a>';}
466 echo $sText."</td>\n";
467 break;
468 }
469 }
470 ?>
471 </tr>
472 <?php
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 echo $paginator_str; ?></td>
498 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
499 </tr>
500 </table>
501 </td>
502 </tr>
503 </table>
504 </td>
505 </tr>
506 <tr>
507 <td>
508 <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>
509 </td>
510 </tr>
511 </table>
512 </form>
513 </div>