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');
17 /* Always set up the language before calling these functions */
18 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
20 global $theme_css, $custom_css, $base_uri;
22 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
23 "\n\n<HTML>\n<HEAD>\n";
25 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
26 if ($theme_css != '') {
27 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
30 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
31 $base_uri . 'themes/css/'.$custom_css.'">';
34 echo "\n<title>$title</title>$xtra</head>\n\n";
37 function displayInternalLink($path, $text, $target='') {
41 $target = " target=\"$target\"";
44 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
47 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
49 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
50 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
51 $attachemessages, $session;
53 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
54 if ($qmark = strpos($module, '?')) {
55 $module = substr($module, 0, $qmark);
57 if (!isset($frame_top)) {
62 Locate the first displayable form element
65 if ($session != false) {
66 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
68 $compose_uri = 'src/compose.php?newmessage=1';
73 case 'src/read_body.php':
74 if ($compose_new_win == '1') {
75 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
76 $compose_width = '640';
78 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
79 $compose_height = '550';
81 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
83 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
84 ' if (new_mes) { '."\n".
85 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
87 " if (comp_uri =='') {\n".
88 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
91 ' var newwin = window.open(comp_uri' .
93 "width='.$compose_width.",height=$compose_height".
94 ",scrollbars=yes,resizable=yes\");\n".
99 displayHtmlHeader ('Squirrelmail', $js);
104 case 'src/compose.php':
105 $js = '<script language="JavaScript" type="text/javascript">' .
107 "function checkForm() {\n".
108 "var f = document.forms.length;\n".
111 "while( pos == -1 && i < f ) {\n".
112 "var e = document.forms[i].elements.length;\n".
114 "while( pos == -1 && j < e ) {\n".
115 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
122 "if( pos >= 0 ) {\n".
123 "document.forms[i-1].elements[pos].focus();\n".
129 $onload = "onLoad=\"checkForm();\"";
130 displayHtmlHeader ('Squirrelmail', $js);
134 $js = '<script language="JavaScript" type="text/javascript">' .
136 "function checkForm() {\n".
137 "var f = document.forms.length;\n".
140 "while( pos == -1 && i < f ) {\n".
141 "var e = document.forms[i].elements.length;\n".
143 "while( pos == -1 && j < e ) {\n".
144 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
151 "if( pos >= 0 ) {\n".
152 "document.forms[i-1].elements[pos].focus();\n".
157 if ($compose_new_win == '1') {
158 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
159 $compose_width = '640';
161 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
162 $compose_height = '550';
164 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
165 ' if (new_mes) { '."\n".
166 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
168 " if (comp_uri =='') {\n".
169 ' comp_uri = "'.$base_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 $onload = "onLoad=\"checkForm();\"";
181 displayHtmlHeader ('Squirrelmail', $js);
186 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
187 /** Here is the header and wrapping table **/
188 $shortBoxName = imap_utf7_decode_local(
189 readShortMailboxName($mailbox, $delimiter));
190 if ( $shortBoxName == 'INBOX' ) {
191 $shortBoxName = _("INBOX");
193 echo "<A NAME=pagetop></A>\n"
194 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
195 . " <TR BGCOLOR=\"$color[9]\" >\n"
196 . " <TD ALIGN=left>\n";
197 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
198 echo ' ' . _("Current Folder") . ": <B>$shortBoxName </B>\n";
203 . ' <TD ALIGN=right><b>';
204 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
207 . " <TR BGCOLOR=\"$color[4]\">\n"
208 . " <TD ALIGN=left>\n";
209 $urlMailbox = urlencode($mailbox);
210 if ($compose_new_win == '1') {
211 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
214 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
216 echo " \n";
217 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
218 echo " \n";
219 displayInternalLink ("src/folders.php", _("Folders"), 'right');
220 echo " \n";
221 displayInternalLink ("src/options.php", _("Options"), 'right');
222 echo " \n";
223 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
224 echo " \n";
225 displayInternalLink ("src/help.php", _("Help"), 'right');
226 echo " \n";
230 echo " </TD>\n <TD ALIGN=\"right\">";
231 echo ($hide_sm_attributions ?
' ' :
232 '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>');
238 /* blatently copied/truncated/modified from the above function */
239 function compose_Header($color, $mailbox) {
241 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
244 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
245 if (!isset($frame_top)) {
250 Locate the first displayable form element
253 case 'src/search.php':
254 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
255 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
256 displayHtmlHeader (_("Compose"));
259 $js = '<script language="JavaScript" type="text/javascript">' .
261 "function checkForm() {\n".
262 "var f = document.forms.length;\n".
265 "while( pos == -1 && i < f ) {\n".
266 "var e = document.forms[i].elements.length;\n".
268 "while( pos == -1 && j < e ) {\n".
269 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
276 "if( pos >= 0 ) {\n".
277 "document.forms[i-1].elements[pos].focus();\n".
282 $onload = "onLoad=\"checkForm();\"";
283 displayHtmlHeader (_("Compose"), $js);
288 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";