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