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');
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";
42 function displayInternalLink($path, $text, $target='') {
46 $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)) {
67 Locate the first displayable form element
70 if ($session != false) {
71 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
73 $compose_uri = 'src/compose.php?newmessage=1';
78 case 'src/read_body.php':
79 if ($compose_new_win == '1') {
80 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
81 $compose_width = '640';
83 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
84 $compose_height = '550';
86 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
88 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
89 ' if (new_mes) { '."\n".
90 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
92 " if (comp_uri =='') {\n".
93 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
96 ' var newwin = window.open(comp_uri' .
98 "width='.$compose_width.",height=$compose_height".
99 ",scrollbars=yes,resizable=yes\");\n".
104 displayHtmlHeader ('Squirrelmail', $js);
109 case 'src/compose.php':
110 $js = '<script language="JavaScript" type="text/javascript">' .
112 "function checkForm() {\n".
113 "var f = document.forms.length;\n".
116 "while( pos == -1 && i < f ) {\n".
117 "var e = document.forms[i].elements.length;\n".
119 "while( pos == -1 && j < e ) {\n".
120 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
127 "if( pos >= 0 ) {\n".
128 "document.forms[i-1].elements[pos].focus();\n".
134 $onload = "onLoad=\"checkForm();\"";
135 displayHtmlHeader ('Squirrelmail', $js);
139 $js = '<script language="JavaScript" type="text/javascript">' .
141 "function checkForm() {\n".
142 "var f = document.forms.length;\n".
145 "while( pos == -1 && i < f ) {\n".
146 "var e = document.forms[i].elements.length;\n".
148 "while( pos == -1 && j < e ) {\n".
149 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
156 "if( pos >= 0 ) {\n".
157 "document.forms[i-1].elements[pos].focus();\n".
162 if ($compose_new_win == '1') {
163 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
164 $compose_width = '640';
166 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
167 $compose_height = '550';
169 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
170 ' if (new_mes) { '."\n".
171 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
173 " if (comp_uri =='') {\n".
174 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
177 ' var newwin = window.open(comp_uri' .
179 "width='.$compose_width.",height=$compose_height".
180 ",scrollbars=yes,resizable=yes\");\n".
185 $onload = "onLoad=\"checkForm();\"";
186 displayHtmlHeader ('Squirrelmail', $js);
191 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
192 /** Here is the header and wrapping table **/
193 $shortBoxName = imap_utf7_decode_local(
194 readShortMailboxName($mailbox, $delimiter));
195 if ( $shortBoxName == 'INBOX' ) {
196 $shortBoxName = _("INBOX");
198 echo "<a name=\"pagetop\"></a>\n"
199 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
200 . html_tag( 'tr', '', '', $color[9] ) ."\n"
201 . html_tag( 'td', '', 'left' ) ."\n";
202 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
203 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
208 . html_tag( 'td', '', 'right' ) ."<b>\n";
209 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
212 . html_tag( 'tr', '', '', $color[4] ) ."\n"
213 . html_tag( 'td', '', 'left' ) ."\n";
214 $urlMailbox = urlencode($mailbox);
215 if ($compose_new_win == '1') {
216 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
219 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
221 echo " \n";
222 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
223 echo " \n";
224 displayInternalLink ("src/folders.php", _("Folders"), 'right');
225 echo " \n";
226 displayInternalLink ("src/options.php", _("Options"), 'right');
227 echo " \n";
228 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
229 echo " \n";
230 displayInternalLink ("src/help.php", _("Help"), 'right');
231 echo " \n";
236 . html_tag( 'td', '', 'right' ) ."\n";
237 echo ($hide_sm_attributions ?
' ' :
238 '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>');
244 /* blatently copied/truncated/modified from the above function */
245 function compose_Header($color, $mailbox) {
247 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
250 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
251 if (!isset($frame_top)) {
256 Locate the first displayable form element
259 case 'src/search.php':
260 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
261 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
262 displayHtmlHeader (_("Compose"));
265 $js = '<script language="JavaScript" type="text/javascript">' .
267 "function checkForm() {\n".
268 "var f = document.forms.length;\n".
271 "while( pos == -1 && i < f ) {\n".
272 "var e = document.forms[i].elements.length;\n".
274 "while( pos == -1 && j < e ) {\n".
275 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
282 "if( pos >= 0 ) {\n".
283 "document.forms[i-1].elements[pos].focus();\n".
288 $onload = "onLoad=\"checkForm();\"";
289 displayHtmlHeader (_("Compose"), $js);
294 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";