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 ( (float)substr(PHP_VERSION
,0,3) < 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.0 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</head>\n\n";
53 function displayInternalLink($path, $text, $target='') {
54 if ( (float)substr(PHP_VERSION
,0,3) < 4.1 ) {
58 $base_uri = $_SESSION['base_uri'];
60 $target = " target=\"$target\"";
62 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
65 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
67 global $hide_sm_attributions, $PHP_SELF, $frame_top,
68 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
69 $attachemessages, $provider_name, $provider_uri;
71 if ( (float)substr(PHP_VERSION
,0,3) < 4.1 ) {
75 $base_uri = $_SESSION['base_uri'];
76 $delimiter = $_SESSION['delimiter'];
77 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
78 if ($qmark = strpos($module, '?')) {
79 $module = substr($module, 0, $qmark);
81 if (!isset($frame_top)) {
86 $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
88 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
93 case 'src/read_body.php':
95 if ($compose_new_win == '1') {
96 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
97 $compose_width = '640';
99 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
100 $compose_height = '550';
102 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
104 $js .= "function comp_in_new(comp_uri) {\n".
105 " if (!comp_uri) {\n".
106 ' comp_uri = "'.$compose_uri."\";\n".
108 ' var newwin = window.open(comp_uri' .
110 '"width='.$compose_width. ',height='.$compose_height.
111 ',scrollbars=yes,resizable=yes");'."\n".
115 $js .= 'function sendMDN() {'."\n".
116 "mdnuri=window.location+'&sendreceipt=1';".
117 "var newwin = window.open(mdnuri,'right');".
124 displayHtmlHeader ('SquirrelMail', $js);
127 case 'src/compose.php':
128 $js = '<script language="JavaScript" type="text/javascript">' .
130 "function checkForm() {\n".
131 "var f = document.forms.length;\n".
134 "while( pos == -1 && i < f ) {\n".
135 "var e = document.forms[i].elements.length;\n".
137 "while( pos == -1 && j < e ) {\n".
138 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
145 "if( pos >= 0 ) {\n".
146 "document.forms[i-1].elements[pos].focus();\n".
152 $onload = "onLoad=\"checkForm();\"";
153 displayHtmlHeader ('SquirrelMail', $js);
157 $js = '<script language="JavaScript" type="text/javascript">' .
159 "function checkForm() {\n".
160 "var f = document.forms.length;\n".
163 "while( pos == -1 && i < f ) {\n".
164 "var e = document.forms[i].elements.length;\n".
166 "while( pos == -1 && j < e ) {\n".
167 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
174 "if( pos >= 0 ) {\n".
175 "document.forms[i-1].elements[pos].focus();\n".
180 if ($compose_new_win == '1') {
181 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
182 $compose_width = '640';
184 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
185 $compose_height = '550';
187 $js .= "function comp_in_new(comp_uri) {\n".
188 " if (!comp_uri) {\n".
189 ' comp_uri = "'.$compose_uri."\";\n".
191 ' var newwin = window.open(comp_uri' .
193 '"width='.$compose_width. ',height='.$compose_height.
194 ',scrollbars=yes,resizable=yes");'."\n".
198 $js .= "// -->\n". "</script>\n";
201 $onload = "onLoad=\"checkForm();\"";
202 displayHtmlHeader ('SquirrelMail', $js);
207 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
208 /** Here is the header and wrapping table **/
209 $shortBoxName = imap_utf7_decode_local(
210 readShortMailboxName($mailbox, $delimiter));
211 if ( $shortBoxName == 'INBOX' ) {
212 $shortBoxName = _("INBOX");
214 echo "<a name=\"pagetop\"></a>\n"
215 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
216 . html_tag( 'tr', '', '', $color[9] ) ."\n"
217 . html_tag( 'td', '', 'left' ) ."\n";
218 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
219 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
224 . html_tag( 'td', '', 'right' ) ."<b>\n";
225 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
228 . html_tag( 'tr', '', '', $color[4] ) ."\n"
229 . html_tag( 'td', '', 'left' ) ."\n";
230 $urlMailbox = urlencode($mailbox);
231 if ($compose_new_win == '1') {
232 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>';
235 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
237 echo " \n";
238 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
239 echo " \n";
240 displayInternalLink ("src/folders.php", _("Folders"), 'right');
241 echo " \n";
242 displayInternalLink ("src/options.php", _("Options"), 'right');
243 echo " \n";
244 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
245 echo " \n";
246 displayInternalLink ("src/help.php", _("Help"), 'right');
247 echo " \n";
252 . html_tag( 'td', '', 'right' ) ."\n";
253 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
254 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
255 echo ($hide_sm_attributions ?
' ' :
256 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
262 /* blatently copied/truncated/modified from the above function */
263 function compose_Header($color, $mailbox) {
265 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
268 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
269 if (!isset($frame_top)) {
274 Locate the first displayable form element
277 case 'src/search.php':
278 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
279 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
280 displayHtmlHeader (_("Compose"));
283 $js = '<script language="JavaScript" type="text/javascript">' .
285 "function checkForm() {\n".
286 "var f = document.forms.length;\n".
289 "while( pos == -1 && i < f ) {\n".
290 "var e = document.forms[i].elements.length;\n".
292 "while( pos == -1 && j < e ) {\n".
293 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
300 "if( pos >= 0 ) {\n".
301 "document.forms[i-1].elements[pos].focus();\n".
306 $onload = "onLoad=\"checkForm();\"";
307 displayHtmlHeader (_("Compose"), $js);
312 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";