6 * Copyright (c) 1999-2005 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" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
45 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
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
51 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
52 if ($theme_css != '') {
53 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
56 echo '<link rel="stylesheet" type="text/css" href="' .
57 $base_uri . 'themes/css/'.$custom_css.'">';
60 if ($squirrelmail_language == 'ja_JP') {
62 * force correct detection of charset, when browser does not follow
63 * http content-type and tries to detect charset from page content.
64 * Shooting of browser's creator can't be implemented in php.
65 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
66 * recommendations and switch to unicode.
68 echo "<!-- \xfd\xfe -->\n";
69 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
72 do_hook('generic_header');
75 echo "<title>$title</title>\n$xtra\n";
77 /* work around IE6's scrollbar bug */
79 <style type="text/css">
81 /* avoid stupid IE6 bug with frames and scrollbars */
83 voice-family: "\"}\"";
84 voice-family: inherit;
85 width: expression(document.documentElement.clientWidth - 30);
94 /* this is used to check elsewhere whether we should call this function */
95 $pageheader_sent = TRUE;
99 * Given a path to a SquirrelMail file, return a HTML link to it
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
105 function makeInternalLink($path, $text, $target='') {
106 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
108 $target = " target=\"$target\"";
111 // This is an inefficient hook and is only used by
112 // one plugin that still needs to patch this code,
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?)
116 // use for the internal_link hook.
118 //$hooktext = do_hook_function('internal_link',$text);
119 //if ($hooktext != '')
120 // $text = $hooktext;
122 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
126 * Same as makeInternalLink, but echoes it too
128 function displayInternalLink($path, $text, $target='') {
129 echo makeInternalLink($path, $text, $target);
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.
137 * @param array color the array of theme colors
138 * @param string mailbox the current mailbox name to display
139 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
140 * @param string sBodyTagJs js events to be inserted in the body tag
144 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
145 global $hide_sm_attributions, $frame_top,
146 $provider_name, $provider_uri, $startMessage,
149 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
151 if (!isset($frame_top)) {
155 if( $javascript_on ||
strpos($xtra, 'new_js_autodetect_results.value') ) {
157 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
159 $sJsHeader . "\n\n// -->\n</script>\n";
163 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
164 displayHtmlHeader ('SquirrelMail', $sJsBlock);
166 /* do not use JavaScript */
167 displayHtmlHeader ('SquirrelMail');
171 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
173 /** Here is the header and wrapping table **/
174 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
175 readShortMailboxName($mailbox, $delimiter)));
176 if ( $shortBoxName == 'INBOX' ) {
177 $shortBoxName = _("INBOX");
179 echo "<a name=\"pagetop\"></a>\n"
180 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
181 . html_tag( 'tr', '', '', $color[9] ) ."\n"
182 . html_tag( 'td', '', 'left' ) ."\n";
183 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
184 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
189 . html_tag( 'td', '', 'right' ) ."<b>\n";
190 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
193 . html_tag( 'tr', '', '', $color[4] ) ."\n"
194 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
195 : html_tag( 'td', '', 'left' ) )
197 $urlMailbox = urlencode($mailbox);
198 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage);
199 echo " \n";
200 displayInternalLink ('src/addressbook.php', _("Addresses"));
201 echo " \n";
202 displayInternalLink ('src/folders.php', _("Folders"));
203 echo " \n";
204 displayInternalLink ('src/options.php', _("Options"));
205 echo " \n";
206 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
207 echo " \n";
208 displayInternalLink ('src/help.php', _("Help"));
209 echo " \n";
215 if (!$hide_sm_attributions)
217 echo html_tag( 'td', '', 'right' ) ."\n";
218 if (empty($provider_uri)) {
219 echo '<a href="about.php">SquirrelMail</a>';
221 if (empty($provider_name)) $provider_name= 'SquirrelMail';
222 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
227 "</table><br />\n\n";
231 * Blatantly copied/truncated/modified from displayPageHeader.
232 * Outputs a page header specifically for the compose_in_new popup window
234 * @param array color the array of theme colors
235 * @param string mailbox the current mailbox name to display
236 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
237 * @param string sBodyTagJs js events to be inserted in the body tag
240 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
241 global $javascript_on;
243 * Locate the first displayable form element (only when JavaScript on)
247 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
249 $sJsHeader . "\n\n// -->\n</script>\n";
253 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
254 displayHtmlHeader (_("Compose"), $sJsBlock);
257 displayHtmlHeader(_("Compose"));
260 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";