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)
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');
19 /* Always set up the language before calling these functions */
20 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
21 global $squirrelmail_language;
23 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
26 global $theme_css, $custom_css, $pageheader_sent;
28 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
29 "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . "\n<head>\n";
31 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
32 if ($theme_css != '') {
33 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
36 echo '<link rel="stylesheet" type="text/css" href="' .
37 $base_uri . 'themes/css/'.$custom_css.'" />';
40 if ($squirrelmail_language == 'ja_JP') {
41 echo "<!-- \xfd\xfe -->\n";
42 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
46 do_hook('generic_header');
49 echo "\n<title>$title</title>$xtra\n";
51 /* work around IE6's scrollbar bug */
53 <style type="text/css">
55 /* avoid stupid IE6 bug with frames and scrollbars */
57 voice-family: "\"}\"";
58 voice-family: inherit;
59 width: expression(document.documentElement.clientWidth - 30);
68 /* this is used to check elsewhere whether we should call this function */
69 $pageheader_sent = TRUE;
72 function makeInternalLink($path, $text, $target='') {
73 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
75 $target = " target=\"$target\"";
77 $hooktext = do_hook_function('internal_link',$text);
80 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
83 function displayInternalLink($path, $text, $target='') {
84 echo makeInternalLink($path, $text, $target);
87 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
89 global $hide_sm_attributions, $PHP_SELF, $frame_top,
90 $compose_new_win, $compose_width, $compose_height,
91 $attachemessages, $provider_name, $provider_uri,
92 $javascript_on, $default_use_mdn, $mdn_user_support;
94 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
95 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
96 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
97 if ($qmark = strpos($module, '?')) {
98 $module = substr($module, 0, $qmark);
100 if (!isset($frame_top)) {
105 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
107 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
114 case 'src/read_body.php':
117 // compose in new window code
118 if ($compose_new_win == '1') {
119 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
120 $compose_width = '640';
122 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
123 $compose_height = '550';
125 $js .= "function comp_in_new(comp_uri) {\n".
126 " if (!comp_uri) {\n".
127 ' comp_uri = "'.$compose_uri."\";\n".
129 ' var newwin = window.open(comp_uri' .
131 '"width='.$compose_width. ',height='.$compose_height.
132 ',scrollbars=yes,resizable=yes");'."\n".
136 // javascript for sending read receipts
137 if($default_use_mdn && $mdn_user_support) {
138 $js .= 'function sendMDN() {'."\n".
139 " mdnuri=window.location+'&sendreceipt=1'; ".
140 "var newwin = window.open(mdnuri,'right');".
144 // if any of the above passes, add the JS tags too.
146 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
147 "\n<!--\n" . $js . "// -->\n</script>\n";
150 displayHtmlHeader ('SquirrelMail', $js);
153 case 'src/compose.php':
154 $js = '<script language="JavaScript" type="text/javascript">' .
156 "function checkForm() {\n".
157 "var f = document.forms.length;\n".
160 "while( pos == -1 && i < f ) {\n".
161 "var e = document.forms[i].elements.length;\n".
163 "while( pos == -1 && j < e ) {\n".
164 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
171 "if( pos >= 0 ) {\n".
172 "document.forms[i-1].elements[pos].focus();\n".
178 $onload = 'onload="checkForm();"';
179 displayHtmlHeader ('SquirrelMail', $js);
183 $js = '<script language="JavaScript" type="text/javascript">' .
185 "function checkForm() {\n".
186 "var f = document.forms.length;\n".
189 "while( pos == -1 && i < f ) {\n".
190 "var e = document.forms[i].elements.length;\n".
192 "while( pos == -1 && j < e ) {\n".
193 "if ( document.forms[i].elements[j].type == 'text' " .
194 "|| document.forms[i].elements[j].type == 'password' ) {\n".
201 "if( pos >= 0 ) {\n".
202 "document.forms[i-1].elements[pos].focus();\n".
207 if ($compose_new_win == '1') {
208 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
209 $compose_width = '640';
211 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
212 $compose_height = '550';
214 $js .= "function comp_in_new(comp_uri) {\n".
215 " if (!comp_uri) {\n".
216 ' comp_uri = "'.$compose_uri."\";\n".
218 ' var newwin = window.open(comp_uri' .
220 '"width='.$compose_width. ',height='.$compose_height.
221 ',scrollbars=yes,resizable=yes");'."\n".
225 $js .= "// -->\n". "</script>\n";
227 $onload = 'onload="checkForm();"';
228 displayHtmlHeader ('SquirrelMail', $js);
233 /* do not use JavaScript */
234 displayHtmlHeader ('SquirrelMail');
238 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
239 /** Here is the header and wrapping table **/
240 $shortBoxName = imap_utf7_decode_local(
241 readShortMailboxName($mailbox, $delimiter));
242 if ( $shortBoxName == 'INBOX' ) {
243 $shortBoxName = _("INBOX");
245 echo "<a name=\"pagetop\"></a>\n"
246 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
247 . html_tag( 'tr', '', '', $color[9] ) ."\n"
248 . html_tag( 'td', '', 'left' ) ."\n";
249 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
250 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
255 . html_tag( 'td', '', 'right' ) ."<b>\n";
256 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
259 . html_tag( 'tr', '', '', $color[4] ) ."\n"
260 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
261 : html_tag( 'td', '', 'left' ) )
263 $urlMailbox = urlencode($mailbox);
264 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox);
265 echo " \n";
266 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
267 echo " \n";
268 displayInternalLink ('src/folders.php', _("Folders"), 'right');
269 echo " \n";
270 displayInternalLink ('src/options.php', _("Options"), 'right');
271 echo " \n";
272 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
273 echo " \n";
274 displayInternalLink ('src/help.php', _("Help"), 'right');
275 echo " \n";
281 if (!$hide_sm_attributions)
283 echo html_tag( 'td', '', 'right' ) ."\n";
284 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
285 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
286 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
293 /* blatently copied/truncated/modified from the above function */
294 function compose_Header($color, $mailbox) {
296 global $javascript_on;
299 * Locate the first displayable form element (only when JavaScript on)
302 global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
304 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
307 case 'src/search.php':
308 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
309 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
310 displayHtmlHeader (_("Compose"));
313 $js = '<script language="JavaScript" type="text/javascript">' .
315 "function checkForm() {\n".
316 "var f = document.forms.length;\n".
319 "while( pos == -1 && i < f ) {\n".
320 "var e = document.forms[i].elements.length;\n".
322 "while( pos == -1 && j < e ) {\n".
323 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
330 "if( pos >= 0 ) {\n".
331 "document.forms[i-1].elements[pos].focus();\n".
336 $onload = 'onload="checkForm();"';
337 displayHtmlHeader (_("Compose"), $js);
342 displayHtmlHeader(_("Compose"));
346 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";