6 * Copyright (c) 1999-2002 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 ) {
22 if ( !check_php_version(4,1) ) {
25 if (isset($_SESSION['base_uri'])) {
26 $base_uri = $_SESSION['base_uri'];
31 global $theme_css, $custom_css;
33 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
34 "\n\n<HTML>\n<HEAD>\n";
36 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
37 if ($theme_css != '') {
38 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
41 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
42 $base_uri . 'themes/css/'.$custom_css.'">';
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 if ( !check_php_version(4,1) ) {
75 $base_uri = $_SESSION['base_uri'];
77 $target = " target=\"$target\"";
79 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
82 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
84 global $hide_sm_attributions, $PHP_SELF, $frame_top,
85 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
86 $attachemessages, $provider_name, $provider_uri;
88 if ( !check_php_version(4,1) ) {
92 $base_uri = $_SESSION['base_uri'];
93 $delimiter = $_SESSION['delimiter'];
94 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
95 if ($qmark = strpos($module, '?')) {
96 $module = substr($module, 0, $qmark);
98 if (!isset($frame_top)) {
103 $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
105 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
110 case 'src/read_body.php':
112 if ($compose_new_win == '1') {
113 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
114 $compose_width = '640';
116 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
117 $compose_height = '550';
119 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
121 $js .= "function comp_in_new(comp_uri) {\n".
122 " if (!comp_uri) {\n".
123 ' comp_uri = "'.$compose_uri."\";\n".
125 ' var newwin = window.open(comp_uri' .
127 '"width='.$compose_width. ',height='.$compose_height.
128 ',scrollbars=yes,resizable=yes");'."\n".
132 $js .= 'function sendMDN() {'."\n".
133 "mdnuri=window.location+'&sendreceipt=1';".
134 "var newwin = window.open(mdnuri,'right');".
141 displayHtmlHeader ('SquirrelMail', $js);
144 case 'src/compose.php':
145 $js = '<script language="JavaScript" type="text/javascript">' .
147 "function checkForm() {\n".
148 "var f = document.forms.length;\n".
151 "while( pos == -1 && i < f ) {\n".
152 "var e = document.forms[i].elements.length;\n".
154 "while( pos == -1 && j < e ) {\n".
155 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
162 "if( pos >= 0 ) {\n".
163 "document.forms[i-1].elements[pos].focus();\n".
169 $onload = "onLoad=\"checkForm();\"";
170 displayHtmlHeader ('SquirrelMail', $js);
174 $js = '<script language="JavaScript" type="text/javascript">' .
176 "function checkForm() {\n".
177 "var f = document.forms.length;\n".
180 "while( pos == -1 && i < f ) {\n".
181 "var e = document.forms[i].elements.length;\n".
183 "while( pos == -1 && j < e ) {\n".
184 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
191 "if( pos >= 0 ) {\n".
192 "document.forms[i-1].elements[pos].focus();\n".
197 if ($compose_new_win == '1') {
198 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
199 $compose_width = '640';
201 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
202 $compose_height = '550';
204 $js .= "function comp_in_new(comp_uri) {\n".
205 " if (!comp_uri) {\n".
206 ' comp_uri = "'.$compose_uri."\";\n".
208 ' var newwin = window.open(comp_uri' .
210 '"width='.$compose_width. ',height='.$compose_height.
211 ',scrollbars=yes,resizable=yes");'."\n".
215 $js .= "// -->\n". "</script>\n";
218 $onload = "onLoad=\"checkForm();\"";
219 displayHtmlHeader ('SquirrelMail', $js);
224 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
225 /** Here is the header and wrapping table **/
226 $shortBoxName = imap_utf7_decode_local(
227 readShortMailboxName($mailbox, $delimiter));
228 if ( $shortBoxName == 'INBOX' ) {
229 $shortBoxName = _("INBOX");
231 echo "<a name=\"pagetop\"></a>\n"
232 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
233 . html_tag( 'tr', '', '', $color[9] ) ."\n"
234 . html_tag( 'td', '', 'left' ) ."\n";
235 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
236 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
241 . html_tag( 'td', '', 'right' ) ."<b>\n";
242 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
245 . html_tag( 'tr', '', '', $color[4] ) ."\n"
246 . html_tag( 'td', '', 'left' ) ."\n";
247 $urlMailbox = urlencode($mailbox);
248 if ($compose_new_win == '1') {
249 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>';
252 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
254 echo " \n";
255 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
256 echo " \n";
257 displayInternalLink ("src/folders.php", _("Folders"), 'right');
258 echo " \n";
259 displayInternalLink ("src/options.php", _("Options"), 'right');
260 echo " \n";
261 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
262 echo " \n";
263 displayInternalLink ("src/help.php", _("Help"), 'right');
264 echo " \n";
269 . html_tag( 'td', '', 'right' ) ."\n";
270 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
271 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
272 echo ($hide_sm_attributions ?
' ' :
273 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
279 /* blatently copied/truncated/modified from the above function */
280 function compose_Header($color, $mailbox) {
282 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
285 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
286 if (!isset($frame_top)) {
291 Locate the first displayable form element
294 case 'src/search.php':
295 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
296 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
297 displayHtmlHeader (_("Compose"));
300 $js = '<script language="JavaScript" type="text/javascript">' .
302 "function checkForm() {\n".
303 "var f = document.forms.length;\n".
306 "while( pos == -1 && i < f ) {\n".
307 "var e = document.forms[i].elements.length;\n".
309 "while( pos == -1 && j < e ) {\n".
310 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
317 "if( pos >= 0 ) {\n".
318 "document.forms[i-1].elements[pos].focus();\n".
323 $onload = "onLoad=\"checkForm();\"";
324 displayHtmlHeader (_("Compose"), $js);
329 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";