Templates
[squirrelmail.git] / functions / page_header.php
CommitLineData
59177427 1<?php
7350889b 2
35586184 3/**
4 * page_header.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 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 *
31841a9e 11 * @version $Id$
d6c32258 12 * @package squirrelmail
35586184 13 */
14
d6c32258 15/** Include required files from SM */
b68edc75 16require_once(SM_PATH . 'functions/strings.php');
17require_once(SM_PATH . 'functions/html.php');
18require_once(SM_PATH . 'functions/imap_mailbox.php');
0b97a708 19require_once(SM_PATH . 'functions/global.php');
b68edc75 20
d6c32258 21/**
8b096f0a 22 * Output a SquirrelMail page header, from <!doctype> to </head>
23 * Always set up the language before calling these functions.
24 *
25 * @param string title the page title, default SquirrelMail.
26 * @param string xtra extra HTML to insert into the header
27 * @param bool do_hook whether to execute hooks, default true
62b9c984 28 * @param bool frames generate html frameset doctype (since 1.5.1)
8b096f0a 29 * @return void
d6c32258 30 */
62b9c984 31function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
e842b215 32 global $squirrelmail_language;
692155b7 33
0365891c 34 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
0b97a708 35 global $base_uri;
36 }
b6c283c4 37 global $theme_css, $custom_css, $pageheader_sent;
2c21ef20 38
62b9c984 39 if ($frames) {
40 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
91e0dccc 41 } else {
62b9c984 42 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
43 }
f9f738dc 44 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
45 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
2c21ef20 46
fcae5445 47 /*
48 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
49 * It is not compatible with html 4.01 Transitional
50 */
a714cb95 51 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
692155b7 52 if ($theme_css != '') {
fcae5445 53 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
692155b7 54 }
8f1ba72b 55 } else {
d68323ff 56 echo '<link rel="stylesheet" type="text/css" href="' .
fcae5445 57 $base_uri . 'themes/css/'.$custom_css.'">';
8f1ba72b 58 }
62f7daa5 59
e842b215 60 if ($squirrelmail_language == 'ja_JP') {
683b7853 61 /*
e50f5ac2 62 * force correct detection of charset, when browser does not follow
683b7853 63 * http content-type and tries to detect charset from page content.
64 * Shooting of browser's creator can't be implemented in php.
e50f5ac2 65 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
683b7853 66 * recommendations and switch to unicode.
e50f5ac2 67 */
e842b215 68 echo "<!-- \xfd\xfe -->\n";
fcae5445 69 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
e842b215 70 }
62f7daa5 71
237470b4 72 if ($do_hook) {
d68323ff 73 do_hook('generic_header');
237470b4 74 }
62f7daa5 75
f9f738dc 76 echo "<title>$title</title>\n$xtra\n";
5ca4b1ee 77
78 /* work around IE6's scrollbar bug */
79 echo <<<ECHO
80<style type="text/css">
81<!--
82 /* avoid stupid IE6 bug with frames and scrollbars */
62f7daa5 83 body {
84 voice-family: "\"}\"";
85 voice-family: inherit;
5ca4b1ee 86 width: expression(document.documentElement.clientWidth - 30);
87 }
88-->
89</style>
90
91ECHO;
92
93 echo "\n</head>\n\n";
b6c283c4 94
95 /* this is used to check elsewhere whether we should call this function */
96 $pageheader_sent = TRUE;
a07cd1a4 97}
98
8b096f0a 99/**
100 * Given a path to a SquirrelMail file, return a HTML link to it
101 *
102 * @param string path the SquirrelMail file to link to
103 * @param string text the link text
104 * @param string target the target frame for this link
105 */
d62c4938 106function makeInternalLink($path, $text, $target='') {
0365891c 107 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
dcc1cc82 108 if ($target != '') {
109 $target = " target=\"$target\"";
110 }
4910106a 111
e50f5ac2 112 // This is an inefficient hook and is only used by
4910106a 113 // one plugin that still needs to patch this code,
e50f5ac2 114 // plus if we are templat-izing SM, visual hooks
115 // are not needed. However, I am leaving the code
116 // here just in case we find a good (non-visual?)
4910106a 117 // use for the internal_link hook.
118 //
119 //$hooktext = do_hook_function('internal_link',$text);
120 //if ($hooktext != '')
121 // $text = $hooktext;
122
d62c4938 123 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
124}
125
8b096f0a 126/**
127 * Same as makeInternalLink, but echoes it too
128 */
d62c4938 129function displayInternalLink($path, $text, $target='') {
b26d81e5 130 echo makeInternalLink($path, $text, $target);
a07cd1a4 131}
132
8b096f0a 133/**
134 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
135 * including the default menu bar. Uses displayHtmlHeader and takes
136 * JavaScript and locale settings into account.
137 *
138 * @param array color the array of theme colors
139 * @param string mailbox the current mailbox name to display
140 * @param string xtra extra html code to add
141 * @param bool session
142 * @return void
143 */
aca403fa 144function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
715225af 145
0b97a708 146 global $hide_sm_attributions, $PHP_SELF, $frame_top,
1ba8cd6b 147 $compose_new_win, $compose_width, $compose_height,
ce68b76b 148 $provider_name, $provider_uri, $startMessage,
149 $javascript_on, $default_use_mdn, $mdn_user_support;
715225af 150
0365891c 151 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
152 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
715225af 153 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
f3e14140 154 if ($qmark = strpos($module, '?')) {
155 $module = substr($module, 0, $qmark);
156 }
d03f3582 157 if (!isset($frame_top)) {
158 $frame_top = '_top';
159 }
715225af 160
735f6b9c 161 if ($session) {
1a531551 162 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
aca403fa 163 } else {
087ce5f8 164 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
1a531551 165 $session = 0;
aca403fa 166 }
62f7daa5 167
04f8889b 168 if( $javascript_on || strpos($xtra, 'new_js_autodetect_results.value') ) {
d62c4938 169
170 switch ( $module ) {
171 case 'src/read_body.php':
172 $js ='';
32485e5e 173
174 // compose in new window code
d62c4938 175 if ($compose_new_win == '1') {
176 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
177 $compose_width = '640';
178 }
179 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
180 $compose_height = '550';
181 }
1a531551 182 $js .= "function comp_in_new_form(comp_uri, button, myform) {\n".
183 ' if (!comp_uri) {'."\n".
184 ' comp_uri = "'.$compose_uri."\";\n".
185 ' }'. "\n".
186 ' comp_uri += "&" + button.name + "=1";'."\n".
187 ' for ( var i=0; i < myform.elements.length; i++ ) {'."\n".
188 ' if ( myform.elements[i].type == "checkbox" && myform.elements[i].checked )'."\n".
189 ' comp_uri += "&" + myform.elements[i].name + "=1";'."\n".
190 ' }'."\n".
191 ' var newwin = window.open(comp_uri' .
192 ', "_blank",'.
193 '"width='.$compose_width. ',height='.$compose_height.
75442b66 194 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
1a531551 195 "}\n\n";
e346043e 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.
75442b66 203 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
e346043e 204 "}\n\n";
32485e5e 205 }
d62c4938 206
32485e5e 207 // javascript for sending read receipts
208 if($default_use_mdn && $mdn_user_support) {
d62c4938 209 $js .= 'function sendMDN() {'."\n".
32485e5e 210 " mdnuri=window.location+'&sendreceipt=1'; ".
d62c4938 211 "var newwin = window.open(mdnuri,'right');".
1a531551 212 "\n}\n\n";
32485e5e 213 }
214
215 // if any of the above passes, add the JS tags too.
216 if($js) {
217 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
218 "\n<!--\n" . $js . "// -->\n</script>\n";
219 }
d62c4938 220
32485e5e 221 displayHtmlHeader ('SquirrelMail', $js);
222 $onload = $xtra;
d62c4938 223 break;
224 case 'src/compose.php':
225 $js = '<script language="JavaScript" type="text/javascript">' .
226 "\n<!--\n" .
9f2f6126 227 "function checkForm() {\n";
228
229 global $action, $reply_focus;
230 if (strpos($action, 'reply') !== FALSE && $reply_focus)
231 {
232 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
233 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
192cdcf5 234 else if ($reply_focus == 'none') $js .= "}\n";
235 }
236 // no reply focus also applies to composing new messages
237 else if ($reply_focus == 'none')
238 {
239 $js .= "}\n";
9f2f6126 240 }
241 else
242 $js .= "var f = document.forms.length;\n".
d62c4938 243 "var i = 0;\n".
244 "var pos = -1;\n".
245 "while( pos == -1 && i < f ) {\n".
246 "var e = document.forms[i].elements.length;\n".
247 "var j = 0;\n".
248 "while( pos == -1 && j < e ) {\n".
249 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
250 "pos = j;\n".
251 "}\n".
252 "j++;\n".
d7f8e6e6 253 "}\n".
d62c4938 254 "i++;\n".
d7f8e6e6 255 "}\n".
d62c4938 256 "if( pos >= 0 ) {\n".
257 "document.forms[i-1].elements[pos].focus();\n".
258 "}\n".
259 "}\n";
62f7daa5 260
d62c4938 261 $js .= "// -->\n".
1a531551 262 "</script>\n";
d62c4938 263 $onload = 'onload="checkForm();"';
264 displayHtmlHeader ('SquirrelMail', $js);
62f7daa5 265 break;
d62c4938 266
cc681ac9 267 case 'src/right_main.php':
63104486 268 global $fancy_index_highlite;
269 if (!$fancy_index_highlite) {
270 $js = '';
271 } else //{ putting braces around this block creats strange PHP errors
272 // following code graciously borrowed from
273 // phpMyAdmin project at:
274 // http://www.phpmyadmin.net
275 $js = <<<EOS
cc681ac9 276/**
277 * This array is used to remember mark status of rows in browse mode
278 */
279var marked_row = new Array;
280
281
f8a4ef2d 282/*
283 * (un)Checks checkbox for the row that the current table cell is in
284 * when it gets clicked.
285 *
286 * @param string the name of the checkbox that should be (un)checked
287 */
288function row_click(chkboxName) {
289 chkbox = document.getElementById(chkboxName);
290 if (chkbox) {
291 chkbox.checked = (chkbox.checked ? false : true);
292 }
293}
294
295
296
297/*
cc681ac9 298 * Sets/unsets the pointer and marker in browse mode
299 *
300 * @param object the table row
301 * @param integer the row number
302 * @param string the action calling this script (over, out or click)
303 * @param string the default background color
304 * @param string the color to use for mouseover
305 * @param string the color to use for marking a row
306 *
307 * @return boolean whether pointer is set or not
308 */
309function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
310{
311 var theCells = null;
312
313 // 1. Pointer and mark feature are disabled or the browser can't get the
314 // row -> exits
315 if ((thePointerColor == '' && theMarkColor == '')
316 || typeof(theRow.style) == 'undefined') {
317 return false;
318 }
319
320 // 2. Gets the current row and exits if the browser can't get it
321 if (typeof(document.getElementsByTagName) != 'undefined') {
322 theCells = theRow.getElementsByTagName('td');
323 }
324 else if (typeof(theRow.cells) != 'undefined') {
325 theCells = theRow.cells;
326 }
327 else {
328 return false;
329 }
330
331 // 3. Gets the current color...
332 var rowCellsCnt = theCells.length;
333 var domDetect = null;
334 var currentColor = null;
335 var newColor = null;
336 // 3.1 ... with DOM compatible browsers except Opera that does not return
337 // valid values with "getAttribute"
338 if (typeof(window.opera) == 'undefined'
339 && typeof(theCells[0].getAttribute) != 'undefined') {
340 currentColor = theCells[0].getAttribute('bgcolor');
341 domDetect = true;
342 }
343 // 3.2 ... with other browsers
344 else {
345 currentColor = theCells[0].style.backgroundColor;
346 domDetect = false;
347 } // end 3
348
349 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
350 if (currentColor.indexOf("rgb") >= 0)
351 {
352 var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
353 currentColor.indexOf(')'));
354 var rgbValues = rgbStr.split(",");
355 currentColor = "#";
356 var hexChars = "0123456789ABCDEF";
357 for (var i = 0; i < 3; i++)
358 {
359 var v = rgbValues[i].valueOf();
360 currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
361 }
362 }
363
364 // 4. Defines the new color
365 // 4.1 Current color is the default one
366 if (currentColor == ''
367 || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
368 if (theAction == 'over' && thePointerColor != '') {
369 newColor = thePointerColor;
370 }
371 else if (theAction == 'click' && theMarkColor != '') {
372 newColor = theMarkColor;
373 marked_row[theRowNum] = true;
374 // deactivated onclick marking of the checkbox because it's also executed
375 // when an action (clicking on the checkbox itself) on a single item is
376 // performed. Then the checkbox would get deactived, even though we need
377 // it activated. Maybe there is a way to detect if the row was clicked,
378 // and not an item therein...
f603fc95 379 //document.getElementById('msg[' + theRowNum + ']').checked = true;
cc681ac9 380 }
381 }
382 // 4.1.2 Current color is the pointer one
383 else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
384 && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
385 if (theAction == 'out') {
386 newColor = theDefaultColor;
387 }
388 else if (theAction == 'click' && theMarkColor != '') {
389 newColor = theMarkColor;
390 marked_row[theRowNum] = true;
f603fc95 391 //document.getElementById('msg[' + theRowNum + ']').checked = true;
cc681ac9 392 }
393 }
394 // 4.1.3 Current color is the marker one
395 else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
396 if (theAction == 'click') {
397 newColor = (thePointerColor != '')
398 ? thePointerColor
399 : theDefaultColor;
400 marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
401 ? true
402 : null;
f603fc95 403 //document.getElementById('msg[' + theRowNum + ']').checked = false;
cc681ac9 404 }
405 } // end 4
406
407 // 5. Sets the new color...
408 if (newColor) {
409 var c = null;
410 // 5.1 ... with DOM compatible browsers except Opera
411 if (domDetect) {
412 for (c = 0; c < rowCellsCnt; c++) {
413 theCells[c].setAttribute('bgcolor', newColor, 0);
414 } // end for
415 }
416 // 5.2 ... with other browsers
417 else {
418 for (c = 0; c < rowCellsCnt; c++) {
419 theCells[c].style.backgroundColor = newColor;
420 }
421 }
422 } // end 5
423
424 return true;
425} // end of the 'setPointer()' function
426EOS;
63104486 427 //} putting braces around this block creats strange PHP errors
cc681ac9 428 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
eaf17634 429 "\n<!--\n" . $js;
430 if ($compose_new_win == '1') {
431 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
432 $compose_width = '640';
433 }
434 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
435 $compose_height = '550';
436 }
63104486 437 $js .= "\n\nfunction comp_in_new(comp_uri) {\n".
eaf17634 438 " if (!comp_uri) {\n".
439 ' comp_uri = "'.$compose_uri."\";\n".
440 ' }'. "\n".
441 ' var newwin = window.open(comp_uri' .
442 ', "_blank",'.
443 '"width='.$compose_width. ',height='.$compose_height.
444 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
445 "}\n\n";
446 }
63104486 447 $js .= $xtra . "\n\n// -->\n</script>\n";
cc681ac9 448 $onload = '';
449 displayHtmlHeader ('SquirrelMail', $js);
450 break;
451
d62c4938 452 default:
453 $js = '<script language="JavaScript" type="text/javascript">' .
454 "\n<!--\n" .
455 "function checkForm() {\n".
456 "var f = document.forms.length;\n".
457 "var i = 0;\n".
458 "var pos = -1;\n".
459 "while( pos == -1 && i < f ) {\n".
460 "var e = document.forms[i].elements.length;\n".
461 "var j = 0;\n".
462 "while( pos == -1 && j < e ) {\n".
463 "if ( document.forms[i].elements[j].type == 'text' " .
464 "|| document.forms[i].elements[j].type == 'password' ) {\n".
465 "pos = j;\n".
466 "}\n".
467 "j++;\n".
353616c4 468 "}\n".
d62c4938 469 "i++;\n".
470 "}\n".
471 "if( pos >= 0 ) {\n".
472 "document.forms[i-1].elements[pos].focus();\n".
353616c4 473 "}\n".
1a531551 474 "$xtra\n".
d62c4938 475 "}\n";
62f7daa5 476
d62c4938 477 if ($compose_new_win == '1') {
478 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
479 $compose_width = '640';
480 }
481 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
482 $compose_height = '550';
483 }
484 $js .= "function comp_in_new(comp_uri) {\n".
75442b66 485 " if (!comp_uri) {\n".
486 ' comp_uri = "'.$compose_uri."\";\n".
487 ' }'. "\n".
d62c4938 488 ' var newwin = window.open(comp_uri' .
489 ', "_blank",'.
490 '"width='.$compose_width. ',height='.$compose_height.
75442b66 491 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
d62c4938 492 "}\n\n";
493
9c3e6cd4 494 }
d62c4938 495 $js .= "// -->\n". "</script>\n";
62f7daa5 496
d62c4938 497 $onload = 'onload="checkForm();"';
498 displayHtmlHeader ('SquirrelMail', $js);
62f7daa5 499 break;
0cba960a 500
d62c4938 501 }
502 } else {
503 /* do not use JavaScript */
504 displayHtmlHeader ('SquirrelMail');
505 $onload = '';
715225af 506 }
507
b01b21d0 508 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
a07cd1a4 509 /** Here is the header and wrapping table **/
72520f77 510 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
91e0dccc 511 readShortMailboxName($mailbox, $delimiter)));
3b7d68e6 512 if ( $shortBoxName == 'INBOX' ) {
7da23762 513 $shortBoxName = _("INBOX");
514 }
b01b21d0 515 echo "<a name=\"pagetop\"></a>\n"
516 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
517 . html_tag( 'tr', '', '', $color[9] ) ."\n"
518 . html_tag( 'td', '', 'left' ) ."\n";
5bb2a991 519 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
b01b21d0 520 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
5bb2a991 521 } else {
522 echo '&nbsp;';
523 }
b01b21d0 524 echo " </td>\n"
525 . html_tag( 'td', '', 'right' ) ."<b>\n";
80e86e94 526 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
b01b21d0 527 echo "</b></td>\n"
528 . " </tr>\n"
529 . html_tag( 'tr', '', '', $color[4] ) ."\n"
99ea51d3 530 . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' )
531 : html_tag( 'td', '', 'left' ) )
532 . "\n";
a07cd1a4 533 $urlMailbox = urlencode($mailbox);
e233a3ad 534 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&amp;startMessage='.$startMessage);
a07cd1a4 535 echo "&nbsp;&nbsp;\n";
21a957a9 536 displayInternalLink ('src/addressbook.php', _("Addresses"));
a07cd1a4 537 echo "&nbsp;&nbsp;\n";
21a957a9 538 displayInternalLink ('src/folders.php', _("Folders"));
a07cd1a4 539 echo "&nbsp;&nbsp;\n";
21a957a9 540 displayInternalLink ('src/options.php', _("Options"));
a07cd1a4 541 echo "&nbsp;&nbsp;\n";
21a957a9 542 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
a07cd1a4 543 echo "&nbsp;&nbsp;\n";
21a957a9 544 displayInternalLink ('src/help.php', _("Help"));
a07cd1a4 545 echo "&nbsp;&nbsp;\n";
546
d68323ff 547 do_hook('menuline');
a07cd1a4 548
99ea51d3 549 echo " </td>\n";
550
551 if (!$hide_sm_attributions)
552 {
553 echo html_tag( 'td', '', 'right' ) ."\n";
8b5c49cd 554 if (empty($provider_uri)) {
555 echo '<a href="about.php">SquirrelMail</a>';
556 } else {
557 if (empty($provider_name)) $provider_name= 'SquirrelMail';
558 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
559 }
99ea51d3 560 echo "</td>\n";
561 }
562 echo " </tr>\n".
04fa3c41 563 "</table><br />\n\n";
a07cd1a4 564}
2ba13803 565
8b096f0a 566/**
567 * Blatantly copied/truncated/modified from displayPageHeader.
568 * Outputs a page header specifically for the compose_in_new popup window
569 *
570 * @param array color the array of theme colors
571 * @param string mailbox the current mailbox name to display
572 * @return void
573 */
9c3e6cd4 574function compose_Header($color, $mailbox) {
575
d62c4938 576 global $javascript_on;
9c3e6cd4 577
578 /*
d62c4938 579 * Locate the first displayable form element (only when JavaScript on)
580 */
581 if($javascript_on) {
ce68b76b 582 global $base_uri, $PHP_SELF, $data_dir, $username;
d62c4938 583
584 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
585
586 switch ( $module ) {
587 case 'src/search.php':
588 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
589 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
590 displayHtmlHeader (_("Compose"));
591 break;
592 default:
593 $js = '<script language="JavaScript" type="text/javascript">' .
594 "\n<!--\n" .
9f2f6126 595 "function checkForm() {\n";
596
597 global $action, $reply_focus;
598 if (strpos($action, 'reply') !== FALSE && $reply_focus)
599 {
600 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
601 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
192cdcf5 602 else if ($reply_focus == 'none') $js .= "}\n";
603 }
604 // no reply focus also applies to composing new messages
605 else if ($reply_focus == 'none')
606 {
607 $js .= "}\n";
9f2f6126 608 }
609 else
610 $js .= "var f = document.forms.length;\n".
d62c4938 611 "var i = 0;\n".
612 "var pos = -1;\n".
613 "while( pos == -1 && i < f ) {\n".
614 "var e = document.forms[i].elements.length;\n".
615 "var j = 0;\n".
616 "while( pos == -1 && j < e ) {\n".
617 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
618 "pos = j;\n".
619 "}\n".
620 "j++;\n".
9c3e6cd4 621 "}\n".
d62c4938 622 "i++;\n".
9c3e6cd4 623 "}\n".
d62c4938 624 "if( pos >= 0 ) {\n".
625 "document.forms[i-1].elements[pos].focus();\n".
626 "}\n".
627 "}\n";
628 $js .= "// -->\n".
1a531551 629 "</script>\n";
d62c4938 630 $onload = 'onload="checkForm();"';
631 displayHtmlHeader (_("Compose"), $js);
62f7daa5 632 break;
d62c4938 633 }
634 } else {
635 /* javascript off */
636 displayHtmlHeader(_("Compose"));
637 $onload = '';
9c3e6cd4 638 }
639
b01b21d0 640 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
9c3e6cd4 641}
e842b215 642
cc681ac9 643?>