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