Reimplement subject_link hook and add some new link attribute variables
[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 *
4b4abf93 8 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
49db257d 10 * @version $Id$
11 * @package squirrelmail
57d06b39 12 * @subpackage templates
49db257d 13 */
14
f2e2aa7f 15/** add required includes */
49db257d 16include_once(SM_PATH . 'templates/util_message_list.php');
17
18/* retrieve the template vars */
19extract($t);
20
21do_hook('mailbox_index_before');
22
23/**
24 * Calculate string "Viewing message x to y (z total)"
25 */
26$msg_cnt_str = '';
27if ($pageOffset < $end_msg) {
28 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
29 '<b>'.$pageOffset.'</b>', '<b>'.$end_msg.'</b>', $iNumberOfMessages);
30} else if ($pageOffset == $end_msg) {
31 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$pageOffset.'</b>', $iNumberOfMessages);
32}
33
34
35
36if (!($sort & SQSORT_THREAD) && $enablesort) {
49719da8 37 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
38 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
39 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
40 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
41 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
42 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
43 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
49db257d 44} else {
45 $aSortSupported = array();
46}
47
48// figure out which columns should serve as labels for checkbox:
49// we try to grab the two columns before and after the checkbox,
50// except the subject column, since it is the link that opens
51// the message view
52//
53// if $javascript_on is set, then the highlighting code takes
54// care of this; just skip it
55//
56$show_label_columns = array();
57$index_order_part = array();
58if (!($javascript_on && $fancy_index_highlite)) {
59 $get_next_two = 0;
60 $last_order_part = 0;
61 $last_last_order_part = 0;
62 foreach ($aOrder as $index_order_part) {
63 if ($index_order_part == SQM_COL_CHECK) {
64 $get_next_two = 1;
65 if ($last_last_order_part != SQM_COL_SUBJ)
66 $show_label_columns[] = $last_last_order_part;
67 if ($last_order_part != SQM_COL_SUBJ)
68 $show_label_columns[] = $last_order_part;
69
70 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
71 $show_label_columns[] = $index_order_part;
72 $get_next_two++;
73 }
74 $last_last_order_part = $last_order_part;
75 $last_order_part = $index_order_part;
76 }
77}
78
583db309 79/**
80 * Check usage of images for attachments, flags and priority
81 */
82$bIcons = ($use_icons && $icon_theme) ? true : false;
83
84/**
85 * Location of icon images
86 */
87if ($bIcons) {
88 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
89}
90
49db257d 91// set this to an empty string to turn off extra
92// highlighting of checked rows
93//
94//$clickedColor = '';
583db309 95$clickedColor = (empty($color[16])) ? $color[2] : $color[16];
49db257d 96
97?>
98<form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
99<table border="0" width="100%" cellpadding="0" cellspacing="0">
100 <tr>
101 <td>
a69c8eb2 102 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
49db257d 103 <tr>
104 <td>
105 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
106 <tr>
107 <td align="<?php echo $align['left']; ?>">
108 <small>
109<!-- paginator and thread link string -->
110 <?php
111 /**
112 * because the template is included in the display function we refer to $oTemplate with $this
113 */
114 $paginator_str = $this->fetch('paginator.tpl');
115 echo $paginator_str . $thread_link_str ."\n"; ?>
116<!-- end paginator and thread link string -->
117 </small>
118 </td>
119<!-- message count string -->
120 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
121<!-- end message count string -->
122 </tr>
123 </table>
124 </td>
125 </tr>
126<?php
127 if (count($aFormElements)) {
128?>
129<!-- start message list form control -->
130 <tr bgcolor="<?php echo $color[0]; ?>">
131 <td>
132 <table border="0" width="100%" cellpadding="1" cellspacing="0">
133 <tr>
134 <td align="<?php echo $align['left']; ?>">
135 <small>
136
137<?php
138 foreach ($aFormElements as $key => $value) {
139 switch ($value[1]) {
140 case 'submit':
a5d40e74 141 if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
49db257d 142?>
a69c8eb2 143 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
49db257d 144<?php
a5d40e74 145 }
49db257d 146 break;
147 case 'checkbox':
a5d40e74 148 if ($key != 'bypass_trash') {
49db257d 149?>
150 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
151<?php
a5d40e74 152 }
49db257d 153 break;
154 case 'hidden':
155 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
156 break;
157 default: break;
158 }
159 }
160?>
161 </small>
162 </td>
163 <td align="<?php echo $align['right']; ?>">
164
165
166<?php
a5d40e74 167 if (isset($aFormElements['delete'])) {
168?>
169 <td align="<?php echo $align['right']; ?>">
170 <small>
171 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
172 <?php
173 if (isset($aFormElements['bypass_trash'])) {
174?>
175 <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>&nbsp;
176<?php
177 }
178 if (isset($aFormElements['undeleteButton'])) {
179?>
180 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" style="padding: 0px; margin: 0px;" />&nbsp;
181<?php
182 }
183?>
184 </small>
185 </td>
186<?php
187 } // if (isset($aFormElements['delete']))
49db257d 188 if (isset($aFormElements['moveButton'])) {
a5d40e74 189?>
190 <td align="<?php echo $align['right']; ?>">
191 <small>&nbsp;
49db257d 192 <tt>
193 <select name="targetMailbox">
194 <?php echo $aFormElements['targetMailbox'][0];?>
195 </select>
196 </tt>
a69c8eb2 197 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px;" />
49db257d 198 </small>
a5d40e74 199 </td>
200
49db257d 201<?php
202 } // if (isset($aFormElements['move']))
203?>
49db257d 204 </tr>
205 </table>
206 </td>
207 </tr>
208<!-- end message list form control -->
209<?php
210 } // if (count($aFormElements))
211?>
212 </table>
213<?php
214 do_hook('mailbox_form_before');
215?>
216 </td>
217 </tr>
218 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
219 <tr>
220 <td>
221 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
222 <tr>
223 <td>
224 <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
225 <tr>
226 <td>
227<!-- table header start -->
228 <tr>
229<?php
230 $aWidth = calcMessageListColumnWidth($aOrder);
231 foreach($aOrder as $iCol) {
232
233?>
a69c8eb2 234 <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%" style="white-space: nowrap;">
49db257d 235 <b>
236<?php
237 switch ($iCol) {
238 case SQM_COL_CHECK:
239 if ($javascript_on) {
95e203e9 240 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.",'".$clickedColor.'\');" />';
49db257d 241 } else {
242 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;&amp;checkall=";
243 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
244 $link .= ($checkall) ? '0' : '1';
245 } else {
246 $link .= '1';
247 }
248 echo "<a href=\"$link\">"._("All").'</a>';
249 }
250 break;
251 case SQM_COL_FROM: echo _("From"); break;
252 case SQM_COL_DATE: echo _("Date"); break;
253 case SQM_COL_SUBJ: echo _("Subject"); break;
583db309 254 case SQM_COL_FLAGS:
255 if ($bIcons) {
256 echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />';
257 } else {
258 echo '&nbsp;';
259 }
260 break;
49db257d 261 case SQM_COL_SIZE: echo _("Size"); break;
583db309 262 case SQM_COL_PRIO:
263 if ($bIcons) {
069a91d3 264 echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />';
583db309 265 } else {
266 echo '!';
267 }
268 break;
269 case SQM_COL_ATTACHMENT:
270 if ($bIcons) {
069a91d3 271 echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>';
583db309 272 } else {
273 echo '+';
274 }
275 break;
49db257d 276 case SQM_COL_INT_DATE: echo _("Received"); break;
277 case SQM_COL_TO: echo _("To"); break;
278 case SQM_COL_CC: echo _("Cc"); break;
279 case SQM_COL_BCC: echo _("Bcc"); break;
280 default: break;
281 }
282 // add the sort buttons
283 if (isset($aSortSupported[$iCol])) {
284 if ($sort == $aSortSupported[$iCol][0]) {
285 $newsort = $aSortSupported[$iCol][1];
286 $img = 'up_pointer.png';
287 } else if ($sort == $aSortSupported[$iCol][1]) {
288 $newsort = 0;
289 $img = 'down_pointer.png';
290 } else {
291 $newsort = $aSortSupported[$iCol][0];
292 $img = 'sort_none.png';
293 }
294 /* Now that we have everything figured out, show the actual button. */
295 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">";
296 echo '<img src="../images/' . $img
297 . '" border="0" width="12" height="10" alt="sort" title="'
298 . _("Click here to change the sorting of the message list") .'" /></a>';
299 }
300?>
301 </b>
302 </td>
303<?php
304 }
305?>
306 </tr>
307
308<!-- Message headers start -->
309<?php
310 $i = 0;
311 $iColCnt = count($aOrder);
312 $sLine = '';
313
314 // this stuff does the auto row highlighting on mouseover
315 //
316 if ($javascript_on && $fancy_index_highlite) {
317
318 $mouseoverColor = $color[5];
319
320 // set this to an empty string to turn off extra
321 // highlighting of checked rows
322 //
323 //$clickedColor = '';
324 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
799ee2d5 325
cd0a9317 326 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
799ee2d5 327 } else {
328 $checkbox_javascript = '';
49db257d 329 }
330 foreach ($aMessages as $iUid => $aMsg) {
331 echo $sLine;
332
333/**
334* Display message header row in messages list
335*
336*/
337
338 $aColumns = $aMsg['columns'];
339
49db257d 340
341 /**
342 * Check the flags and set a class var.
343 */
344 if (isset($aColumns[SQM_COL_FLAGS])) {
345 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
346 if ($bIcons) {
347
348 $sFlags = getFlagIcon($aFlags, $sImageLocation);
349 } else {
350 $sFlags = getFlagText($aFlags);
351 }
352 /* add the flag string to the value index */
353 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
354 }
355 /**
356 * Check the priority column
357 */
358 if (isset($aColumns[SQM_COL_PRIO])) {
359 /* FIX ME, we should use separate templates for icons */
360 if ($bIcons) {
361 $sValue = '<img src="' . $sImageLocation;
362 switch ($aColumns[SQM_COL_PRIO]['value']) {
363 case 1:
364 case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
365 case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
366 default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
367 }
368 } else {
369 $sValue = '';
370 switch ($aColumns[SQM_COL_PRIO]['value']) {
371 case 1:
372 case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break;
a5d40e74 373 // use downwards arrow for low priority emails
57d06b39 374 case 5: $sValue .= "<font color=\"$color[8]\">&#8595;</font>"; break;
49db257d 375 default: break;
376 }
377 }
378 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
379 }
380
381 /**
382 * Check the attachment column
383 */
384 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
385 /* FIX ME, we should use separate templates for icons */
386 if ($bIcons) {
387 $sValue = '<img src="' . $sImageLocation;
388 $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
389 ? 'attach.png" border="0" height="10" width="6" alt=""/>'
390 : 'transparent.png" border="0" width="6" alt="" />';
391 } else {
392 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
393 }
394 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
395 }
396
397
398 $bgcolor = $color[4];
399
400 /**
401 * If alternating row colors is set, adapt the bgcolor
402 */
403 if (isset($alt_index_colors) && $alt_index_colors) {
404 if (!($i % 2)) {
405 if (!isset($color[12])) {
406 $color[12] = '#EAEAEA';
407 }
408 $bgcolor = $color[12];
409 }
410
411 }
412 $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
413 $class = 'msg_row';
414
415 $row_extra = '';
416
417 // this stuff does the auto row highlighting on mouseover
418 //
419 if ($javascript_on && $fancy_index_highlite) {
420 $row_extra .= ' onmouseover="rowOver(\''.$form_id . "_msg$i','". $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
421 }
422 // this does the auto-checking of the checkbox no matter
423 // where on the row you click
424 //
425 $javascript_auto_click = '';
426 if ($javascript_on && $fancy_index_highlite) {
427 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
428 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
429 }
430
431?>
432<tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
433<?php
434 // flag style mumbo jumbo
435 $sPre = $sEnd = '';
bf9e5efb 436 if (isset($aColumns[SQM_COL_FLAGS])) {
f2e2aa7f 437 if (!in_array('seen',$aFlags)) {
438 $sPre = '<b>'; $sEnd = '</b>';
439 }
440 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
441 $sPre = "<font color=\"$color[9]\">" . $sPre;
49db257d 442 $sEnd .= '</font>';
f2e2aa7f 443 } else {
444 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
445 $sPre = "<font color=\"$color[2]\">" . $sPre;
446 $sEnd .= '</font>';
447 }
49db257d 448 }
449 }
450 /**
451 * Because the order of the columns and which columns to show is a user preference
452 * we have to do some php coding to display the columns in the right order
453 */
454 foreach ($aOrder as $iCol) {
6547ab43 455 if (in_array($iCol, $show_label_columns)) {
6d34ad62 456 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
49db257d 457 $sLabelEnd = '</label>';
458 } else {
459 $sLabelStart = '';
460 $sLabelEnd = '';
461 }
02e830bd 462 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
463 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
464 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
465 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
466 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
467 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
468 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
469 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
49db257d 470 if ($iCol !== SQM_COL_CHECK) {
471 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
472 }
473
474
475 switch ($iCol) {
476 case SQM_COL_CHECK:
a69c8eb2 477 echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'" style="white-space: nowrap;">' ?>
49db257d 478 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
479 <?php
480 break;
481 case SQM_COL_SUBJ:
482 $indent = $aCol['indent'];
483 $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
484 if ($align['left'] == 'left') {
485 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
486 }
487 $sText .= "<a href=\"$link\"";
02e830bd 488 if ($target) { $sText .= " target=\"$target\""; }
489 if ($title) { $sText .= " title=\"$title\""; }
490 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
491 if ($link_extra) { $sText .= " $link_extra"; }
49db257d 492 if ($javascript_on && $fancy_index_highlite) {
493 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
494 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
495 $clickedColor .'\');"';
496 }
497 $sText .= ">";
498 $sText .= $value . '</a>';
499 if ($align['left'] == 'right') {
500 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
501 }
502 echo $sText."</td>\n";
503 break;
504 case SQM_COL_SIZE:
505 case SQM_COL_FLAGS:
583db309 506 $sText = " <td class=\"col_flags\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
49db257d 507 $sText .= "<small>$value</small></td>\n";
508 echo $sText;
509 break;
510 case SQM_COL_INT_DATE:
511 case SQM_COL_DATE:
a69c8eb2 512 $sText = " <td class=\"col_date\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\" style=\"white-space: nowrap;\">";
49db257d 513 $sText .= $value. "</td>\n";
514 echo $sText;
515 break;
516 default:
a69c8eb2 517 $sText = " <td class=\"col_text\" align=\"$align[left]\" style=\"white-space: nowrap;\" $javascript_auto_click bgcolor=\"$bgcolor\"";
49db257d 518 if ($link) {
519 $sText .= "><a href=\"$link\"";
520 if ($target) { $sText .= " target=\"$target\"";}
521 if ($title) { $sText .= " title=\"$title\"" ;}
522 $sText .= ">";
523 } else {
524 if ($title) {$sText .= " title=\"$title\"";}
525 $sText .= ">";
526 }
527 $sText .= $value;
528 if ($link) { $sText .= '</a>';}
529 echo $sText."</td>\n";
530 break;
531 }
532 }
533?>
534 </tr>
535<?php
536 $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
537 ++$i;
538
539/*
540 * End displaying row part
541 */
542 }
543
544?>
545<!-- Message headers end -->
546 </table>
547 </td>
548 </tr>
549 </table>
550 </td>
551 </tr>
552 <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
553 <tr>
554 <td>
a69c8eb2 555 <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>;">
49db257d 556 <tr>
557 <td>
558 <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
559 <tr>
560 <td align="left"><small><?php echo $paginator_str; ?></small></td>
561 <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
562 </tr>
563 </table>
564 </td>
565 </tr>
566 </table>
567 </td>
568 </tr>
569 <tr>
570 <td>
571 <?php do_hook('mailbox_index_after');?>
572 </td>
573 </tr>
574 </table>
cd0a9317 575</form>