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 { |
68 | $compose_uri = 'src/compose.php'; |
69 | } |
70 | |
715225af |
71 | switch ( $module ) { |
f3e14140 |
72 | case 'src/read_body.php': |
73 | if ($compose_new_win == '1') { |
74 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
75 | $compose_width = '640'; |
76 | } |
77 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
78 | $compose_height = '550'; |
79 | } |
80 | $js = "\n".'<script language="JavaScript" type="text/javascript">' . |
81 | "\n<!--\n"; |
82 | $js .= "function comp_in_new() {\n". |
aca403fa |
83 | " var newwin = window.open(\"".$base_uri.$compose_uri. '"'. |
f3e14140 |
84 | ", \"compose_window\", |
85 | \"width=".$compose_width.",height=$compose_height". |
86 | ",scrollbars=yes,resizable=yes\");\n". |
87 | "}\n"; |
88 | $js .= "// -->\n". |
89 | "</script>\n"; |
90 | displayHtmlHeader ('Squirrelmail', $js); |
91 | } |
92 | displayHtmlHeader(); |
aca403fa |
93 | $onload = $xtra; |
f3e14140 |
94 | break; |
715225af |
95 | default: |
aaf16822 |
96 | $js = '<script language="JavaScript" type="text/javascript">' . |
353616c4 |
97 | "\n<!--\n" . |
98 | "function checkForm() {\n". |
99 | "var f = document.forms.length;\n". |
100 | "var i = 0;\n". |
101 | "var pos = -1;\n". |
102 | "while( pos == -1 && i < f ) {\n". |
103 | "var e = document.forms[i].elements.length;\n". |
104 | "var j = 0;\n". |
105 | "while( pos == -1 && j < e ) {\n". |
106 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
107 | "pos = j;\n". |
108 | "}\n". |
109 | "j++;\n". |
110 | "}\n". |
111 | "i++;\n". |
112 | "}\n". |
113 | "if( pos >= 0 ) {\n". |
114 | "document.forms[i-1].elements[pos].focus();\n". |
115 | "}\n". |
de19cd73 |
116 | "$xtra\n". |
9c3e6cd4 |
117 | "}\n"; |
f3e14140 |
118 | |
9c3e6cd4 |
119 | if ($compose_new_win == '1') { |
07687736 |
120 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
121 | $compose_width = '640'; |
9c3e6cd4 |
122 | } |
07687736 |
123 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
124 | $compose_height = '550'; |
9c3e6cd4 |
125 | } |
aaf16822 |
126 | $js .= "function comp_in_new() {\n". |
f3e14140 |
127 | ' var newwin = window.open("'.$base_uri.$compose_uri . '"' . |
128 | ', "compose_window", |
129 | "width='.$compose_width.",height=$compose_height". |
9c3e6cd4 |
130 | ",scrollbars=yes,resizable=yes\");\n". |
131 | "}\n"; |
132 | } |
aaf16822 |
133 | $js .= "// -->\n". |
de19cd73 |
134 | "</script>\n"; |
715225af |
135 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
136 | displayHtmlHeader ('Squirrelmail', $js); |
715225af |
137 | break; |
138 | |
139 | } |
140 | |
141 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
142 | /** Here is the header and wrapping table **/ |
f3e14140 |
143 | $shortBoxName = imap_utf7_decode_local( |
144 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
145 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
146 | $shortBoxName = _("INBOX"); |
147 | } |
a07cd1a4 |
148 | echo "<A NAME=pagetop></A>\n" |
149 | . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n" |
150 | . " <TR BGCOLOR=\"$color[9]\" >\n" |
5bb2a991 |
151 | . " <TD ALIGN=left>\n"; |
152 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
153 | echo ' ' . _("Current Folder") . ": <B>$shortBoxName </B>\n"; |
154 | } else { |
155 | echo ' '; |
156 | } |
157 | echo " </TD>\n" |
34c90574 |
158 | . ' <TD ALIGN=right><b>'; |
80e86e94 |
159 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
34c90574 |
160 | echo "</b></TD>\n" |
a07cd1a4 |
161 | . " </TR>\n" |
162 | . " <TR BGCOLOR=\"$color[4]\">\n" |
163 | . " <TD ALIGN=left>\n"; |
164 | $urlMailbox = urlencode($mailbox); |
9c3e6cd4 |
165 | if ($compose_new_win == '1') { |
166 | echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=". |
9c8ba651 |
167 | '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>'; |
9c3e6cd4 |
168 | } |
169 | else { |
170 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
171 | } |
a07cd1a4 |
172 | echo " \n"; |
173 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
174 | echo " \n"; |
175 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
176 | echo " \n"; |
177 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
178 | echo " \n"; |
179 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
180 | echo " \n"; |
181 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
182 | echo " \n"; |
183 | |
184 | do_hook("menuline"); |
185 | |
34c90574 |
186 | echo " </TD>\n <TD ALIGN=\"right\">"; |
a07cd1a4 |
187 | echo ($hide_sm_attributions ? ' ' : |
34c90574 |
188 | '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>'); |
189 | echo "</TD>\n". |
a07cd1a4 |
190 | " </TR>\n". |
191 | "</TABLE>\n\n"; |
192 | } |
2ba13803 |
193 | |
9c3e6cd4 |
194 | /* blatently copied/truncated/modified from the above function */ |
195 | function compose_Header($color, $mailbox) { |
196 | |
197 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
198 | |
9c3e6cd4 |
199 | |
200 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
201 | if (!isset($frame_top)) { |
202 | $frame_top = '_top'; |
203 | } |
204 | |
205 | /* |
206 | Locate the first displayable form element |
207 | */ |
208 | switch ( $module ) { |
209 | case 'src/search.php': |
210 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
211 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
aaf16822 |
212 | displayHtmlHeader (_("Compose")); |
9c3e6cd4 |
213 | break; |
214 | default: |
aaf16822 |
215 | $js = '<script language="JavaScript" type="text/javascript">' . |
9c3e6cd4 |
216 | "\n<!--\n" . |
217 | "function checkForm() {\n". |
218 | "var f = document.forms.length;\n". |
219 | "var i = 0;\n". |
220 | "var pos = -1;\n". |
221 | "while( pos == -1 && i < f ) {\n". |
222 | "var e = document.forms[i].elements.length;\n". |
223 | "var j = 0;\n". |
224 | "while( pos == -1 && j < e ) {\n". |
225 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
226 | "pos = j;\n". |
227 | "}\n". |
228 | "j++;\n". |
229 | "}\n". |
230 | "i++;\n". |
231 | "}\n". |
232 | "if( pos >= 0 ) {\n". |
233 | "document.forms[i-1].elements[pos].focus();\n". |
234 | "}\n". |
235 | "}\n"; |
aaf16822 |
236 | $js .= "// -->\n". |
de19cd73 |
237 | "</script>\n"; |
9c3e6cd4 |
238 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
239 | displayHtmlHeader (_("Compose"), $js); |
9c3e6cd4 |
240 | break; |
241 | |
242 | } |
243 | |
244 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
245 | } |
43fdb2a4 |
246 | ?> |