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;
28 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
29 "\n\n" . html_tag( 'html' ,'' , '', '', '' ) . "\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-equuiv="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);
69 function makeInternalLink($path, $text, $target='') {
70 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
72 $target = " target=\"$target\"";
74 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
77 function displayInternalLink($path, $text, $target='') {
78 echo makeInternalLink($path, $text, $target);
81 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
83 global $hide_sm_attributions, $PHP_SELF, $frame_top,
84 $compose_new_win, $compose_width, $compose_height,
85 $attachemessages, $provider_name, $provider_uri,
88 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
89 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
90 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
91 if ($qmark = strpos($module, '?')) {
92 $module = substr($module, 0, $qmark);
94 if (!isset($frame_top)) {
99 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
101 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
108 case 'src/read_body.php':
110 if ($compose_new_win == '1') {
111 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
112 $compose_width = '640';
114 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
115 $compose_height = '550';
117 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
119 $js .= "function comp_in_new(comp_uri) {\n".
120 " if (!comp_uri) {\n".
121 ' comp_uri = "'.$compose_uri."\";\n".
123 ' var newwin = window.open(comp_uri' .
125 '"width='.$compose_width. ',height='.$compose_height.
126 ',scrollbars=yes,resizable=yes");'."\n".
130 $js .= 'function sendMDN() {'."\n".
131 "mdnuri=window.location+'&sendreceipt=1';".
132 "var newwin = window.open(mdnuri,'right');".
139 displayHtmlHeader ('SquirrelMail', $js);
142 case 'src/compose.php':
143 $js = '<script language="JavaScript" type="text/javascript">' .
145 "function checkForm() {\n".
146 "var f = document.forms.length;\n".
149 "while( pos == -1 && i < f ) {\n".
150 "var e = document.forms[i].elements.length;\n".
152 "while( pos == -1 && j < e ) {\n".
153 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
160 "if( pos >= 0 ) {\n".
161 "document.forms[i-1].elements[pos].focus();\n".
167 $onload = 'onload="checkForm();"';
168 displayHtmlHeader ('SquirrelMail', $js);
172 $js = '<script language="JavaScript" type="text/javascript">' .
174 "function checkForm() {\n".
175 "var f = document.forms.length;\n".
178 "while( pos == -1 && i < f ) {\n".
179 "var e = document.forms[i].elements.length;\n".
181 "while( pos == -1 && j < e ) {\n".
182 "if ( document.forms[i].elements[j].type == 'text' " .
183 "|| document.forms[i].elements[j].type == 'password' ) {\n".
190 "if( pos >= 0 ) {\n".
191 "document.forms[i-1].elements[pos].focus();\n".
196 if ($compose_new_win == '1') {
197 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
198 $compose_width = '640';
200 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
201 $compose_height = '550';
203 $js .= "function comp_in_new(comp_uri) {\n".
204 " if (!comp_uri) {\n".
205 ' comp_uri = "'.$compose_uri."\";\n".
207 ' var newwin = window.open(comp_uri' .
209 '"width='.$compose_width. ',height='.$compose_height.
210 ',scrollbars=yes,resizable=yes");'."\n".
214 $js .= "// -->\n". "</script>\n";
216 $onload = 'onload="checkForm();"';
217 displayHtmlHeader ('SquirrelMail', $js);
222 /* do not use JavaScript */
223 displayHtmlHeader ('SquirrelMail');
227 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
228 /** Here is the header and wrapping table **/
229 $shortBoxName = imap_utf7_decode_local(
230 readShortMailboxName($mailbox, $delimiter));
231 if ( $shortBoxName == 'INBOX' ) {
232 $shortBoxName = _("INBOX");
234 echo "<a name=\"pagetop\"></a>\n"
235 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
236 . html_tag( 'tr', '', '', $color[9] ) ."\n"
237 . html_tag( 'td', '', 'left' ) ."\n";
238 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
239 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
244 . html_tag( 'td', '', 'right' ) ."<b>\n";
245 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
248 . html_tag( 'tr', '', '', $color[4] ) ."\n"
249 . html_tag( 'td', '', 'left' ) ."\n";
250 $urlMailbox = urlencode($mailbox);
251 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox);
252 echo " \n";
253 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
254 echo " \n";
255 displayInternalLink ('src/folders.php', _("Folders"), 'right');
256 echo " \n";
257 displayInternalLink ('src/options.php', _("Options"), 'right');
258 echo " \n";
259 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
260 echo " \n";
261 displayInternalLink ('src/help.php', _("Help"), 'right');
262 echo " \n";
267 . html_tag( 'td', '', 'right' ) ."\n";
268 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
269 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
270 echo ($hide_sm_attributions ?
' ' :
271 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
277 /* blatently copied/truncated/modified from the above function */
278 function compose_Header($color, $mailbox) {
280 global $javascript_on;
283 * Locate the first displayable form element (only when JavaScript on)
286 global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
288 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
291 case 'src/search.php':
292 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
293 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
294 displayHtmlHeader (_("Compose"));
297 $js = '<script language="JavaScript" type="text/javascript">' .
299 "function checkForm() {\n".
300 "var f = document.forms.length;\n".
303 "while( pos == -1 && i < f ) {\n".
304 "var e = document.forms[i].elements.length;\n".
306 "while( pos == -1 && j < e ) {\n".
307 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
314 "if( pos >= 0 ) {\n".
315 "document.forms[i-1].elements[pos].focus();\n".
320 $onload = 'onload="checkForm();"';
321 displayHtmlHeader (_("Compose"), $js);
326 displayHtmlHeader(_("Compose"));
330 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";