Use a consistent capitalization of "SquirrelMail" throughout the application.
[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(SM_PATH . 'functions/strings.php');
15 require_once(SM_PATH . 'functions/html.php');
16 require_once(SM_PATH . 'functions/imap_mailbox.php');
17 require_once(SM_PATH . 'functions/global.php');
18
19 /* Always set up the language before calling these functions */
20 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
21
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;
32
33 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
34 "\n\n<HTML>\n<HEAD>\n";
35
36 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
37 if ($theme_css != '') {
38 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
39 }
40 } else {
41 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
42 $base_uri . 'themes/css/'.$custom_css.'">';
43 }
44
45 if ($do_hook) {
46 do_hook("generic_header");
47 }
48
49 echo "\n<title>$title</title>$xtra</head>\n\n";
50 }
51
52
53 function displayInternalLink($path, $text, $target='') {
54 if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) {
55 global $_SESSION;
56 }
57
58 $base_uri = $_SESSION['base_uri'];
59 if ($target != '') {
60 $target = " target=\"$target\"";
61 }
62 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
63 }
64
65 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
66
67 global $hide_sm_attributions, $PHP_SELF, $frame_top,
68 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
69 $attachemessages, $provider_name, $provider_uri;
70
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'];
77 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
78 if ($qmark = strpos($module, '?')) {
79 $module = substr($module, 0, $qmark);
80 }
81 if (!isset($frame_top)) {
82 $frame_top = '_top';
83 }
84
85 if ($session) {
86 $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
87 } else {
88 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
89 $session = 0;
90 }
91
92 switch ( $module ) {
93 case 'src/read_body.php':
94 $js ='';
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 }
102 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
103 "\n<!--\n";
104 $js .= "function comp_in_new(comp_uri) {\n".
105 " if (!comp_uri) {\n".
106 ' comp_uri = "'.$compose_uri."\";\n".
107 ' }'. "\n".
108 ' var newwin = window.open(comp_uri' .
109 ', "_blank",'.
110 '"width='.$compose_width. ',height='.$compose_height.
111 ',scrollbars=yes,resizable=yes");'."\n".
112 "}\n\n";
113
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;
126 break;
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
156 default:
157 $js = '<script language="JavaScript" type="text/javascript">' .
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".
177 "$xtra\n".
178 "}\n";
179
180 if ($compose_new_win == '1') {
181 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
182 $compose_width = '640';
183 }
184 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
185 $compose_height = '550';
186 }
187 $js .= "function comp_in_new(comp_uri) {\n".
188 " if (!comp_uri) {\n".
189 ' comp_uri = "'.$compose_uri."\";\n".
190 ' }'. "\n".
191 ' var newwin = window.open(comp_uri' .
192 ', "_blank",'.
193 '"width='.$compose_width. ',height='.$compose_height.
194 ',scrollbars=yes,resizable=yes");'."\n".
195 "}\n\n";
196
197 }
198 $js .= "// -->\n". "</script>\n";
199
200
201 $onload = "onLoad=\"checkForm();\"";
202 displayHtmlHeader ('SquirrelMail', $js);
203 break;
204
205 }
206
207 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
208 /** Here is the header and wrapping table **/
209 $shortBoxName = imap_utf7_decode_local(
210 readShortMailboxName($mailbox, $delimiter));
211 if ( $shortBoxName == 'INBOX' ) {
212 $shortBoxName = _("INBOX");
213 }
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";
218 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
219 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
220 } else {
221 echo '&nbsp;';
222 }
223 echo " </td>\n"
224 . html_tag( 'td', '', 'right' ) ."<b>\n";
225 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
226 echo "</b></td>\n"
227 . " </tr>\n"
228 . html_tag( 'tr', '', '', $color[4] ) ."\n"
229 . html_tag( 'td', '', 'left' ) ."\n";
230 $urlMailbox = urlencode($mailbox);
231 if ($compose_new_win == '1') {
232 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>';
233 }
234 else {
235 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
236 }
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
251 echo " </td>\n"
252 . html_tag( 'td', '', 'right' ) ."\n";
253 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
254 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
255 echo ($hide_sm_attributions ? '&nbsp;' :
256 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
257 echo "</td>\n".
258 " </tr>\n".
259 "</table><br>\n\n";
260 }
261
262 /* blatently copied/truncated/modified from the above function */
263 function compose_Header($color, $mailbox) {
264
265 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
266
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();\"";
280 displayHtmlHeader (_("Compose"));
281 break;
282 default:
283 $js = '<script language="JavaScript" type="text/javascript">' .
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";
304 $js .= "// -->\n".
305 "</script>\n";
306 $onload = "onLoad=\"checkForm();\"";
307 displayHtmlHeader (_("Compose"), $js);
308 break;
309
310 }
311
312 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
313 }
314 ?>