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