3cac7aeda9a42075c3d4995ff49d703e5487d62b
[squirrelmail.git] / functions / page_header.php
1 <?php
2
3 /**
4 * page_header.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
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
14 require_once('../functions/strings.php');
15 require_once('../functions/imap_utf7_decode_local.php');
16
17 /* Always set up the language before calling these functions */
18 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
19
20 global $theme_css, $custom_css, $base_uri;
21
22 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
23 "\n\n<HTML>\n<HEAD>\n";
24
25 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
26 if ($theme_css != '') {
27 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
28 }
29 } else {
30 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
31 $base_uri . 'themes/css/'.$custom_css.'">';
32 }
33
34 echo "\n<title>$title</title>$xtra</head>\n\n";
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
47 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
48
49 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
50 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
51 $attachemessages, $session;
52
53 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
54 if ($qmark = strpos($module, '?')) {
55 $module = substr($module, 0, $qmark);
56 }
57 if (!isset($frame_top)) {
58 $frame_top = '_top';
59 }
60
61 /*
62 Locate the first displayable form element
63 */
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?newmessage=1';
69 $session = 0;
70 }
71
72 switch ( $module ) {
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";
83 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
84 ' if (new_mes) { '."\n".
85 " comp_uri = \"".$base_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".
94 ",scrollbars=yes,resizable=yes\");\n".
95 "}\n";
96
97 $js .= "// -->\n".
98 "</script>\n";
99 displayHtmlHeader ('Squirrelmail', $js);
100 }
101 displayHtmlHeader();
102 $onload = $xtra;
103 break;
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
133 default:
134 $js = '<script language="JavaScript" type="text/javascript">' .
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".
154 "$xtra\n".
155 "}\n";
156
157 if ($compose_new_win == '1') {
158 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
159 $compose_width = '640';
160 }
161 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
162 $compose_height = '550';
163 }
164 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
165 ' if (new_mes) { '."\n".
166 " comp_uri = \"".$base_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 ' var newwin = window.open(comp_uri' .
173 ', "_blank",
174 "width='.$compose_width.",height=$compose_height".
175 ",scrollbars=yes,resizable=yes\");\n".
176 "}\n";
177 }
178 $js .= "// -->\n".
179 "</script>\n";
180 $onload = "onLoad=\"checkForm();\"";
181 displayHtmlHeader ('Squirrelmail', $js);
182 break;
183
184 }
185
186 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
187 /** Here is the header and wrapping table **/
188 $shortBoxName = imap_utf7_decode_local(
189 readShortMailboxName($mailbox, $delimiter));
190 if ( $shortBoxName == 'INBOX' ) {
191 $shortBoxName = _("INBOX");
192 }
193 echo "<A NAME=pagetop></A>\n"
194 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
195 . " <TR BGCOLOR=\"$color[9]\" >\n"
196 . " <TD ALIGN=left>\n";
197 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
198 echo ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n";
199 } else {
200 echo '&nbsp;';
201 }
202 echo " </TD>\n"
203 . ' <TD ALIGN=right><b>';
204 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
205 echo "</b></TD>\n"
206 . " </TR>\n"
207 . " <TR BGCOLOR=\"$color[4]\">\n"
208 . " <TD ALIGN=left>\n";
209 $urlMailbox = urlencode($mailbox);
210 if ($compose_new_win == '1') {
211 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
212 }
213 else {
214 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
215 }
216 echo "&nbsp;&nbsp;\n";
217 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
218 echo "&nbsp;&nbsp;\n";
219 displayInternalLink ("src/folders.php", _("Folders"), 'right');
220 echo "&nbsp;&nbsp;\n";
221 displayInternalLink ("src/options.php", _("Options"), 'right');
222 echo "&nbsp;&nbsp;\n";
223 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
224 echo "&nbsp;&nbsp;\n";
225 displayInternalLink ("src/help.php", _("Help"), 'right');
226 echo "&nbsp;&nbsp;\n";
227
228 do_hook("menuline");
229
230 echo " </TD>\n <TD ALIGN=\"right\">";
231 echo ($hide_sm_attributions ? '&nbsp;' :
232 '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>');
233 echo "</TD>\n".
234 " </TR>\n".
235 "</TABLE>\n\n";
236 }
237
238 /* blatently copied/truncated/modified from the above function */
239 function compose_Header($color, $mailbox) {
240
241 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
242
243
244 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
245 if (!isset($frame_top)) {
246 $frame_top = '_top';
247 }
248
249 /*
250 Locate the first displayable form element
251 */
252 switch ( $module ) {
253 case 'src/search.php':
254 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
255 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
256 displayHtmlHeader (_("Compose"));
257 break;
258 default:
259 $js = '<script language="JavaScript" type="text/javascript">' .
260 "\n<!--\n" .
261 "function checkForm() {\n".
262 "var f = document.forms.length;\n".
263 "var i = 0;\n".
264 "var pos = -1;\n".
265 "while( pos == -1 && i < f ) {\n".
266 "var e = document.forms[i].elements.length;\n".
267 "var j = 0;\n".
268 "while( pos == -1 && j < e ) {\n".
269 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
270 "pos = j;\n".
271 "}\n".
272 "j++;\n".
273 "}\n".
274 "i++;\n".
275 "}\n".
276 "if( pos >= 0 ) {\n".
277 "document.forms[i-1].elements[pos].focus();\n".
278 "}\n".
279 "}\n";
280 $js .= "// -->\n".
281 "</script>\n";
282 $onload = "onLoad=\"checkForm();\"";
283 displayHtmlHeader (_("Compose"), $js);
284 break;
285
286 }
287
288 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
289 }
290 ?>