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('../functions/strings.php');
15 require_once('../functions/imap_utf7_decode_local.php');
16 require_once('../functions/html.php');
17 //require_once('../functions/imap_mailbox.php');
18 /* Always set up the language before calling these functions */
19 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
21 global $theme_css, $custom_css, $base_uri;
23 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
24 "\n\n<HTML>\n<HEAD>\n";
26 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
27 if ($theme_css != '') {
28 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
31 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
32 $base_uri . 'themes/css/'.$custom_css.'">';
36 do_hook("generic_header");
39 echo "\n<title>$title</title>$xtra</head>\n\n";
43 function displayInternalLink($path, $text, $target='') {
47 $target = " target=\"$target\"";
49 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
52 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
54 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
55 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
56 $attachemessages, $session;
58 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
59 if ($qmark = strpos($module, '?')) {
60 $module = substr($module, 0, $qmark);
62 if (!isset($frame_top)) {
66 if ($session != false) {
67 $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
69 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
74 case 'src/read_body.php':
76 if ($compose_new_win == '1') {
77 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
78 $compose_width = '640';
80 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
81 $compose_height = '550';
83 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
85 $js .= "function comp_in_new(comp_uri) {\n".
86 " if (!comp_uri) {\n".
87 ' comp_uri = "'.$compose_uri."\";\n".
89 ' var newwin = window.open(comp_uri' .
91 '"width='.$compose_width. ',height='.$compose_height.
92 '",scrollbars="yes",resizable="yes");'."\n".
96 $js .= 'function sendMDN() {'."\n".
97 "mdnuri=window.location+'&sendreceipt=1';".
98 "var newwin = window.open(mdnuri,'right');".
105 displayHtmlHeader ('Squirrelmail', $js);
108 case 'src/compose.php':
109 $js = '<script language="JavaScript" type="text/javascript">' .
111 "function checkForm() {\n".
112 "var f = document.forms.length;\n".
115 "while( pos == -1 && i < f ) {\n".
116 "var e = document.forms[i].elements.length;\n".
118 "while( pos == -1 && j < e ) {\n".
119 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
126 "if( pos >= 0 ) {\n".
127 "document.forms[i-1].elements[pos].focus();\n".
133 $onload = "onLoad=\"checkForm();\"";
134 displayHtmlHeader ('Squirrelmail', $js);
138 $js = '<script language="JavaScript" type="text/javascript">' .
140 "function checkForm() {\n".
141 "var f = document.forms.length;\n".
144 "while( pos == -1 && i < f ) {\n".
145 "var e = document.forms[i].elements.length;\n".
147 "while( pos == -1 && j < e ) {\n".
148 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
155 "if( pos >= 0 ) {\n".
156 "document.forms[i-1].elements[pos].focus();\n".
161 if ($compose_new_win == '1') {
162 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
163 $compose_width = '640';
165 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
166 $compose_height = '550';
168 $js .= "function comp_in_new(comp_uri) {\n".
169 " if (!comp_uri) {\n".
170 ' comp_uri = "'.$compose_uri."\";\n".
172 ' var newwin = window.open(comp_uri' .
174 '"width='.$compose_width. ',height='.$compose_height.
175 '",scrollbars="yes",resizable="yes");'."\n".
180 $js .= "// -->\n". "</script>\n";
183 $onload = "onLoad=\"checkForm();\"";
184 displayHtmlHeader ('Squirrelmail', $js);
189 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
190 /** Here is the header and wrapping table **/
191 $shortBoxName = imap_utf7_decode_local(
192 readShortMailboxName($mailbox, $delimiter));
193 if ( $shortBoxName == 'INBOX' ) {
194 $shortBoxName = _("INBOX");
196 echo "<a name=\"pagetop\"></a>\n"
197 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
198 . html_tag( 'tr', '', '', $color[9] ) ."\n"
199 . html_tag( 'td', '', 'left' ) ."\n";
200 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
201 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
206 . html_tag( 'td', '', 'right' ) ."<b>\n";
207 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
210 . html_tag( 'tr', '', '', $color[4] ) ."\n"
211 . html_tag( 'td', '', 'left' ) ."\n";
212 $urlMailbox = urlencode($mailbox);
213 if ($compose_new_win == '1') {
214 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>';
217 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
219 echo " \n";
220 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
221 echo " \n";
222 displayInternalLink ("src/folders.php", _("Folders"), 'right');
223 echo " \n";
224 displayInternalLink ("src/options.php", _("Options"), 'right');
225 echo " \n";
226 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
227 echo " \n";
228 displayInternalLink ("src/help.php", _("Help"), 'right');
229 echo " \n";
234 . html_tag( 'td', '', 'right' ) ."\n";
235 echo ($hide_sm_attributions ?
' ' :
236 '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>');
242 /* blatently copied/truncated/modified from the above function */
243 function compose_Header($color, $mailbox) {
245 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
248 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
249 if (!isset($frame_top)) {
254 Locate the first displayable form element
257 case 'src/search.php':
258 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
259 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
260 displayHtmlHeader (_("Compose"));
263 $js = '<script language="JavaScript" type="text/javascript">' .
265 "function checkForm() {\n".
266 "var f = document.forms.length;\n".
269 "while( pos == -1 && i < f ) {\n".
270 "var e = document.forms[i].elements.length;\n".
272 "while( pos == -1 && j < e ) {\n".
273 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
280 "if( pos >= 0 ) {\n".
281 "document.forms[i-1].elements[pos].focus();\n".
286 $onload = "onLoad=\"checkForm();\"";
287 displayHtmlHeader (_("Compose"), $js);
292 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";