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);
70 function displayInternalLink($path, $text, $target='') {
71 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
73 $target = " target=\"$target\"";
75 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
78 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
80 global $hide_sm_attributions, $PHP_SELF, $frame_top,
81 $compose_new_win, $compose_width, $compose_height,
82 $attachemessages, $provider_name, $provider_uri;
84 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
85 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
86 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
87 if ($qmark = strpos($module, '?')) {
88 $module = substr($module, 0, $qmark);
90 if (!isset($frame_top)) {
95 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
97 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
102 case 'src/read_body.php':
104 if ($compose_new_win == '1') {
105 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
106 $compose_width = '640';
108 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
109 $compose_height = '550';
111 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
113 $js .= "function comp_in_new(comp_uri) {\n".
114 " if (!comp_uri) {\n".
115 ' comp_uri = "'.$compose_uri."\";\n".
117 ' var newwin = window.open(comp_uri' .
119 '"width='.$compose_width. ',height='.$compose_height.
120 ',scrollbars=yes,resizable=yes");'."\n".
124 $js .= 'function sendMDN() {'."\n".
125 "mdnuri=window.location+'&sendreceipt=1';".
126 "var newwin = window.open(mdnuri,'right');".
133 displayHtmlHeader ('SquirrelMail', $js);
136 case 'src/compose.php':
137 $js = '<script language="JavaScript" type="text/javascript">' .
139 "function checkForm() {\n".
140 "var f = document.forms.length;\n".
143 "while( pos == -1 && i < f ) {\n".
144 "var e = document.forms[i].elements.length;\n".
146 "while( pos == -1 && j < e ) {\n".
147 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
154 "if( pos >= 0 ) {\n".
155 "document.forms[i-1].elements[pos].focus();\n".
161 $onload = 'onload="checkForm();"';
162 displayHtmlHeader ('SquirrelMail', $js);
166 $js = '<script language="JavaScript" type="text/javascript">' .
168 "function checkForm() {\n".
169 "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".
189 if ($compose_new_win == '1') {
190 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
191 $compose_width = '640';
193 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
194 $compose_height = '550';
196 $js .= "function comp_in_new(comp_uri) {\n".
197 " if (!comp_uri) {\n".
198 ' comp_uri = "'.$compose_uri."\";\n".
200 ' var newwin = window.open(comp_uri' .
202 '"width='.$compose_width. ',height='.$compose_height.
203 ',scrollbars=yes,resizable=yes");'."\n".
207 $js .= "// -->\n". "</script>\n";
210 $onload = 'onload="checkForm();"';
211 displayHtmlHeader ('SquirrelMail', $js);
216 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
217 /** Here is the header and wrapping table **/
218 $shortBoxName = imap_utf7_decode_local(
219 readShortMailboxName($mailbox, $delimiter));
220 if ( $shortBoxName == 'INBOX' ) {
221 $shortBoxName = _("INBOX");
223 echo "<a name=\"pagetop\"></a>\n"
224 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
225 . html_tag( 'tr', '', '', $color[9] ) ."\n"
226 . html_tag( 'td', '', 'left' ) ."\n";
227 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
228 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
233 . html_tag( 'td', '', 'right' ) ."<b>\n";
234 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
237 . html_tag( 'tr', '', '', $color[4] ) ."\n"
238 . html_tag( 'td', '', 'left' ) ."\n";
239 $urlMailbox = urlencode($mailbox);
240 if ($compose_new_win == '1') {
241 echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
244 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
246 echo " \n";
247 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
248 echo " \n";
249 displayInternalLink ('src/folders.php', _("Folders"), 'right');
250 echo " \n";
251 displayInternalLink ('src/options.php', _("Options"), 'right');
252 echo " \n";
253 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
254 echo " \n";
255 displayInternalLink ('src/help.php', _("Help"), 'right');
256 echo " \n";
261 . html_tag( 'td', '', 'right' ) ."\n";
262 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
263 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
264 echo ($hide_sm_attributions ?
' ' :
265 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
271 /* blatently copied/truncated/modified from the above function */
272 function compose_Header($color, $mailbox) {
274 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF,
275 $data_dir, $username, $frame_top, $compose_new_win;
278 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
279 if (!isset($frame_top)) {
284 Locate the first displayable form element
287 case 'src/search.php':
288 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
289 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
290 displayHtmlHeader (_("Compose"));
293 $js = '<script language="JavaScript" type="text/javascript">' .
295 "function checkForm() {\n".
296 "var f = document.forms.length;\n".
299 "while( pos == -1 && i < f ) {\n".
300 "var e = document.forms[i].elements.length;\n".
302 "while( pos == -1 && j < e ) {\n".
303 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
310 "if( pos >= 0 ) {\n".
311 "document.forms[i-1].elements[pos].focus();\n".
316 $onload = 'onload="checkForm();"';
317 displayHtmlHeader (_("Compose"), $js);
322 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";