Continue development on 1.4.1!
[squirrelmail.git] / functions / page_header.php
CommitLineData
59177427 1<?php
7350889b 2
35586184 3/**
4 * page_header.php
5 *
76911253 6 * Copyright (c) 1999-2003 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
b68edc75 14require_once(SM_PATH . 'functions/strings.php');
15require_once(SM_PATH . 'functions/html.php');
16require_once(SM_PATH . 'functions/imap_mailbox.php');
0b97a708 17require_once(SM_PATH . 'functions/global.php');
b68edc75 18
34c90574 19/* Always set up the language before calling these functions */
a07cd1a4 20function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
e842b215 21 global $squirrelmail_language;
692155b7 22
0365891c 23 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
0b97a708 24 global $base_uri;
25 }
26 global $theme_css, $custom_css;
2c21ef20 27
12ff1cab 28 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
98fb28fd 29 "\n\n" . html_tag( 'html' ,'' , '', '', '' ) . "\n<head>\n";
2c21ef20 30
a714cb95 31 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
692155b7 32 if ($theme_css != '') {
d68323ff 33 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
692155b7 34 }
8f1ba72b 35 } else {
d68323ff 36 echo '<link rel="stylesheet" type="text/css" href="' .
37 $base_uri . 'themes/css/'.$custom_css.'" />';
8f1ba72b 38 }
85f4ce52 39
e842b215 40 if ($squirrelmail_language == 'ja_JP') {
41 echo "<!-- \xfd\xfe -->\n";
42 echo '<meta http-equuiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
43 }
44
237470b4 45 if ($do_hook) {
d68323ff 46 do_hook('generic_header');
237470b4 47 }
8f1ba72b 48
5ca4b1ee 49 echo "\n<title>$title</title>$xtra\n";
50
51 /* work around IE6's scrollbar bug */
52 echo <<<ECHO
53<style type="text/css">
54<!--
55 /* avoid stupid IE6 bug with frames and scrollbars */
56 body {
57 voice-family: "\"}\"";
58 voice-family: inherit;
59 width: expression(document.documentElement.clientWidth - 30);
60 }
61-->
62</style>
63
64ECHO;
65
66 echo "\n</head>\n\n";
a07cd1a4 67}
68
85f4ce52 69
a07cd1a4 70function displayInternalLink($path, $text, $target='') {
0365891c 71 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
a07cd1a4 72 if ($target != '') {
73 $target = " target=\"$target\"";
74 }
a07cd1a4 75 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
76}
77
aca403fa 78function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
715225af 79
0b97a708 80 global $hide_sm_attributions, $PHP_SELF, $frame_top,
1ba8cd6b 81 $compose_new_win, $compose_width, $compose_height,
735f6b9c 82 $attachemessages, $provider_name, $provider_uri;
715225af 83
0365891c 84 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
85 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
715225af 86 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
f3e14140 87 if ($qmark = strpos($module, '?')) {
88 $module = substr($module, 0, $qmark);
89 }
d03f3582 90 if (!isset($frame_top)) {
91 $frame_top = '_top';
92 }
715225af 93
735f6b9c 94 if ($session) {
d68323ff 95 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
aca403fa 96 } else {
087ce5f8 97 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
d7f8e6e6 98 $session = 0;
aca403fa 99 }
cb6b53c6 100
715225af 101 switch ( $module ) {
f3e14140 102 case 'src/read_body.php':
087ce5f8 103 $js ='';
f3e14140 104 if ($compose_new_win == '1') {
105 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
106 $compose_width = '640';
107 }
108 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
109 $compose_height = '550';
110 }
087ce5f8 111 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
f3e14140 112 "\n<!--\n";
087ce5f8 113 $js .= "function comp_in_new(comp_uri) {\n".
114 " if (!comp_uri) {\n".
115 ' comp_uri = "'.$compose_uri."\";\n".
d7f8e6e6 116 ' }'. "\n".
d7f8e6e6 117 ' var newwin = window.open(comp_uri' .
087ce5f8 118 ', "_blank",'.
119 '"width='.$compose_width. ',height='.$compose_height.
602b2bdf 120 ',scrollbars=yes,resizable=yes");'."\n".
087ce5f8 121 "}\n\n";
d7f8e6e6 122
087ce5f8 123
124 $js .= 'function sendMDN() {'."\n".
125 "mdnuri=window.location+'&sendreceipt=1';".
126 "var newwin = window.open(mdnuri,'right');".
127 "\n}\n\n";
128
129 $js .= "// -->\n".
130 "</script>\n";
131
132 }
5e8de8b6 133 displayHtmlHeader ('SquirrelMail', $js);
087ce5f8 134 $onload = $xtra;
f3e14140 135 break;
d7f8e6e6 136 case 'src/compose.php':
137 $js = '<script language="JavaScript" type="text/javascript">' .
138 "\n<!--\n" .
139 "function checkForm() {\n".
140 "var f = document.forms.length;\n".
141 "var i = 0;\n".
142 "var pos = -1;\n".
143 "while( pos == -1 && i < f ) {\n".
144 "var e = document.forms[i].elements.length;\n".
145 "var j = 0;\n".
146 "while( pos == -1 && j < e ) {\n".
147 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
148 "pos = j;\n".
149 "}\n".
150 "j++;\n".
151 "}\n".
152 "i++;\n".
153 "}\n".
154 "if( pos >= 0 ) {\n".
155 "document.forms[i-1].elements[pos].focus();\n".
156 "}\n".
157 "}\n";
158
159 $js .= "// -->\n".
160 "</script>\n";
d68323ff 161 $onload = 'onload="checkForm();"';
5e8de8b6 162 displayHtmlHeader ('SquirrelMail', $js);
d7f8e6e6 163 break;
164
715225af 165 default:
aaf16822 166 $js = '<script language="JavaScript" type="text/javascript">' .
353616c4 167 "\n<!--\n" .
168 "function checkForm() {\n".
169 "var f = document.forms.length;\n".
170 "var i = 0;\n".
171 "var pos = -1;\n".
172 "while( pos == -1 && i < f ) {\n".
173 "var e = document.forms[i].elements.length;\n".
174 "var j = 0;\n".
175 "while( pos == -1 && j < e ) {\n".
5ca05f19 176 "if ( document.forms[i].elements[j].type == 'text' " .
177 "|| document.forms[i].elements[j].type == 'password' ) {\n".
353616c4 178 "pos = j;\n".
179 "}\n".
180 "j++;\n".
181 "}\n".
182 "i++;\n".
183 "}\n".
184 "if( pos >= 0 ) {\n".
185 "document.forms[i-1].elements[pos].focus();\n".
186 "}\n".
de19cd73 187 "$xtra\n".
9c3e6cd4 188 "}\n";
f3e14140 189
9c3e6cd4 190 if ($compose_new_win == '1') {
07687736 191 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
192 $compose_width = '640';
9c3e6cd4 193 }
07687736 194 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
195 $compose_height = '550';
9c3e6cd4 196 }
087ce5f8 197 $js .= "function comp_in_new(comp_uri) {\n".
198 " if (!comp_uri) {\n".
199 ' comp_uri = "'.$compose_uri."\";\n".
d7f8e6e6 200 ' }'. "\n".
d7f8e6e6 201 ' var newwin = window.open(comp_uri' .
087ce5f8 202 ', "_blank",'.
203 '"width='.$compose_width. ',height='.$compose_height.
602b2bdf 204 ',scrollbars=yes,resizable=yes");'."\n".
087ce5f8 205 "}\n\n";
206
9c3e6cd4 207 }
087ce5f8 208 $js .= "// -->\n". "</script>\n";
0cba960a 209
210
d68323ff 211 $onload = 'onload="checkForm();"';
5e8de8b6 212 displayHtmlHeader ('SquirrelMail', $js);
715225af 213 break;
214
215 }
216
b01b21d0 217 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
a07cd1a4 218 /** Here is the header and wrapping table **/
f3e14140 219 $shortBoxName = imap_utf7_decode_local(
220 readShortMailboxName($mailbox, $delimiter));
3b7d68e6 221 if ( $shortBoxName == 'INBOX' ) {
7da23762 222 $shortBoxName = _("INBOX");
223 }
b01b21d0 224 echo "<a name=\"pagetop\"></a>\n"
225 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
226 . html_tag( 'tr', '', '', $color[9] ) ."\n"
227 . html_tag( 'td', '', 'left' ) ."\n";
5bb2a991 228 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
b01b21d0 229 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
5bb2a991 230 } else {
231 echo '&nbsp;';
232 }
b01b21d0 233 echo " </td>\n"
234 . html_tag( 'td', '', 'right' ) ."<b>\n";
80e86e94 235 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
b01b21d0 236 echo "</b></td>\n"
237 . " </tr>\n"
238 . html_tag( 'tr', '', '', $color[4] ) ."\n"
239 . html_tag( 'td', '', 'left' ) ."\n";
a07cd1a4 240 $urlMailbox = urlencode($mailbox);
9c3e6cd4 241 if ($compose_new_win == '1') {
d68323ff 242 echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
9c3e6cd4 243 }
244 else {
245 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
246 }
a07cd1a4 247 echo "&nbsp;&nbsp;\n";
d68323ff 248 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
a07cd1a4 249 echo "&nbsp;&nbsp;\n";
d68323ff 250 displayInternalLink ('src/folders.php', _("Folders"), 'right');
a07cd1a4 251 echo "&nbsp;&nbsp;\n";
d68323ff 252 displayInternalLink ('src/options.php', _("Options"), 'right');
a07cd1a4 253 echo "&nbsp;&nbsp;\n";
254 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
255 echo "&nbsp;&nbsp;\n";
d68323ff 256 displayInternalLink ('src/help.php', _("Help"), 'right');
a07cd1a4 257 echo "&nbsp;&nbsp;\n";
258
d68323ff 259 do_hook('menuline');
a07cd1a4 260
b01b21d0 261 echo " </td>\n"
262 . html_tag( 'td', '', 'right' ) ."\n";
1f2eaa02 263 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
264 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
a07cd1a4 265 echo ($hide_sm_attributions ? '&nbsp;' :
1f2eaa02 266 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
b01b21d0 267 echo "</td>\n".
268 " </tr>\n".
6206f6c4 269 "</table><br>\n\n";
a07cd1a4 270}
2ba13803 271
9c3e6cd4 272/* blatently copied/truncated/modified from the above function */
273function compose_Header($color, $mailbox) {
274
1ba8cd6b 275 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF,
276 $data_dir, $username, $frame_top, $compose_new_win;
9c3e6cd4 277
9c3e6cd4 278
279 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
280 if (!isset($frame_top)) {
281 $frame_top = '_top';
282 }
283
284 /*
285 Locate the first displayable form element
286 */
287 switch ( $module ) {
288 case 'src/search.php':
289 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
d68323ff 290 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
aaf16822 291 displayHtmlHeader (_("Compose"));
9c3e6cd4 292 break;
293 default:
aaf16822 294 $js = '<script language="JavaScript" type="text/javascript">' .
9c3e6cd4 295 "\n<!--\n" .
296 "function checkForm() {\n".
297 "var f = document.forms.length;\n".
298 "var i = 0;\n".
299 "var pos = -1;\n".
300 "while( pos == -1 && i < f ) {\n".
301 "var e = document.forms[i].elements.length;\n".
302 "var j = 0;\n".
303 "while( pos == -1 && j < e ) {\n".
304 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
305 "pos = j;\n".
306 "}\n".
307 "j++;\n".
308 "}\n".
309 "i++;\n".
310 "}\n".
311 "if( pos >= 0 ) {\n".
312 "document.forms[i-1].elements[pos].focus();\n".
313 "}\n".
314 "}\n";
aaf16822 315 $js .= "// -->\n".
de19cd73 316 "</script>\n";
d68323ff 317 $onload = 'onload="checkForm();"';
aaf16822 318 displayHtmlHeader (_("Compose"), $js);
9c3e6cd4 319 break;
320
321 }
322
b01b21d0 323 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
9c3e6cd4 324}
e842b215 325
326?>