6 * Prints the page header (duh)
8 * @copyright © 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 if (! defined('SM_PATH')) define('SM_PATH','../');
17 /** Include required files from SM */
18 require_once(SM_PATH
. 'functions/strings.php');
19 require_once(SM_PATH
. 'functions/html.php');
20 require_once(SM_PATH
. 'functions/imap_mailbox.php');
21 require_once(SM_PATH
. 'functions/global.php');
24 * Output a SquirrelMail page header, from <!doctype> to </head>
25 * Always set up the language before calling these functions.
27 * Since 1.5.1 function sends http headers. Function should be called
28 * before any output is started.
29 * @param string title the page title, default SquirrelMail.
30 * @param string xtra extra HTML to insert into the header
31 * @param bool do_hook whether to execute hooks, default true
32 * @param bool frames generate html frameset doctype (since 1.5.1)
35 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
36 global $squirrelmail_language;
38 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
41 global $theme_css, $custom_css, $pageheader_sent,
42 $chosen_fontset, $chosen_fontsize, $chosen_theme;
44 /* add no cache headers here */
45 header('Pragma: no-cache'); // http 1.0 (rfc1945)
46 header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
49 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
51 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
53 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
54 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
57 $used_theme = basename($chosen_theme,'.php');
60 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
61 * It is not compatible with html 4.01 Transitional
63 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
64 .'?fontset='.$chosen_fontset
65 .'&themeid='.$used_theme
66 .(isset($chosen_fontsize) ?
'&fontsize='.$chosen_fontsize : '')."\">\n";
68 // load custom style sheet (deprecated)
69 if ( !isset( $theme_css ) ||
empty($theme_css) ) {
70 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
73 if ($squirrelmail_language == 'ja_JP') {
75 * force correct detection of charset, when browser does not follow
76 * http content-type and tries to detect charset from page content.
77 * Shooting of browser's creator can't be implemented in php.
78 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
79 * recommendations and switch to unicode.
81 echo "<!-- \xfd\xfe -->\n";
82 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
85 do_hook('generic_header');
88 echo "<title>$title</title>\n$xtra\n";
90 /* work around IE6's scrollbar bug */
92 <style type="text/css">
94 /* avoid stupid IE6 bug with frames and scrollbars */
96 voice-family: "\"}\"";
97 voice-family: inherit;
98 width: expression(document.documentElement.clientWidth - 30);
105 echo "\n</head>\n\n";
107 /* this is used to check elsewhere whether we should call this function */
108 $pageheader_sent = TRUE;
112 * Given a path to a SquirrelMail file, return a HTML link to it
114 * @param string path the SquirrelMail file to link to
115 * @param string text the link text
116 * @param string target the target frame for this link
118 function makeInternalLink($path, $text, $target='') {
119 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
121 $target = " target=\"$target\"";
124 // This is an inefficient hook and is only used by
125 // one plugin that still needs to patch this code,
126 // plus if we are templat-izing SM, visual hooks
127 // are not needed. However, I am leaving the code
128 // here just in case we find a good (non-visual?)
129 // use for the internal_link hook.
131 //$hooktext = do_hook_function('internal_link',$text);
132 //if ($hooktext != '')
133 // $text = $hooktext;
135 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
139 * Same as makeInternalLink, but echoes it too
141 function displayInternalLink($path, $text, $target='') {
142 echo makeInternalLink($path, $text, $target);
146 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
147 * including the default menu bar. Uses displayHtmlHeader and takes
148 * JavaScript and locale settings into account.
150 * @param array color the array of theme colors
151 * @param string mailbox the current mailbox name to display
152 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
153 * @param string sBodyTagJs js events to be inserted in the body tag
157 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
159 global $reply_focus, $hide_sm_attributions, $frame_top,
160 $provider_name, $provider_uri, $startMessage,
161 $javascript_on, $action;
163 if (empty($sBodyTagJs)) {
164 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
165 if ($reply_focus == 'select')
166 $sBodyTagJs = 'onload="checkForm(\'select\');"';
167 else if ($reply_focus == 'focus')
168 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
169 else if ($reply_focus != 'none')
170 $sBodyTagJs = 'onload="checkForm();"';
173 $sBodyTagJs = 'onload="checkForm();"';
177 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
179 if (!isset($frame_top)) {
183 if( $javascript_on ||
strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
184 $sJsBlock = '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
186 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
188 $sHeaderJs . "\n\n// -->\n</script>\n";
190 displayHtmlHeader ('SquirrelMail', $sJsBlock);
192 /* do not use JavaScript */
193 displayHtmlHeader ('SquirrelMail');
197 echo "<body $sBodyTagJs>\n\n";
199 /** Here is the header and wrapping table **/
200 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
201 readShortMailboxName($mailbox, $delimiter)));
202 if ( $shortBoxName == 'INBOX' ) {
203 $shortBoxName = _("INBOX");
205 echo "<a name=\"pagetop\"></a>\n"
206 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
207 . html_tag( 'tr', '', '', $color[9] ) ."\n"
208 . html_tag( 'td', '', 'left' ) ."\n";
209 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
210 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
215 . html_tag( 'td', '', 'right' ) ."<b>\n";
216 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
219 . html_tag( 'tr', '', '', $color[4] ) ."\n"
220 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
221 : html_tag( 'td', '', 'left' ) )
223 $urlMailbox = urlencode($mailbox);
224 $startMessage = (int)$startMessage;
226 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage);
227 echo " \n";
228 displayInternalLink ('src/addressbook.php', _("Addresses"));
229 echo " \n";
230 displayInternalLink ('src/folders.php', _("Folders"));
231 echo " \n";
232 displayInternalLink ('src/options.php', _("Options"));
233 echo " \n";
234 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
235 echo " \n";
236 displayInternalLink ('src/help.php', _("Help"));
237 echo " \n";
243 if (!$hide_sm_attributions)
245 echo html_tag( 'td', '', 'right' ) ."\n";
246 if (empty($provider_uri)) {
247 echo '<a href="about.php">SquirrelMail</a>';
249 if (empty($provider_name)) $provider_name= 'SquirrelMail';
250 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
255 "</table><br />\n\n";
259 * Blatantly copied/truncated/modified from displayPageHeader.
260 * Outputs a page header specifically for the compose_in_new popup window
262 * @param array color the array of theme colors
263 * @param string mailbox the current mailbox name to display
264 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
265 * @param string sBodyTagJs js events to be inserted in the body tag
268 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
270 global $reply_focus, $javascript_on, $action;
272 if (empty($sBodyTagJs)) {
273 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
274 if ($reply_focus == 'select')
275 $sBodyTagJs = 'onload="checkForm(\'select\');"';
276 else if ($reply_focus == 'focus')
277 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
278 else if ($reply_focus != 'none')
279 $sBodyTagJs = 'onload="checkForm();"';
282 $sBodyTagJs = 'onload="checkForm();"';
287 * Locate the first displayable form element (only when JavaScript on)
291 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
293 $sHeaderJs . "\n\n// -->\n</script>\n";
297 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
298 displayHtmlHeader (_("Compose"), $sJsBlock);
301 displayHtmlHeader(_("Compose"));
304 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";