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