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
14 /** Include required files from SM */
15 include_once(SM_PATH
. 'functions/imap_mailbox.php');
18 * Output a SquirrelMail page header, from <!doctype> to </head>
19 * Always set up the language before calling these functions.
21 * Since 1.5.1 function sends http headers. Function should be called
22 * before any output is started.
23 * @param string title the page title, default SquirrelMail.
24 * @param string xtra extra HTML to insert into the header
25 * @param bool do_hook whether to execute hooks, default true
26 * @param bool frames generate html frameset doctype (since 1.5.1)
29 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE, $frames = FALSE ) {
30 global $squirrelmail_language, $sTplDir, $oErrorHandler;
32 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
35 global $theme_css, $custom_css, $pageheader_sent, $theme, $theme_default, $text_direction,
36 $default_fontset, $chosen_fontset, $default_fontsize, $chosen_fontsize, $chosen_theme;
38 /* add no cache headers here */
39 header('Pragma: no-cache'); // http 1.0 (rfc1945)
40 header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
43 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"'."\n"
44 .' "http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">';
46 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'."\n"
47 .' "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">';
49 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
50 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
52 $used_fontset = (!empty($chosen_fontset) ?
$chosen_fontset : $default_fontset);
53 $used_fontsize = (!empty($chosen_fontsize) ?
$chosen_fontsize : $default_fontsize);
54 $used_theme = basename((!empty($chosen_theme) ?
$chosen_theme : $theme[$theme_default]['PATH']),'.php');
57 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
58 * It is not compatible with html 4.01 Transitional
60 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
61 .'?themeid='.$used_theme
62 .'&templateid='.basename($sTplDir)
63 .(!empty($used_fontset) ?
'&fontset='.$used_fontset : '')
64 .(!empty($used_fontsize) ?
'&fontsize='.$used_fontsize : '')
65 .(!empty($text_direction) ?
'&dir='.$text_direction : '')."\">\n";
67 // load custom style sheet (deprecated)
68 if ( ! empty($theme_css) ) {
69 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">\n";
72 if ($squirrelmail_language == 'ja_JP') {
74 * force correct detection of charset, when browser does not follow
75 * http content-type and tries to detect charset from page content.
76 * Shooting of browser's creator can't be implemented in php.
77 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
78 * recommendations and switch to unicode.
80 echo "<!-- \xfd\xfe -->\n";
81 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
84 do_hook('generic_header');
87 echo "<title>$title</title>\n$xtra\n";
89 /* work around IE6's scrollbar bug */
91 <style type="text/css">
93 /* avoid stupid IE6 bug with frames and scrollbars */
95 voice-family: "\"}\"";
96 voice-family: inherit;
97 width: expression(document.documentElement.clientWidth - 30);
104 echo "\n</head>\n\n";
106 /* this is used to check elsewhere whether we should call this function */
107 $pageheader_sent = TRUE;
108 if (isset($oErrorHandler)) {
109 $oErrorHandler->HeaderSent();
114 * Given a path to a SquirrelMail file, return a HTML link to it
116 * @param string path the SquirrelMail file to link to
117 * @param string text the link text
118 * @param string target the target frame for this link
120 function makeInternalLink($path, $text, $target='') {
122 // sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
124 $target = " target=\"$target\"";
127 // This is an inefficient hook and is only used by
128 // one plugin that still needs to patch this code,
129 // plus if we are templat-izing SM, visual hooks
130 // are not needed. However, I am leaving the code
131 // here just in case we find a good (non-visual?)
132 // use for the internal_link hook.
134 //$hooktext = do_hook_function('internal_link',$text);
135 //if ($hooktext != '')
136 // $text = $hooktext;
138 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
142 * Same as makeInternalLink, but echoes it too
144 function displayInternalLink($path, $text, $target='') {
145 echo makeInternalLink($path, $text, $target);
149 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
150 * including the default menu bar. Uses displayHtmlHeader and takes
151 * JavaScript and locale settings into account.
153 * @param array color the array of theme colors
154 * @param string mailbox the current mailbox name to display
155 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
156 * @param string sBodyTagJs js events to be inserted in the body tag
160 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
162 global $reply_focus, $hide_sm_attributions, $frame_top,
163 $provider_name, $provider_uri, $startMessage,
164 $javascript_on, $action, $oTemplate;
166 if (empty($sBodyTagJs)) {
167 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
168 if ($reply_focus == 'select')
169 $sBodyTagJs = 'onload="checkForm(\'select\');"';
170 else if ($reply_focus == 'focus')
171 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
172 else if ($reply_focus != 'none')
173 $sBodyTagJs = 'onload="checkForm();"';
176 $sBodyTagJs = 'onload="checkForm();"';
179 $urlMailbox = urlencode($mailbox);
180 $startMessage = (int)$startMessage;
182 $sTplDir = $oTemplate->template_dir
;
184 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
186 if (!isset($frame_top)) {
190 if( $javascript_on ||
strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
191 $js_includes = $oTemplate->getJavascriptIncludes();
193 foreach ($js_includes as $js_file) {
194 $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
197 $sJsBlock .= "\n<script type=\"text/javascript\">" .
199 $sHeaderJs . "\n\n// -->\n</script>\n";
201 displayHtmlHeader ('SquirrelMail', $sJsBlock);
203 /* do not use JavaScript */
204 displayHtmlHeader ('SquirrelMail');
208 * this explains the imap_mailbox.php dependency. We should instead store
209 * the selected mailbox in the session and fallback to the session var.
211 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
212 readShortMailboxName($mailbox, $delimiter)));
213 if ( $shortBoxName == 'INBOX' ) {
214 $shortBoxName = _("INBOX");
218 if (!$hide_sm_attributions) {
219 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
220 if (empty($provider_uri)) {
221 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
223 if (empty($provider_name)) $provider_name= 'SquirrelMail';
224 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
226 $sm_attributes .= " </td>\n";
229 $oTemplate->assign('body_tag_js', $sBodyTagJs);
230 $oTemplate->assign('shortBoxName', $shortBoxName);
231 $oTemplate->assign('sm_attribute_str', $sm_attributes);
232 $oTemplate->assign('frame_top', $frame_top);
233 $oTemplate->assign('urlMailbox', $urlMailbox);
234 $oTemplate->assign('startMessage', $startMessage);
235 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
236 $oTemplate->display('page_header.tpl');
240 * Blatantly copied/truncated/modified from displayPageHeader.
241 * Outputs a page header specifically for the compose_in_new popup window
243 * @param array color the array of theme colors
244 * @param string mailbox the current mailbox name to display
245 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
246 * @param string sBodyTagJs js events to be inserted in the body tag
249 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
251 global $reply_focus, $javascript_on, $action, $oTemplate;
253 if (empty($sBodyTagJs)) {
254 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
255 if ($reply_focus == 'select')
256 $sBodyTagJs = 'onload="checkForm(\'select\');"';
257 else if ($reply_focus == 'focus')
258 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
259 else if ($reply_focus != 'none')
260 $sBodyTagJs = 'onload="checkForm();"';
263 $sBodyTagJs = 'onload="checkForm();"';
268 * Locate the first displayable form element (only when JavaScript on)
272 $sJsBlock = "\n<script type=\"text/javascript\">" .
274 $sHeaderJs . "\n\n// -->\n</script>\n";
280 $js_includes = $oTemplate->getJavascriptIncludes();
281 foreach ($js_includes as $js_file) {
282 $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
285 displayHtmlHeader (_("Compose"), $sJsBlock);
288 displayHtmlHeader(_("Compose"));
291 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";