6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Prints the page header (duh)
12 * @package squirrelmail
15 /** Include required files from SM */
16 require_once(SM_PATH
. 'functions/strings.php');
17 require_once(SM_PATH
. 'functions/html.php');
18 require_once(SM_PATH
. 'functions/imap_mailbox.php');
19 require_once(SM_PATH
. 'functions/global.php');
22 * Output a SquirrelMail page header, from <!doctype> to </head>
23 * Always set up the language before calling these functions.
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
30 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
31 global $squirrelmail_language;
33 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
36 global $theme_css, $custom_css, $pageheader_sent;
38 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
39 "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . "\n<head>\n";
41 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
42 if ($theme_css != '') {
43 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
46 echo '<link rel="stylesheet" type="text/css" href="' .
47 $base_uri . 'themes/css/'.$custom_css.'" />';
50 if ($squirrelmail_language == 'ja_JP') {
51 echo "<!-- \xfd\xfe -->\n";
52 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
56 do_hook('generic_header');
59 echo "\n<title>$title</title>$xtra\n";
61 /* work around IE6's scrollbar bug */
63 <style type="text/css">
65 /* avoid stupid IE6 bug with frames and scrollbars */
67 voice-family: "\"}\"";
68 voice-family: inherit;
69 width: expression(document.documentElement.clientWidth - 30);
78 /* this is used to check elsewhere whether we should call this function */
79 $pageheader_sent = TRUE;
83 * Given a path to a SquirrelMail file, return a HTML link to it
85 * @param string path the SquirrelMail file to link to
86 * @param string text the link text
87 * @param string target the target frame for this link
89 function makeInternalLink($path, $text, $target='') {
90 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
92 $target = " target=\"$target\"";
94 $hooktext = do_hook_function('internal_link',$text);
97 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
101 * Same as makeInternalLink, but echoes it too
103 function displayInternalLink($path, $text, $target='') {
104 echo makeInternalLink($path, $text, $target);
108 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
109 * including the default menu bar. Uses displayHtmlHeader and takes
110 * JavaScript and locale settings into account.
112 * @param array color the array of theme colors
113 * @param string mailbox the current mailbox name to display
114 * @param string xtra extra html code to add
115 * @param bool session
118 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
120 global $hide_sm_attributions, $PHP_SELF, $frame_top,
121 $compose_new_win, $compose_width, $compose_height,
122 $attachemessages, $provider_name, $provider_uri,
123 $javascript_on, $default_use_mdn, $mdn_user_support,
126 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
127 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
128 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
129 if ($qmark = strpos($module, '?')) {
130 $module = substr($module, 0, $qmark);
132 if (!isset($frame_top)) {
137 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
139 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
146 case 'src/read_body.php':
149 // compose in new window code
150 if ($compose_new_win == '1') {
151 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
152 $compose_width = '640';
154 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
155 $compose_height = '550';
157 $js .= "function comp_in_new(comp_uri) {\n".
158 " if (!comp_uri) {\n".
159 ' comp_uri = "'.$compose_uri."\";\n".
161 ' var newwin = window.open(comp_uri' .
163 '"width='.$compose_width. ',height='.$compose_height.
164 ',scrollbars=yes,resizable=yes");'."\n".
168 // javascript for sending read receipts
169 if($default_use_mdn && $mdn_user_support) {
170 $js .= 'function sendMDN() {'."\n".
171 " mdnuri=window.location+'&sendreceipt=1'; ".
172 "var newwin = window.open(mdnuri,'right');".
176 // if any of the above passes, add the JS tags too.
178 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
179 "\n<!--\n" . $js . "// -->\n</script>\n";
182 displayHtmlHeader ('SquirrelMail', $js);
185 case 'src/compose.php':
186 $js = '<script language="JavaScript" type="text/javascript">' .
188 "function checkForm() {\n";
190 global $action, $reply_focus;
191 if (strpos($action, 'reply') !== FALSE && $reply_focus)
193 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
194 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
197 $js .= "var f = document.forms.length;\n".
200 "while( pos == -1 && i < f ) {\n".
201 "var e = document.forms[i].elements.length;\n".
203 "while( pos == -1 && j < e ) {\n".
204 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
211 "if( pos >= 0 ) {\n".
212 "document.forms[i-1].elements[pos].focus();\n".
218 $onload = 'onload="checkForm();"';
219 displayHtmlHeader ('SquirrelMail', $js);
223 $js = '<script language="JavaScript" type="text/javascript">' .
225 "function checkForm() {\n".
226 "var f = document.forms.length;\n".
229 "while( pos == -1 && i < f ) {\n".
230 "var e = document.forms[i].elements.length;\n".
232 "while( pos == -1 && j < e ) {\n".
233 "if ( document.forms[i].elements[j].type == 'text' " .
234 "|| document.forms[i].elements[j].type == 'password' ) {\n".
241 "if( pos >= 0 ) {\n".
242 "document.forms[i-1].elements[pos].focus();\n".
247 if ($compose_new_win == '1') {
248 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
249 $compose_width = '640';
251 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
252 $compose_height = '550';
254 $js .= "function comp_in_new(comp_uri) {\n".
255 " if (!comp_uri) {\n".
256 ' comp_uri = "'.$compose_uri."\";\n".
258 ' var newwin = window.open(comp_uri' .
260 '"width='.$compose_width. ',height='.$compose_height.
261 ',scrollbars=yes,resizable=yes");'."\n".
265 $js .= "// -->\n". "</script>\n";
267 $onload = 'onload="checkForm();"';
268 displayHtmlHeader ('SquirrelMail', $js);
273 /* do not use JavaScript */
274 displayHtmlHeader ('SquirrelMail');
278 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
279 /** Here is the header and wrapping table **/
280 $shortBoxName = imap_utf7_decode_local(
281 readShortMailboxName($mailbox, $delimiter));
282 if ( $shortBoxName == 'INBOX' ) {
283 $shortBoxName = _("INBOX");
285 echo "<a name=\"pagetop\"></a>\n"
286 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
287 . html_tag( 'tr', '', '', $color[9] ) ."\n"
288 . html_tag( 'td', '', 'left' ) ."\n";
289 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
290 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
295 . html_tag( 'td', '', 'right' ) ."<b>\n";
296 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
299 . html_tag( 'tr', '', '', $color[4] ) ."\n"
300 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
301 : html_tag( 'td', '', 'left' ) )
303 $urlMailbox = urlencode($mailbox);
304 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage);
305 echo " \n";
306 displayInternalLink ('src/addressbook.php', _("Addresses"));
307 echo " \n";
308 displayInternalLink ('src/folders.php', _("Folders"));
309 echo " \n";
310 displayInternalLink ('src/options.php', _("Options"));
311 echo " \n";
312 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
313 echo " \n";
314 displayInternalLink ('src/help.php', _("Help"));
315 echo " \n";
321 if (!$hide_sm_attributions)
323 echo html_tag( 'td', '', 'right' ) ."\n";
324 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
325 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
326 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
334 * Blatantly copied/truncated/modified from displayPageHeader.
335 * Outputs a page header specifically for the compose_in_new popup window
337 * @param array color the array of theme colors
338 * @param string mailbox the current mailbox name to display
341 function compose_Header($color, $mailbox) {
343 global $javascript_on;
346 * Locate the first displayable form element (only when JavaScript on)
349 global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
351 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
354 case 'src/search.php':
355 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
356 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
357 displayHtmlHeader (_("Compose"));
360 $js = '<script language="JavaScript" type="text/javascript">' .
362 "function checkForm() {\n";
364 global $action, $reply_focus;
365 if (strpos($action, 'reply') !== FALSE && $reply_focus)
367 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
368 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
371 $js .= "var f = document.forms.length;\n".
374 "while( pos == -1 && i < f ) {\n".
375 "var e = document.forms[i].elements.length;\n".
377 "while( pos == -1 && j < e ) {\n".
378 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
385 "if( pos >= 0 ) {\n".
386 "document.forms[i-1].elements[pos].focus();\n".
391 $onload = 'onload="checkForm();"';
392 displayHtmlHeader (_("Compose"), $js);
397 displayHtmlHeader(_("Compose"));
401 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";