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