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
28 * @param bool frames generate html frameset doctype (since 1.5.1)
31 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
32 global $squirrelmail_language;
34 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
37 global $theme_css, $custom_css, $pageheader_sent;
40 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
42 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
44 echo "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . "\n<head>\n";
46 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
47 if ($theme_css != '') {
48 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
51 echo '<link rel="stylesheet" type="text/css" href="' .
52 $base_uri . 'themes/css/'.$custom_css.'" />';
55 if ($squirrelmail_language == 'ja_JP') {
56 echo "<!-- \xfd\xfe -->\n";
57 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' . "\n";
61 do_hook('generic_header');
64 echo "\n<title>$title</title>$xtra\n";
66 /* work around IE6's scrollbar bug */
68 <style type="text/css">
70 /* avoid stupid IE6 bug with frames and scrollbars */
72 voice-family: "\"}\"";
73 voice-family: inherit;
74 width: expression(document.documentElement.clientWidth - 30);
83 /* this is used to check elsewhere whether we should call this function */
84 $pageheader_sent = TRUE;
88 * Given a path to a SquirrelMail file, return a HTML link to it
90 * @param string path the SquirrelMail file to link to
91 * @param string text the link text
92 * @param string target the target frame for this link
94 function makeInternalLink($path, $text, $target='') {
95 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
97 $target = " target=\"$target\"";
99 $hooktext = do_hook_function('internal_link',$text);
102 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
106 * Same as makeInternalLink, but echoes it too
108 function displayInternalLink($path, $text, $target='') {
109 echo makeInternalLink($path, $text, $target);
113 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
114 * including the default menu bar. Uses displayHtmlHeader and takes
115 * JavaScript and locale settings into account.
117 * @param array color the array of theme colors
118 * @param string mailbox the current mailbox name to display
119 * @param string xtra extra html code to add
120 * @param bool session
123 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
125 global $hide_sm_attributions, $PHP_SELF, $frame_top,
126 $compose_new_win, $compose_width, $compose_height,
127 $attachemessages, $provider_name, $provider_uri,
128 $javascript_on, $default_use_mdn, $mdn_user_support,
131 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
132 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
133 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
134 if ($qmark = strpos($module, '?')) {
135 $module = substr($module, 0, $qmark);
137 if (!isset($frame_top)) {
142 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session";
144 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
151 case 'src/read_body.php':
154 // compose in new window code
155 if ($compose_new_win == '1') {
156 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
157 $compose_width = '640';
159 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
160 $compose_height = '550';
162 $js .= "function comp_in_new_form(comp_uri, button, myform) {\n".
163 ' if (!comp_uri) {'."\n".
164 ' comp_uri = "'.$compose_uri."\";\n".
166 ' comp_uri += "&" + button.name + "=1";'."\n".
167 ' for ( var i=0; i < myform.elements.length; i++ ) {'."\n".
168 ' if ( myform.elements[i].type == "checkbox" && myform.elements[i].checked )'."\n".
169 ' comp_uri += "&" + myform.elements[i].name + "=1";'."\n".
171 ' var newwin = window.open(comp_uri' .
173 '"width='.$compose_width. ',height='.$compose_height.
174 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
176 $js .= "function comp_in_new(comp_uri) {\n".
177 " if (!comp_uri) {\n".
178 ' comp_uri = "'.$compose_uri."\";\n".
180 ' var newwin = window.open(comp_uri' .
182 '"width='.$compose_width. ',height='.$compose_height.
183 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
187 // javascript for sending read receipts
188 if($default_use_mdn && $mdn_user_support) {
189 $js .= 'function sendMDN() {'."\n".
190 " mdnuri=window.location+'&sendreceipt=1'; ".
191 "var newwin = window.open(mdnuri,'right');".
195 // if any of the above passes, add the JS tags too.
197 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
198 "\n<!--\n" . $js . "// -->\n</script>\n";
201 displayHtmlHeader ('SquirrelMail', $js);
204 case 'src/compose.php':
205 $js = '<script language="JavaScript" type="text/javascript">' .
207 "function checkForm() {\n";
209 global $action, $reply_focus;
210 if (strpos($action, 'reply') !== FALSE && $reply_focus)
212 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
213 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
214 else if ($reply_focus == 'none') $js .= "}\n";
216 // no reply focus also applies to composing new messages
217 else if ($reply_focus == 'none')
222 $js .= "var f = document.forms.length;\n".
225 "while( pos == -1 && i < f ) {\n".
226 "var e = document.forms[i].elements.length;\n".
228 "while( pos == -1 && j < e ) {\n".
229 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
236 "if( pos >= 0 ) {\n".
237 "document.forms[i-1].elements[pos].focus();\n".
243 $onload = 'onload="checkForm();"';
244 displayHtmlHeader ('SquirrelMail', $js);
248 $js = '<script language="JavaScript" type="text/javascript">' .
250 "function checkForm() {\n".
251 "var f = document.forms.length;\n".
254 "while( pos == -1 && i < f ) {\n".
255 "var e = document.forms[i].elements.length;\n".
257 "while( pos == -1 && j < e ) {\n".
258 "if ( document.forms[i].elements[j].type == 'text' " .
259 "|| document.forms[i].elements[j].type == 'password' ) {\n".
266 "if( pos >= 0 ) {\n".
267 "document.forms[i-1].elements[pos].focus();\n".
272 if ($compose_new_win == '1') {
273 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
274 $compose_width = '640';
276 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
277 $compose_height = '550';
279 $js .= "function comp_in_new(comp_uri) {\n".
280 " if (!comp_uri) {\n".
281 ' comp_uri = "'.$compose_uri."\";\n".
283 ' var newwin = window.open(comp_uri' .
285 '"width='.$compose_width. ',height='.$compose_height.
286 ',scrollbars=yes,resizable=yes,status=yes");'."\n".
290 $js .= "// -->\n". "</script>\n";
292 $onload = 'onload="checkForm();"';
293 displayHtmlHeader ('SquirrelMail', $js);
298 /* do not use JavaScript */
299 displayHtmlHeader ('SquirrelMail');
303 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
304 /** Here is the header and wrapping table **/
305 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
306 readShortMailboxName($mailbox, $delimiter)));
307 if ( $shortBoxName == 'INBOX' ) {
308 $shortBoxName = _("INBOX");
310 echo "<a name=\"pagetop\"></a>\n"
311 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
312 . html_tag( 'tr', '', '', $color[9] ) ."\n"
313 . html_tag( 'td', '', 'left' ) ."\n";
314 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
315 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
320 . html_tag( 'td', '', 'right' ) ."<b>\n";
321 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
324 . html_tag( 'tr', '', '', $color[4] ) ."\n"
325 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
326 : html_tag( 'td', '', 'left' ) )
328 $urlMailbox = urlencode($mailbox);
329 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage);
330 echo " \n";
331 displayInternalLink ('src/addressbook.php', _("Addresses"));
332 echo " \n";
333 displayInternalLink ('src/folders.php', _("Folders"));
334 echo " \n";
335 displayInternalLink ('src/options.php', _("Options"));
336 echo " \n";
337 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
338 echo " \n";
339 displayInternalLink ('src/help.php', _("Help"));
340 echo " \n";
346 if (!$hide_sm_attributions)
348 echo html_tag( 'td', '', 'right' ) ."\n";
349 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
350 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
351 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
355 "</table><br />\n\n";
359 * Blatantly copied/truncated/modified from displayPageHeader.
360 * Outputs a page header specifically for the compose_in_new popup window
362 * @param array color the array of theme colors
363 * @param string mailbox the current mailbox name to display
366 function compose_Header($color, $mailbox) {
368 global $javascript_on;
371 * Locate the first displayable form element (only when JavaScript on)
374 global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
376 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
379 case 'src/search.php':
380 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
381 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
382 displayHtmlHeader (_("Compose"));
385 $js = '<script language="JavaScript" type="text/javascript">' .
387 "function checkForm() {\n";
389 global $action, $reply_focus;
390 if (strpos($action, 'reply') !== FALSE && $reply_focus)
392 if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n";
393 else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n";
394 else if ($reply_focus == 'none') $js .= "}\n";
396 // no reply focus also applies to composing new messages
397 else if ($reply_focus == 'none')
402 $js .= "var f = document.forms.length;\n".
405 "while( pos == -1 && i < f ) {\n".
406 "var e = document.forms[i].elements.length;\n".
408 "while( pos == -1 && j < e ) {\n".
409 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
416 "if( pos >= 0 ) {\n".
417 "document.forms[i-1].elements[pos].focus();\n".
422 $onload = 'onload="checkForm();"';
423 displayHtmlHeader (_("Compose"), $js);
428 displayHtmlHeader(_("Compose"));
432 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";