fix for text box focus on read_body.php. Ryan, adding a simple case block causes...
[squirrelmail.git] / functions / page_header.php
CommitLineData
59177427 1<?php
7350889b 2
35586184 3/**
4 * page_header.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Prints the page header (duh)
10 *
11 * $Id$
12 */
13
46d38f78 14require_once('../functions/strings.php');
43fdb2a4 15
34c90574 16/* Always set up the language before calling these functions */
a07cd1a4 17function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
692155b7 18
2c21ef20 19 global $theme_css, $custom_css, $base_uri;
20
8f1ba72b 21 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
22 "\n\n<HTML>\n<HEAD>\n";
2c21ef20 23
a714cb95 24 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
692155b7 25 if ($theme_css != '') {
34c90574 26 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
692155b7 27 }
8f1ba72b 28 } else {
2c21ef20 29 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
67dfe419 30 $base_uri . 'themes/css/'.$custom_css.'">';
8f1ba72b 31 }
32
34c90574 33 echo "\n<title>$title</title>$xtra</head>\n\n";
a07cd1a4 34}
35
36function displayInternalLink($path, $text, $target='') {
37 global $base_uri;
38
39 if ($target != '') {
40 $target = " target=\"$target\"";
41 }
42
43 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
44}
45
de19cd73 46function displayPageHeader($color, $mailbox, $xtra='') {
715225af 47
07687736 48 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
49 $compose_new_win, $username, $datadir, $compose_width, $compose_height;
715225af 50
715225af 51 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
b9d5e411 52 if ($qmark = strpos($module, '?')) {
53 $module = substr($module, 0, $qmark);
54 }
d03f3582 55 if (!isset($frame_top)) {
56 $frame_top = '_top';
57 }
715225af 58
59 /*
60 Locate the first displayable form element
61 */
62 switch ( $module ) {
2e52e4a2 63 case 'src/read_body.php':
64 if ($compose_new_win == '1') {
65 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
66 $compose_width = '640';
67 }
68 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
69 $compose_height = '550';
70 }
71 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
72 "\n<!--\n";
73 $js .= "function comp_in_new() {\n".
74 " var newwin = window.open(\"".$base_uri."src/compose.php\"".
75 ", \"compose_window\",
76 \"width=".$compose_width.",height=$compose_height".
77 ",scrollbars=yes,resizable=yes\");\n".
78 "}\n";
79 $js .= "// -->\n".
80 "</script>\n";
81 displayHtmlHeader ('Squirrelmail', $js);
82 }
83 displayHtmlHeader();
84 $onload = '';
85 break;
715225af 86 default:
aaf16822 87 $js = '<script language="JavaScript" type="text/javascript">' .
353616c4 88 "\n<!--\n" .
89 "function checkForm() {\n".
90 "var f = document.forms.length;\n".
91 "var i = 0;\n".
92 "var pos = -1;\n".
93 "while( pos == -1 && i < f ) {\n".
94 "var e = document.forms[i].elements.length;\n".
95 "var j = 0;\n".
96 "while( pos == -1 && j < e ) {\n".
97 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
98 "pos = j;\n".
99 "}\n".
100 "j++;\n".
101 "}\n".
102 "i++;\n".
103 "}\n".
104 "if( pos >= 0 ) {\n".
105 "document.forms[i-1].elements[pos].focus();\n".
106 "}\n".
de19cd73 107 "$xtra\n".
9c3e6cd4 108 "}\n";
109 if ($compose_new_win == '1') {
07687736 110 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
111 $compose_width = '640';
9c3e6cd4 112 }
07687736 113 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
114 $compose_height = '550';
9c3e6cd4 115 }
aaf16822 116 $js .= "function comp_in_new() {\n".
9c3e6cd4 117 " var newwin = window.open(\"".$base_uri."src/compose.php\"".
07687736 118 ", \"compose_window\",
119 \"width=".$compose_width.",height=$compose_height".
9c3e6cd4 120 ",scrollbars=yes,resizable=yes\");\n".
121 "}\n";
122 }
aaf16822 123 $js .= "// -->\n".
de19cd73 124 "</script>\n";
715225af 125 $onload = "onLoad=\"checkForm();\"";
aaf16822 126 displayHtmlHeader ('Squirrelmail', $js);
715225af 127 break;
128
129 }
130
131 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
a07cd1a4 132 /** Here is the header and wrapping table **/
133 $shortBoxName = readShortMailboxName($mailbox, $delimiter);
3b7d68e6 134 if ( $shortBoxName == 'INBOX' ) {
7da23762 135 $shortBoxName = _("INBOX");
136 }
a07cd1a4 137 echo "<A NAME=pagetop></A>\n"
138 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
139 . " <TR BGCOLOR=\"$color[9]\" >\n"
5bb2a991 140 . " <TD ALIGN=left>\n";
141 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
142 echo ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n";
143 } else {
144 echo '&nbsp;';
145 }
146 echo " </TD>\n"
34c90574 147 . ' <TD ALIGN=right><b>';
80e86e94 148 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
34c90574 149 echo "</b></TD>\n"
a07cd1a4 150 . " </TR>\n"
151 . " <TR BGCOLOR=\"$color[4]\">\n"
152 . " <TD ALIGN=left>\n";
153 $urlMailbox = urlencode($mailbox);
9c3e6cd4 154 if ($compose_new_win == '1') {
155 echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=".
9c8ba651 156 '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>';
9c3e6cd4 157 }
158 else {
159 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
160 }
a07cd1a4 161 echo "&nbsp;&nbsp;\n";
162 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
163 echo "&nbsp;&nbsp;\n";
164 displayInternalLink ("src/folders.php", _("Folders"), 'right');
165 echo "&nbsp;&nbsp;\n";
166 displayInternalLink ("src/options.php", _("Options"), 'right');
167 echo "&nbsp;&nbsp;\n";
168 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
169 echo "&nbsp;&nbsp;\n";
170 displayInternalLink ("src/help.php", _("Help"), 'right');
171 echo "&nbsp;&nbsp;\n";
172
173 do_hook("menuline");
174
34c90574 175 echo " </TD>\n <TD ALIGN=\"right\">";
a07cd1a4 176 echo ($hide_sm_attributions ? '&nbsp;' :
34c90574 177 '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>');
178 echo "</TD>\n".
a07cd1a4 179 " </TR>\n".
180 "</TABLE>\n\n";
181}
2ba13803 182
9c3e6cd4 183/* blatently copied/truncated/modified from the above function */
184function compose_Header($color, $mailbox) {
185
186 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
187
9c3e6cd4 188
189 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
190 if (!isset($frame_top)) {
191 $frame_top = '_top';
192 }
193
194 /*
195 Locate the first displayable form element
196 */
197 switch ( $module ) {
198 case 'src/search.php':
199 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
200 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
aaf16822 201 displayHtmlHeader (_("Compose"));
9c3e6cd4 202 break;
203 default:
aaf16822 204 $js = '<script language="JavaScript" type="text/javascript">' .
9c3e6cd4 205 "\n<!--\n" .
206 "function checkForm() {\n".
207 "var f = document.forms.length;\n".
208 "var i = 0;\n".
209 "var pos = -1;\n".
210 "while( pos == -1 && i < f ) {\n".
211 "var e = document.forms[i].elements.length;\n".
212 "var j = 0;\n".
213 "while( pos == -1 && j < e ) {\n".
214 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
215 "pos = j;\n".
216 "}\n".
217 "j++;\n".
218 "}\n".
219 "i++;\n".
220 "}\n".
221 "if( pos >= 0 ) {\n".
222 "document.forms[i-1].elements[pos].focus();\n".
223 "}\n".
224 "}\n";
aaf16822 225 $js .= "// -->\n".
de19cd73 226 "</script>\n";
9c3e6cd4 227 $onload = "onLoad=\"checkForm();\"";
aaf16822 228 displayHtmlHeader (_("Compose"), $js);
9c3e6cd4 229 break;
230
231 }
232
233 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
234}
43fdb2a4 235?>