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 ) {
22 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
25 global $theme_css, $custom_css;
27 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
28 "\n\n<html>\n<head>\n";
30 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
31 if ($theme_css != '') {
32 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
35 echo '<link rel="stylesheet" type="text/css" href="' .
36 $base_uri . 'themes/css/'.$custom_css.'" />';
40 do_hook('generic_header');
43 echo "\n<title>$title</title>$xtra\n";
45 /* work around IE6's scrollbar bug */
47 <style type="text/css">
49 /* avoid stupid IE6 bug with frames and scrollbars */
51 voice-family: "\"}\"";
52 voice-family: inherit;
53 width: expression(document.documentElement.clientWidth - 30);
64 function displayInternalLink($path, $text, $target='') {
65 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
67 $target = " target=\"$target\"";
69 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
72 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
74 global $hide_sm_attributions, $PHP_SELF, $frame_top,
75 $compose_new_win, $compose_width, $compose_height,
76 $attachemessages, $provider_name, $provider_uri;
78 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
79 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
80 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
81 if ($qmark = strpos($module, '?')) {
82 $module = substr($module, 0, $qmark);
84 if (!isset($frame_top)) {
89 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
91 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
96 case 'src/read_body.php':
98 if ($compose_new_win == '1') {
99 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
100 $compose_width = '640';
102 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
103 $compose_height = '550';
105 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
107 $js .= "function comp_in_new(comp_uri) {\n".
108 " if (!comp_uri) {\n".
109 ' comp_uri = "'.$compose_uri."\";\n".
111 ' var newwin = window.open(comp_uri' .
113 '"width='.$compose_width. ',height='.$compose_height.
114 ',scrollbars=yes,resizable=yes");'."\n".
118 $js .= 'function sendMDN() {'."\n".
119 "mdnuri=window.location+'&sendreceipt=1';".
120 "var newwin = window.open(mdnuri,'right');".
127 displayHtmlHeader ('SquirrelMail', $js);
130 case 'src/compose.php':
131 $js = '<script language="JavaScript" type="text/javascript">' .
133 "function checkForm() {\n".
134 "var f = document.forms.length;\n".
137 "while( pos == -1 && i < f ) {\n".
138 "var e = document.forms[i].elements.length;\n".
140 "while( pos == -1 && j < e ) {\n".
141 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
148 "if( pos >= 0 ) {\n".
149 "document.forms[i-1].elements[pos].focus();\n".
155 $onload = 'onload="checkForm();"';
156 displayHtmlHeader ('SquirrelMail', $js);
160 $js = '<script language="JavaScript" type="text/javascript">' .
162 "function checkForm() {\n".
163 "var f = document.forms.length;\n".
166 "while( pos == -1 && i < f ) {\n".
167 "var e = document.forms[i].elements.length;\n".
169 "while( pos == -1 && j < e ) {\n".
170 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
177 "if( pos >= 0 ) {\n".
178 "document.forms[i-1].elements[pos].focus();\n".
183 if ($compose_new_win == '1') {
184 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
185 $compose_width = '640';
187 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
188 $compose_height = '550';
190 $js .= "function comp_in_new(comp_uri) {\n".
191 " if (!comp_uri) {\n".
192 ' comp_uri = "'.$compose_uri."\";\n".
194 ' var newwin = window.open(comp_uri' .
196 '"width='.$compose_width. ',height='.$compose_height.
197 ',scrollbars=yes,resizable=yes");'."\n".
201 $js .= "// -->\n". "</script>\n";
204 $onload = 'onload="checkForm();"';
205 displayHtmlHeader ('SquirrelMail', $js);
210 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
211 /** Here is the header and wrapping table **/
212 $shortBoxName = imap_utf7_decode_local(
213 readShortMailboxName($mailbox, $delimiter));
214 if ( $shortBoxName == 'INBOX' ) {
215 $shortBoxName = _("INBOX");
217 echo "<a name=\"pagetop\"></a>\n"
218 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
219 . html_tag( 'tr', '', '', $color[9] ) ."\n"
220 . html_tag( 'td', '', 'left' ) ."\n";
221 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
222 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
227 . html_tag( 'td', '', 'right' ) ."<b>\n";
228 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
231 . html_tag( 'tr', '', '', $color[4] ) ."\n"
232 . html_tag( 'td', '', 'left' ) ."\n";
233 $urlMailbox = urlencode($mailbox);
234 if ($compose_new_win == '1') {
235 echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
238 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
240 echo " \n";
241 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
242 echo " \n";
243 displayInternalLink ('src/folders.php', _("Folders"), 'right');
244 echo " \n";
245 displayInternalLink ('src/options.php', _("Options"), 'right');
246 echo " \n";
247 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
248 echo " \n";
249 displayInternalLink ('src/help.php', _("Help"), 'right');
250 echo " \n";
255 . html_tag( 'td', '', 'right' ) ."\n";
256 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
257 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
258 echo ($hide_sm_attributions ?
' ' :
259 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
265 /* blatently copied/truncated/modified from the above function */
266 function compose_Header($color, $mailbox) {
268 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF,
269 $data_dir, $username, $frame_top, $compose_new_win;
272 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
273 if (!isset($frame_top)) {
278 Locate the first displayable form element
281 case 'src/search.php':
282 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
283 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
284 displayHtmlHeader (_("Compose"));
287 $js = '<script language="JavaScript" type="text/javascript">' .
289 "function checkForm() {\n".
290 "var f = document.forms.length;\n".
293 "while( pos == -1 && i < f ) {\n".
294 "var e = document.forms[i].elements.length;\n".
296 "while( pos == -1 && j < e ) {\n".
297 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
304 "if( pos >= 0 ) {\n".
305 "document.forms[i-1].elements[pos].focus();\n".
310 $onload = 'onload="checkForm();"';
311 displayHtmlHeader (_("Compose"), $js);
316 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";