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');
22 include_once(SM_PATH
. 'class/template/template.class.php');
25 * Output a SquirrelMail page header, from <!doctype> to </head>
26 * Always set up the language before calling these functions.
28 * Since 1.5.1 function sends http headers. Function should be called
29 * before any output is started.
30 * @param string title the page title, default SquirrelMail.
31 * @param string xtra extra HTML to insert into the header
32 * @param bool do_hook whether to execute hooks, default true
33 * @param bool frames generate html frameset doctype (since 1.5.1)
34 * @param bool style use style.php CSS, default true (since 1.5.1)
37 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE, $frames = FALSE, $style = TRUE ) {
38 global $squirrelmail_language, $sTplDir;
40 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
43 global $theme_css, $custom_css, $pageheader_sent,
44 $chosen_fontset, $chosen_fontsize, $chosen_theme;
46 /* add no cache headers here */
47 header('Pragma: no-cache'); // http 1.0 (rfc1945)
48 header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
51 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
53 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
55 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
56 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
59 $used_theme = basename($chosen_theme,'.php');
62 * The $style parameter is needed since style.php breaks the login otherwise.
63 * This can be removed when style.php doesn't depend on a logged in user.
67 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
68 * It is not compatible with html 4.01 Transitional
70 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
71 .'?fontset='.$chosen_fontset
72 .'&themeid='.$used_theme
73 .(isset($chosen_fontsize) ?
'&fontsize='.$chosen_fontsize : '')."\">\n";
76 // load custom style sheet (deprecated)
77 if ( !isset( $theme_css ) ||
empty($theme_css) ) {
78 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
81 if ($squirrelmail_language == 'ja_JP') {
83 * force correct detection of charset, when browser does not follow
84 * http content-type and tries to detect charset from page content.
85 * Shooting of browser's creator can't be implemented in php.
86 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
87 * recommendations and switch to unicode.
89 echo "<!-- \xfd\xfe -->\n";
90 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
93 do_hook('generic_header');
96 echo "<title>$title</title>\n$xtra\n";
98 /* work around IE6's scrollbar bug */
100 <style type="text/css">
102 /* avoid stupid IE6 bug with frames and scrollbars */
104 voice-family: "\"}\"";
105 voice-family: inherit;
106 width: expression(document.documentElement.clientWidth - 30);
113 echo "\n</head>\n\n";
115 /* this is used to check elsewhere whether we should call this function */
116 $pageheader_sent = TRUE;
120 * Given a path to a SquirrelMail file, return a HTML link to it
122 * @param string path the SquirrelMail file to link to
123 * @param string text the link text
124 * @param string target the target frame for this link
126 function makeInternalLink($path, $text, $target='') {
127 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
129 $target = " target=\"$target\"";
132 // This is an inefficient hook and is only used by
133 // one plugin that still needs to patch this code,
134 // plus if we are templat-izing SM, visual hooks
135 // are not needed. However, I am leaving the code
136 // here just in case we find a good (non-visual?)
137 // use for the internal_link hook.
139 //$hooktext = do_hook_function('internal_link',$text);
140 //if ($hooktext != '')
141 // $text = $hooktext;
143 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
147 * Same as makeInternalLink, but echoes it too
149 function displayInternalLink($path, $text, $target='') {
150 echo makeInternalLink($path, $text, $target);
154 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
155 * including the default menu bar. Uses displayHtmlHeader and takes
156 * JavaScript and locale settings into account.
158 * @param array color the array of theme colors
159 * @param string mailbox the current mailbox name to display
160 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
161 * @param string sBodyTagJs js events to be inserted in the body tag
165 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
167 global $reply_focus, $hide_sm_attributions, $frame_top,
168 $provider_name, $provider_uri, $startMessage,
169 $javascript_on, $action, $oTemplate;
171 if (empty($sBodyTagJs)) {
172 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
173 if ($reply_focus == 'select')
174 $sBodyTagJs = 'onload="checkForm(\'select\');"';
175 else if ($reply_focus == 'focus')
176 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
177 else if ($reply_focus != 'none')
178 $sBodyTagJs = 'onload="checkForm();"';
181 $sBodyTagJs = 'onload="checkForm();"';
184 $urlMailbox = urlencode($mailbox);
185 $startMessage = (int)$startMessage;
187 $sTplDir = $oTemplate->template_dir
;
189 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
191 if (!isset($frame_top)) {
195 if( $javascript_on ||
strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
196 $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
198 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
200 $sHeaderJs . "\n\n// -->\n</script>\n";
202 displayHtmlHeader ('SquirrelMail', $sJsBlock);
204 /* do not use JavaScript */
205 displayHtmlHeader ('SquirrelMail');
209 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
210 readShortMailboxName($mailbox, $delimiter)));
211 if ( $shortBoxName == 'INBOX' ) {
212 $shortBoxName = _("INBOX");
216 if (!$hide_sm_attributions) {
217 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
218 if (empty($provider_uri)) {
219 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
221 if (empty($provider_name)) $provider_name= 'SquirrelMail';
222 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
224 $sm_attributes .= " </td>\n";
227 $oTemplate->assign('body_tag_js', $sBodyTagJs);
228 $oTemplate->assign('shortBoxName', $shortBoxName);
229 $oTemplate->assign('sm_attribute_str', $sm_attributes);
230 $oTemplate->assign('frame_top', $frame_top);
231 $oTemplate->assign('urlMailbox', $urlMailbox);
232 $oTemplate->assign('startMessage', $startMessage);
233 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
234 $oTemplate->display('page_header.tpl');
238 * Blatantly copied/truncated/modified from displayPageHeader.
239 * Outputs a page header specifically for the compose_in_new popup window
241 * @param array color the array of theme colors
242 * @param string mailbox the current mailbox name to display
243 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
244 * @param string sBodyTagJs js events to be inserted in the body tag
247 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
249 global $reply_focus, $javascript_on, $action;
251 if (empty($sBodyTagJs)) {
252 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
253 if ($reply_focus == 'select')
254 $sBodyTagJs = 'onload="checkForm(\'select\');"';
255 else if ($reply_focus == 'focus')
256 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
257 else if ($reply_focus != 'none')
258 $sBodyTagJs = 'onload="checkForm();"';
261 $sBodyTagJs = 'onload="checkForm();"';
266 * Locate the first displayable form element (only when JavaScript on)
270 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
272 $sHeaderJs . "\n\n// -->\n</script>\n";
276 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
277 displayHtmlHeader (_("Compose"), $sJsBlock);
280 displayHtmlHeader(_("Compose"));
283 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";