82c463ce |
1 | <?php |
2 | /** |
3 | * read_headers.tpl |
4 | * |
5 | * Template to display the envelope headers when viewing a message. |
6 | * |
7 | * The following variables are available in this template: |
8 | * |
9 | * $headers_to_display - Array containing the list of all elements that need |
10 | * to be displayed. The index of each element is the |
11 | * translated name of the field to be displayed. The |
12 | * value of each element is the value to be displayed |
13 | * for that field. Many values can be controled through |
14 | * additional templates. |
15 | * |
16 | * |
c0d96801 |
17 | * @copyright 1999-2012 The SquirrelMail Project Team |
82c463ce |
18 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
19 | * @version $Id: read_headers.tpl 11998 2006-12-10 21:06:24Z pdontthink $ |
20 | * @package squirrelmail |
21 | * @subpackage templates |
22 | */ |
23 | |
24 | /** add required includes **/ |
25 | |
26 | /** extract template variables **/ |
27 | extract($t); |
28 | |
29 | /** Begin template **/ |
30 | ?> |
31 | <div class="readHeaders"> |
32 | <table cellspacing="0" class="spacer"> |
33 | <tr> |
34 | <td> |
35 | </td> |
36 | </tr> |
37 | </table> |
38 | <table cellspacing="0" class="table2"> |
39 | <?php |
40 | |
41 | // detect if we want to show reduced header or regular (expanded) header list |
42 | // default is to show the reduced header when the preview pane is turned on |
43 | // |
44 | // note that this is an example of a template page making use of its own |
45 | // value placed on the page's query string; we like to keep things like |
46 | // that in the core, but for template-specific add-on functionalities, this |
47 | // kind of thing is perfectly acceptable |
48 | // |
49 | global $data_dir, $username, $PHP_SELF; |
50 | $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0); |
51 | $show_preview_pane = checkForJavascript() && $use_previewPane; |
52 | if (!sqGetGlobalVar('expand_header', $expand_header, SQ_FORM, 0)) |
53 | if (!$show_preview_pane) |
54 | $expand_header = 1; |
55 | |
56 | // show reduced (collapsed) header |
57 | if (!$expand_header) { |
58 | |
ca49a46f |
59 | $subject = (!empty($headers_to_display[_("Subject")]) |
60 | ? $headers_to_display[_("Subject")] : _("(no subject)")); |
61 | $date = (!empty($headers_to_display[_("Date")]) |
62 | ? $headers_to_display[_("Date")] : _("Unknown date")); |
63 | $from = (!empty($headers_to_display[_("From")]) |
64 | ? $headers_to_display[_("From")] : _("Unknown sender")); |
82c463ce |
65 | // if available, print "real" name instead of email addr |
66 | if (strpos($from,"<") !== FALSE) { |
67 | list($from, $ignore) = $parts = explode('<', $from); |
68 | $from = trim($from); |
69 | $from = preg_replace('/^( )+|( )+$/', '', $from); |
70 | $from = preg_replace('/^(")+|(")+$/', '', $from); |
71 | $from = preg_replace('/"$/', '', trim($from)); |
72 | } |
b0dab4a6 |
73 | // i18n: The parameters are: subject, sender, and date. |
31f8cb78 |
74 | $reduced_header = sprintf(_("%s from %s on %s"), "<b>$subject</b>", "<b>$from</b>", "<b>$date</b>"); |
82c463ce |
75 | $expand_link = str_replace('&expand_header=0', '', $PHP_SELF) . '&expand_header=1'; |
76 | |
77 | echo '<tr><td colspan="2" align="center" valign="top">' |
78 | . '<a href="' . $expand_link . '">' |
79 | . getIcon($icon_theme_path, 'plus.png', '-', _("Expand Header")) |
80 | . '</a> ' |
81 | . $reduced_header |
82 | . '</td></tr>'; |
83 | |
84 | // show normal/full/expanded header listing |
85 | } else { |
86 | |
87 | $collapse_link = str_replace('&expand_header=1', '', $PHP_SELF) . '&expand_header=0'; |
88 | $first_time = TRUE; |
89 | foreach ($headers_to_display as $field_name=>$value) { |
90 | if (empty($value)) { |
91 | # Skip enpty headers |
92 | continue; |
93 | } |
94 | ?> |
2ad37738 |
95 | <tr class="field_<?php echo $field_name; ?>"> |
82c463ce |
96 | <td class="fieldName"> |
97 | <?php |
98 | if ($first_time) |
99 | echo '<a href="' . $collapse_link . '">' |
100 | . getIcon($icon_theme_path, 'minus.png', '-', _("Collapse Header")) |
101 | . '</a> '; |
102 | echo $field_name . ':'; |
103 | $first_time = FALSE; |
104 | ?> |
105 | </td> |
106 | <td class="fieldValue"> |
107 | <?php echo $value; ?> |
108 | </td> |
109 | </tr> |
110 | <?php |
111 | } |
112 | } |
113 | if (!empty($plugin_output['read_body_header'])) echo $plugin_output['read_body_header']; |
114 | ?> |
115 | </table> |
116 | <table cellspacing="0" class="spacer"> |
117 | <tr> |
118 | <td> |
119 | </td> |
120 | </tr> |
121 | </table> |
122 | </div> |
010ff205 |
123 | <?php |
124 | // do a conditional refresh of message list if needed |
125 | // "pp_rr" = "preview pane read refresh" |
212d8abf |
126 | // "pp_rr_force" = force pp_rr even if this is not the first time the message has been read |
127 | if ($show_preview_pane |
128 | && (sqGetGlobalVar('pp_rr_force', $pp_rr_force, SQ_FORM) |
129 | || (sqGetGlobalVar('pp_rr', $pp_rr, SQ_FORM) && $first_time_reading))) { |
130 | echo "<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\nif (self.name == 'bottom') { refresh_message_list(); }\n// -->\n</script>\n"; |
010ff205 |
131 | } |