6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Prints the page header (duh)
12 * @package squirrelmail
15 /** Include required files from SM */
16 require_once(SM_PATH
. 'functions/strings.php');
17 require_once(SM_PATH
. 'functions/html.php');
18 require_once(SM_PATH
. 'functions/imap_mailbox.php');
19 require_once(SM_PATH
. 'functions/global.php');
22 * Always set up the language before calling these functions
24 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
25 global $squirrelmail_language;
27 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
30 global $theme_css, $custom_css, $pageheader_sent;
32 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
33 "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . "\n<head>\n";
35 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
36 if ($theme_css != '') {
37 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
40 echo '<link rel="stylesheet" type="text/css" href="' .
41 $base_uri . 'themes/css/'.$custom_css.'" />';
44 if ($squirrelmail_language == 'ja_JP') {
45 echo "<!-- \xfd\xfe -->\n";
46 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
50 do_hook('generic_header');
53 echo "\n<title>$title</title>$xtra\n";
55 /* work around IE6's scrollbar bug */
57 <style type="text/css">
59 /* avoid stupid IE6 bug with frames and scrollbars */
61 voice-family: "\"}\"";
62 voice-family: inherit;
63 width: expression(document.documentElement.clientWidth - 30);
72 /* this is used to check elsewhere whether we should call this function */
73 $pageheader_sent = TRUE;
76 function makeInternalLink($path, $text, $target='') {
77 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
79 $target = " target=\"$target\"";
81 $hooktext = do_hook_function('internal_link',$text);
84 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
87 function displayInternalLink($path, $text, $target='') {
88 echo makeInternalLink($path, $text, $target);
91 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
93 global $hide_sm_attributions, $PHP_SELF, $frame_top,
94 $compose_new_win, $compose_width, $compose_height,
95 $attachemessages, $provider_name, $provider_uri,
96 $javascript_on, $default_use_mdn, $mdn_user_support;
98 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
99 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
100 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
101 if ($qmark = strpos($module, '?')) {
102 $module = substr($module, 0, $qmark);
104 if (!isset($frame_top)) {
109 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
111 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
118 case 'src/read_body.php':
121 // compose in new window code
122 if ($compose_new_win == '1') {
123 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
124 $compose_width = '640';
126 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
127 $compose_height = '550';
129 $js .= "function comp_in_new(comp_uri) {\n".
130 " if (!comp_uri) {\n".
131 ' comp_uri = "'.$compose_uri."\";\n".
133 ' var newwin = window.open(comp_uri' .
135 '"width='.$compose_width. ',height='.$compose_height.
136 ',scrollbars=yes,resizable=yes");'."\n".
140 // javascript for sending read receipts
141 if($default_use_mdn && $mdn_user_support) {
142 $js .= 'function sendMDN() {'."\n".
143 " mdnuri=window.location+'&sendreceipt=1'; ".
144 "var newwin = window.open(mdnuri,'right');".
148 // if any of the above passes, add the JS tags too.
150 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
151 "\n<!--\n" . $js . "// -->\n</script>\n";
154 displayHtmlHeader ('SquirrelMail', $js);
157 case 'src/compose.php':
158 $js = '<script language="JavaScript" type="text/javascript">' .
160 "function checkForm() {\n";
162 global $action, $reply_focus;
163 if (strpos($action, 'reply') !== FALSE && $reply_focus)
165 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
166 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
169 $js .= "var f = document.forms.length;\n".
172 "while( pos == -1 && i < f ) {\n".
173 "var e = document.forms[i].elements.length;\n".
175 "while( pos == -1 && j < e ) {\n".
176 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
183 "if( pos >= 0 ) {\n".
184 "document.forms[i-1].elements[pos].focus();\n".
190 $onload = 'onload="checkForm();"';
191 displayHtmlHeader ('SquirrelMail', $js);
195 $js = '<script language="JavaScript" type="text/javascript">' .
197 "function checkForm() {\n".
198 "var f = document.forms.length;\n".
201 "while( pos == -1 && i < f ) {\n".
202 "var e = document.forms[i].elements.length;\n".
204 "while( pos == -1 && j < e ) {\n".
205 "if ( document.forms[i].elements[j].type == 'text' " .
206 "|| document.forms[i].elements[j].type == 'password' ) {\n".
213 "if( pos >= 0 ) {\n".
214 "document.forms[i-1].elements[pos].focus();\n".
219 if ($compose_new_win == '1') {
220 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
221 $compose_width = '640';
223 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
224 $compose_height = '550';
226 $js .= "function comp_in_new(comp_uri) {\n".
227 " if (!comp_uri) {\n".
228 ' comp_uri = "'.$compose_uri."\";\n".
230 ' var newwin = window.open(comp_uri' .
232 '"width='.$compose_width. ',height='.$compose_height.
233 ',scrollbars=yes,resizable=yes");'."\n".
237 $js .= "// -->\n". "</script>\n";
239 $onload = 'onload="checkForm();"';
240 displayHtmlHeader ('SquirrelMail', $js);
245 /* do not use JavaScript */
246 displayHtmlHeader ('SquirrelMail');
250 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
251 /** Here is the header and wrapping table **/
252 $shortBoxName = imap_utf7_decode_local(
253 readShortMailboxName($mailbox, $delimiter));
254 if ( $shortBoxName == 'INBOX' ) {
255 $shortBoxName = _("INBOX");
257 echo "<a name=\"pagetop\"></a>\n"
258 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
259 . html_tag( 'tr', '', '', $color[9] ) ."\n"
260 . html_tag( 'td', '', 'left' ) ."\n";
261 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
262 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
267 . html_tag( 'td', '', 'right' ) ."<b>\n";
268 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
271 . html_tag( 'tr', '', '', $color[4] ) ."\n"
272 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
273 : html_tag( 'td', '', 'left' ) )
275 $urlMailbox = urlencode($mailbox);
276 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox);
277 echo " \n";
278 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
279 echo " \n";
280 displayInternalLink ('src/folders.php', _("Folders"), 'right');
281 echo " \n";
282 displayInternalLink ('src/options.php', _("Options"), 'right');
283 echo " \n";
284 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
285 echo " \n";
286 displayInternalLink ('src/help.php', _("Help"), 'right');
287 echo " \n";
293 if (!$hide_sm_attributions)
295 echo html_tag( 'td', '', 'right' ) ."\n";
296 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
297 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
298 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
305 /* blatently copied/truncated/modified from the above function */
306 function compose_Header($color, $mailbox) {
308 global $javascript_on;
311 * Locate the first displayable form element (only when JavaScript on)
314 global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
316 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
319 case 'src/search.php':
320 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
321 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
322 displayHtmlHeader (_("Compose"));
325 $js = '<script language="JavaScript" type="text/javascript">' .
327 "function checkForm() {\n";
329 global $action, $reply_focus;
330 if (strpos($action, 'reply') !== FALSE && $reply_focus)
332 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
333 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
336 $js .= "var f = document.forms.length;\n".
339 "while( pos == -1 && i < f ) {\n".
340 "var e = document.forms[i].elements.length;\n".
342 "while( pos == -1 && j < e ) {\n".
343 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
350 "if( pos >= 0 ) {\n".
351 "document.forms[i-1].elements[pos].focus();\n".
356 $onload = 'onload="checkForm();"';
357 displayHtmlHeader (_("Compose"), $js);
362 displayHtmlHeader(_("Compose"));
366 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";