Masato Higashiyama japanese patch.
[squirrelmail.git] / functions / page_header.php
1 <?php
2
3 /**
4 * page_header.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
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
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');
18
19 /* Always set up the language before calling these functions */
20 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
21 global $squirrelmail_language;
22
23 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
24 global $base_uri;
25 }
26 global $theme_css, $custom_css;
27
28 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
29 "\n\n" . html_tag( 'html' ,'' , '', '', '' ) . "\n<head>\n";
30
31 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
32 if ($theme_css != '') {
33 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
34 }
35 } else {
36 echo '<link rel="stylesheet" type="text/css" href="' .
37 $base_uri . 'themes/css/'.$custom_css.'" />';
38 }
39
40 if ($squirrelmail_language == 'ja_JP') {
41 echo "<!-- \xfd\xfe -->\n";
42 echo '<meta http-equuiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
43 }
44
45 if ($do_hook) {
46 do_hook('generic_header');
47 }
48
49 echo "\n<title>$title</title>$xtra\n";
50
51 /* work around IE6's scrollbar bug */
52 echo <<<ECHO
53 <style type="text/css">
54 <!--
55 /* avoid stupid IE6 bug with frames and scrollbars */
56 body {
57 voice-family: "\"}\"";
58 voice-family: inherit;
59 width: expression(document.documentElement.clientWidth - 30);
60 }
61 -->
62 </style>
63
64 ECHO;
65
66 echo "\n</head>\n\n";
67 }
68
69
70 function displayInternalLink($path, $text, $target='') {
71 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
72 if ($target != '') {
73 $target = " target=\"$target\"";
74 }
75 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
76 }
77
78 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
79
80 global $hide_sm_attributions, $PHP_SELF, $frame_top,
81 $compose_new_win, $compose_width, $compose_height,
82 $attachemessages, $provider_name, $provider_uri;
83
84 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
85 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
86 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
87 if ($qmark = strpos($module, '?')) {
88 $module = substr($module, 0, $qmark);
89 }
90 if (!isset($frame_top)) {
91 $frame_top = '_top';
92 }
93
94 if ($session) {
95 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
96 } else {
97 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
98 $session = 0;
99 }
100
101 switch ( $module ) {
102 case 'src/read_body.php':
103 $js ='';
104 if ($compose_new_win == '1') {
105 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
106 $compose_width = '640';
107 }
108 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
109 $compose_height = '550';
110 }
111 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
112 "\n<!--\n";
113 $js .= "function comp_in_new(comp_uri) {\n".
114 " if (!comp_uri) {\n".
115 ' comp_uri = "'.$compose_uri."\";\n".
116 ' }'. "\n".
117 ' var newwin = window.open(comp_uri' .
118 ', "_blank",'.
119 '"width='.$compose_width. ',height='.$compose_height.
120 ',scrollbars=yes,resizable=yes");'."\n".
121 "}\n\n";
122
123
124 $js .= 'function sendMDN() {'."\n".
125 "mdnuri=window.location+'&sendreceipt=1';".
126 "var newwin = window.open(mdnuri,'right');".
127 "\n}\n\n";
128
129 $js .= "// -->\n".
130 "</script>\n";
131
132 }
133 displayHtmlHeader ('SquirrelMail', $js);
134 $onload = $xtra;
135 break;
136 case 'src/compose.php':
137 $js = '<script language="JavaScript" type="text/javascript">' .
138 "\n<!--\n" .
139 "function checkForm() {\n".
140 "var f = document.forms.length;\n".
141 "var i = 0;\n".
142 "var pos = -1;\n".
143 "while( pos == -1 && i < f ) {\n".
144 "var e = document.forms[i].elements.length;\n".
145 "var j = 0;\n".
146 "while( pos == -1 && j < e ) {\n".
147 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
148 "pos = j;\n".
149 "}\n".
150 "j++;\n".
151 "}\n".
152 "i++;\n".
153 "}\n".
154 "if( pos >= 0 ) {\n".
155 "document.forms[i-1].elements[pos].focus();\n".
156 "}\n".
157 "}\n";
158
159 $js .= "// -->\n".
160 "</script>\n";
161 $onload = 'onload="checkForm();"';
162 displayHtmlHeader ('SquirrelMail', $js);
163 break;
164
165 default:
166 $js = '<script language="JavaScript" type="text/javascript">' .
167 "\n<!--\n" .
168 "function checkForm() {\n".
169 "var f = document.forms.length;\n".
170 "var i = 0;\n".
171 "var pos = -1;\n".
172 "while( pos == -1 && i < f ) {\n".
173 "var e = document.forms[i].elements.length;\n".
174 "var j = 0;\n".
175 "while( pos == -1 && j < e ) {\n".
176 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
177 "pos = j;\n".
178 "}\n".
179 "j++;\n".
180 "}\n".
181 "i++;\n".
182 "}\n".
183 "if( pos >= 0 ) {\n".
184 "document.forms[i-1].elements[pos].focus();\n".
185 "}\n".
186 "$xtra\n".
187 "}\n";
188
189 if ($compose_new_win == '1') {
190 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
191 $compose_width = '640';
192 }
193 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
194 $compose_height = '550';
195 }
196 $js .= "function comp_in_new(comp_uri) {\n".
197 " if (!comp_uri) {\n".
198 ' comp_uri = "'.$compose_uri."\";\n".
199 ' }'. "\n".
200 ' var newwin = window.open(comp_uri' .
201 ', "_blank",'.
202 '"width='.$compose_width. ',height='.$compose_height.
203 ',scrollbars=yes,resizable=yes");'."\n".
204 "}\n\n";
205
206 }
207 $js .= "// -->\n". "</script>\n";
208
209
210 $onload = 'onload="checkForm();"';
211 displayHtmlHeader ('SquirrelMail', $js);
212 break;
213
214 }
215
216 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
217 /** Here is the header and wrapping table **/
218 $shortBoxName = imap_utf7_decode_local(
219 readShortMailboxName($mailbox, $delimiter));
220 if ( $shortBoxName == 'INBOX' ) {
221 $shortBoxName = _("INBOX");
222 }
223 echo "<a name=\"pagetop\"></a>\n"
224 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
225 . html_tag( 'tr', '', '', $color[9] ) ."\n"
226 . html_tag( 'td', '', 'left' ) ."\n";
227 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
228 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
229 } else {
230 echo '&nbsp;';
231 }
232 echo " </td>\n"
233 . html_tag( 'td', '', 'right' ) ."<b>\n";
234 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
235 echo "</b></td>\n"
236 . " </tr>\n"
237 . html_tag( 'tr', '', '', $color[4] ) ."\n"
238 . html_tag( 'td', '', 'left' ) ."\n";
239 $urlMailbox = urlencode($mailbox);
240 if ($compose_new_win == '1') {
241 echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
242 }
243 else {
244 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
245 }
246 echo "&nbsp;&nbsp;\n";
247 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
248 echo "&nbsp;&nbsp;\n";
249 displayInternalLink ('src/folders.php', _("Folders"), 'right');
250 echo "&nbsp;&nbsp;\n";
251 displayInternalLink ('src/options.php', _("Options"), 'right');
252 echo "&nbsp;&nbsp;\n";
253 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
254 echo "&nbsp;&nbsp;\n";
255 displayInternalLink ('src/help.php', _("Help"), 'right');
256 echo "&nbsp;&nbsp;\n";
257
258 do_hook('menuline');
259
260 echo " </td>\n"
261 . html_tag( 'td', '', 'right' ) ."\n";
262 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
263 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
264 echo ($hide_sm_attributions ? '&nbsp;' :
265 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
266 echo "</td>\n".
267 " </tr>\n".
268 "</table><br>\n\n";
269 }
270
271 /* blatently copied/truncated/modified from the above function */
272 function compose_Header($color, $mailbox) {
273
274 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF,
275 $data_dir, $username, $frame_top, $compose_new_win;
276
277
278 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
279 if (!isset($frame_top)) {
280 $frame_top = '_top';
281 }
282
283 /*
284 Locate the first displayable form element
285 */
286 switch ( $module ) {
287 case 'src/search.php':
288 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
289 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
290 displayHtmlHeader (_("Compose"));
291 break;
292 default:
293 $js = '<script language="JavaScript" type="text/javascript">' .
294 "\n<!--\n" .
295 "function checkForm() {\n".
296 "var f = document.forms.length;\n".
297 "var i = 0;\n".
298 "var pos = -1;\n".
299 "while( pos == -1 && i < f ) {\n".
300 "var e = document.forms[i].elements.length;\n".
301 "var j = 0;\n".
302 "while( pos == -1 && j < e ) {\n".
303 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
304 "pos = j;\n".
305 "}\n".
306 "j++;\n".
307 "}\n".
308 "i++;\n".
309 "}\n".
310 "if( pos >= 0 ) {\n".
311 "document.forms[i-1].elements[pos].focus();\n".
312 "}\n".
313 "}\n";
314 $js .= "// -->\n".
315 "</script>\n";
316 $onload = 'onload="checkForm();"';
317 displayHtmlHeader (_("Compose"), $js);
318 break;
319
320 }
321
322 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
323 }
324
325 ?>