59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Prints the page header (duh) |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
46d38f78 |
14 | require_once('../functions/strings.php'); |
96b1b597 |
15 | require_once('../functions/imap_utf7_decode_local.php'); |
b01b21d0 |
16 | require_once('../functions/html.php'); |
96b1b597 |
17 | //require_once('../functions/imap_mailbox.php'); |
34c90574 |
18 | /* Always set up the language before calling these functions */ |
a07cd1a4 |
19 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
692155b7 |
20 | |
2c21ef20 |
21 | global $theme_css, $custom_css, $base_uri; |
22 | |
8f1ba72b |
23 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' . |
24 | "\n\n<HTML>\n<HEAD>\n"; |
2c21ef20 |
25 | |
a714cb95 |
26 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
27 | if ($theme_css != '') { |
34c90574 |
28 | echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">"; |
692155b7 |
29 | } |
8f1ba72b |
30 | } else { |
2c21ef20 |
31 | echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' . |
67dfe419 |
32 | $base_uri . 'themes/css/'.$custom_css.'">'; |
8f1ba72b |
33 | } |
85f4ce52 |
34 | |
237470b4 |
35 | if ($do_hook) { |
36 | do_hook("generic_header"); |
37 | } |
8f1ba72b |
38 | |
34c90574 |
39 | echo "\n<title>$title</title>$xtra</head>\n\n"; |
a07cd1a4 |
40 | } |
41 | |
85f4ce52 |
42 | |
a07cd1a4 |
43 | function displayInternalLink($path, $text, $target='') { |
44 | global $base_uri; |
45 | |
46 | if ($target != '') { |
47 | $target = " target=\"$target\""; |
48 | } |
a07cd1a4 |
49 | echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
50 | } |
51 | |
aca403fa |
52 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
715225af |
53 | |
07687736 |
54 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, |
aca403fa |
55 | $compose_new_win, $username, $datadir, $compose_width, $compose_height, |
56 | $attachemessages, $session; |
715225af |
57 | |
715225af |
58 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
f3e14140 |
59 | if ($qmark = strpos($module, '?')) { |
60 | $module = substr($module, 0, $qmark); |
61 | } |
d03f3582 |
62 | if (!isset($frame_top)) { |
63 | $frame_top = '_top'; |
64 | } |
715225af |
65 | |
cb6b53c6 |
66 | if ($session != false) { |
087ce5f8 |
67 | $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
aca403fa |
68 | } else { |
087ce5f8 |
69 | $compose_uri = $base_uri.'src/compose.php?newmessage=1'; |
d7f8e6e6 |
70 | $session = 0; |
aca403fa |
71 | } |
cb6b53c6 |
72 | |
715225af |
73 | switch ( $module ) { |
f3e14140 |
74 | case 'src/read_body.php': |
087ce5f8 |
75 | $js =''; |
f3e14140 |
76 | if ($compose_new_win == '1') { |
77 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
78 | $compose_width = '640'; |
79 | } |
80 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
81 | $compose_height = '550'; |
82 | } |
087ce5f8 |
83 | $js .= "\n".'<script language="JavaScript" type="text/javascript">' . |
f3e14140 |
84 | "\n<!--\n"; |
087ce5f8 |
85 | $js .= "function comp_in_new(comp_uri) {\n". |
86 | " if (!comp_uri) {\n". |
87 | ' comp_uri = "'.$compose_uri."\";\n". |
d7f8e6e6 |
88 | ' }'. "\n". |
d7f8e6e6 |
89 | ' var newwin = window.open(comp_uri' . |
087ce5f8 |
90 | ', "_blank",'. |
91 | '"width='.$compose_width. ',height='.$compose_height. |
92 | '",scrollbars="yes",resizable="yes");'."\n". |
93 | "}\n\n"; |
d7f8e6e6 |
94 | |
087ce5f8 |
95 | |
96 | $js .= 'function sendMDN() {'."\n". |
97 | "mdnuri=window.location+'&sendreceipt=1';". |
98 | "var newwin = window.open(mdnuri,'right');". |
99 | "\n}\n\n"; |
100 | |
101 | $js .= "// -->\n". |
102 | "</script>\n"; |
103 | |
104 | } |
105 | displayHtmlHeader ('Squirrelmail', $js); |
106 | $onload = $xtra; |
f3e14140 |
107 | break; |
d7f8e6e6 |
108 | case 'src/compose.php': |
109 | $js = '<script language="JavaScript" type="text/javascript">' . |
110 | "\n<!--\n" . |
111 | "function checkForm() {\n". |
112 | "var f = document.forms.length;\n". |
113 | "var i = 0;\n". |
114 | "var pos = -1;\n". |
115 | "while( pos == -1 && i < f ) {\n". |
116 | "var e = document.forms[i].elements.length;\n". |
117 | "var j = 0;\n". |
118 | "while( pos == -1 && j < e ) {\n". |
119 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
120 | "pos = j;\n". |
121 | "}\n". |
122 | "j++;\n". |
123 | "}\n". |
124 | "i++;\n". |
125 | "}\n". |
126 | "if( pos >= 0 ) {\n". |
127 | "document.forms[i-1].elements[pos].focus();\n". |
128 | "}\n". |
129 | "}\n"; |
130 | |
131 | $js .= "// -->\n". |
132 | "</script>\n"; |
133 | $onload = "onLoad=\"checkForm();\""; |
134 | displayHtmlHeader ('Squirrelmail', $js); |
135 | break; |
136 | |
715225af |
137 | default: |
aaf16822 |
138 | $js = '<script language="JavaScript" type="text/javascript">' . |
353616c4 |
139 | "\n<!--\n" . |
140 | "function checkForm() {\n". |
141 | "var f = document.forms.length;\n". |
142 | "var i = 0;\n". |
143 | "var pos = -1;\n". |
144 | "while( pos == -1 && i < f ) {\n". |
145 | "var e = document.forms[i].elements.length;\n". |
146 | "var j = 0;\n". |
147 | "while( pos == -1 && j < e ) {\n". |
148 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
149 | "pos = j;\n". |
150 | "}\n". |
151 | "j++;\n". |
152 | "}\n". |
153 | "i++;\n". |
154 | "}\n". |
155 | "if( pos >= 0 ) {\n". |
156 | "document.forms[i-1].elements[pos].focus();\n". |
157 | "}\n". |
de19cd73 |
158 | "$xtra\n". |
9c3e6cd4 |
159 | "}\n"; |
f3e14140 |
160 | |
9c3e6cd4 |
161 | if ($compose_new_win == '1') { |
07687736 |
162 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
163 | $compose_width = '640'; |
9c3e6cd4 |
164 | } |
07687736 |
165 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
166 | $compose_height = '550'; |
9c3e6cd4 |
167 | } |
087ce5f8 |
168 | $js .= "function comp_in_new(comp_uri) {\n". |
169 | " if (!comp_uri) {\n". |
170 | ' comp_uri = "'.$compose_uri."\";\n". |
d7f8e6e6 |
171 | ' }'. "\n". |
d7f8e6e6 |
172 | ' var newwin = window.open(comp_uri' . |
087ce5f8 |
173 | ', "_blank",'. |
174 | '"width='.$compose_width. ',height='.$compose_height. |
175 | '",scrollbars="yes",resizable="yes");'."\n". |
176 | "}\n\n"; |
177 | |
9c3e6cd4 |
178 | } |
087ce5f8 |
179 | $js .= "// -->\n". "</script>\n"; |
0cba960a |
180 | |
181 | |
715225af |
182 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
183 | displayHtmlHeader ('Squirrelmail', $js); |
715225af |
184 | break; |
185 | |
186 | } |
187 | |
b01b21d0 |
188 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
189 | /** Here is the header and wrapping table **/ |
f3e14140 |
190 | $shortBoxName = imap_utf7_decode_local( |
191 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
192 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
193 | $shortBoxName = _("INBOX"); |
194 | } |
b01b21d0 |
195 | echo "<a name=\"pagetop\"></a>\n" |
196 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
197 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
198 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
199 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
200 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
201 | } else { |
202 | echo ' '; |
203 | } |
b01b21d0 |
204 | echo " </td>\n" |
205 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
206 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
207 | echo "</b></td>\n" |
208 | . " </tr>\n" |
209 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
210 | . html_tag( 'td', '', 'left' ) ."\n"; |
a07cd1a4 |
211 | $urlMailbox = urlencode($mailbox); |
9c3e6cd4 |
212 | if ($compose_new_win == '1') { |
087ce5f8 |
213 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>'; |
9c3e6cd4 |
214 | } |
215 | else { |
216 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
217 | } |
a07cd1a4 |
218 | echo " \n"; |
219 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
220 | echo " \n"; |
221 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
222 | echo " \n"; |
223 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
224 | echo " \n"; |
225 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
226 | echo " \n"; |
227 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
228 | echo " \n"; |
229 | |
230 | do_hook("menuline"); |
231 | |
b01b21d0 |
232 | echo " </td>\n" |
233 | . html_tag( 'td', '', 'right' ) ."\n"; |
a07cd1a4 |
234 | echo ($hide_sm_attributions ? ' ' : |
b01b21d0 |
235 | '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>'); |
236 | echo "</td>\n". |
237 | " </tr>\n". |
238 | "</table>\n\n"; |
a07cd1a4 |
239 | } |
2ba13803 |
240 | |
9c3e6cd4 |
241 | /* blatently copied/truncated/modified from the above function */ |
242 | function compose_Header($color, $mailbox) { |
243 | |
244 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
245 | |
9c3e6cd4 |
246 | |
247 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
248 | if (!isset($frame_top)) { |
249 | $frame_top = '_top'; |
250 | } |
251 | |
252 | /* |
253 | Locate the first displayable form element |
254 | */ |
255 | switch ( $module ) { |
256 | case 'src/search.php': |
257 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
258 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
aaf16822 |
259 | displayHtmlHeader (_("Compose")); |
9c3e6cd4 |
260 | break; |
261 | default: |
aaf16822 |
262 | $js = '<script language="JavaScript" type="text/javascript">' . |
9c3e6cd4 |
263 | "\n<!--\n" . |
264 | "function checkForm() {\n". |
265 | "var f = document.forms.length;\n". |
266 | "var i = 0;\n". |
267 | "var pos = -1;\n". |
268 | "while( pos == -1 && i < f ) {\n". |
269 | "var e = document.forms[i].elements.length;\n". |
270 | "var j = 0;\n". |
271 | "while( pos == -1 && j < e ) {\n". |
272 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
273 | "pos = j;\n". |
274 | "}\n". |
275 | "j++;\n". |
276 | "}\n". |
277 | "i++;\n". |
278 | "}\n". |
279 | "if( pos >= 0 ) {\n". |
280 | "document.forms[i-1].elements[pos].focus();\n". |
281 | "}\n". |
282 | "}\n"; |
aaf16822 |
283 | $js .= "// -->\n". |
de19cd73 |
284 | "</script>\n"; |
9c3e6cd4 |
285 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
286 | displayHtmlHeader (_("Compose"), $js); |
9c3e6cd4 |
287 | break; |
288 | |
289 | } |
290 | |
b01b21d0 |
291 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
9c3e6cd4 |
292 | } |
43fdb2a4 |
293 | ?> |