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)
36 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
37 global $squirrelmail_language, $sTplDir;
39 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
42 global $theme_css, $custom_css, $pageheader_sent,
43 $chosen_fontset, $chosen_fontsize, $chosen_theme;
45 /* add no cache headers here */
46 header('Pragma: no-cache'); // http 1.0 (rfc1945)
47 header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
50 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
52 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
54 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
55 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
58 $used_theme = basename($chosen_theme,'.php');
61 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
62 * It is not compatible with html 4.01 Transitional
64 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
65 .'?fontset='.$chosen_fontset
66 .'&themeid='.$used_theme
67 .(isset($chosen_fontsize) ?
'&fontsize='.$chosen_fontsize : '')."\">\n";
69 // load custom style sheet (deprecated)
70 if ( !isset( $theme_css ) ||
empty($theme_css) ) {
71 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
74 if ($squirrelmail_language == 'ja_JP') {
76 * force correct detection of charset, when browser does not follow
77 * http content-type and tries to detect charset from page content.
78 * Shooting of browser's creator can't be implemented in php.
79 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
80 * recommendations and switch to unicode.
82 echo "<!-- \xfd\xfe -->\n";
83 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
86 do_hook('generic_header');
89 echo "<title>$title</title>\n$xtra\n";
91 /* work around IE6's scrollbar bug */
93 <style type="text/css">
95 /* avoid stupid IE6 bug with frames and scrollbars */
97 voice-family: "\"}\"";
98 voice-family: inherit;
99 width: expression(document.documentElement.clientWidth - 30);
106 echo "\n</head>\n\n";
108 /* this is used to check elsewhere whether we should call this function */
109 $pageheader_sent = TRUE;
113 * Given a path to a SquirrelMail file, return a HTML link to it
115 * @param string path the SquirrelMail file to link to
116 * @param string text the link text
117 * @param string target the target frame for this link
119 function makeInternalLink($path, $text, $target='') {
120 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
122 $target = " target=\"$target\"";
125 // This is an inefficient hook and is only used by
126 // one plugin that still needs to patch this code,
127 // plus if we are templat-izing SM, visual hooks
128 // are not needed. However, I am leaving the code
129 // here just in case we find a good (non-visual?)
130 // use for the internal_link hook.
132 //$hooktext = do_hook_function('internal_link',$text);
133 //if ($hooktext != '')
134 // $text = $hooktext;
136 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
140 * Same as makeInternalLink, but echoes it too
142 function displayInternalLink($path, $text, $target='') {
143 echo makeInternalLink($path, $text, $target);
147 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
148 * including the default menu bar. Uses displayHtmlHeader and takes
149 * JavaScript and locale settings into account.
151 * @param array color the array of theme colors
152 * @param string mailbox the current mailbox name to display
153 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
154 * @param string sBodyTagJs js events to be inserted in the body tag
158 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
160 global $reply_focus, $hide_sm_attributions, $frame_top,
161 $provider_name, $provider_uri, $startMessage,
162 $javascript_on, $action, $oTemplate;
164 if (empty($sBodyTagJs)) {
165 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
166 if ($reply_focus == 'select')
167 $sBodyTagJs = 'onload="checkForm(\'select\');"';
168 else if ($reply_focus == 'focus')
169 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
170 else if ($reply_focus != 'none')
171 $sBodyTagJs = 'onload="checkForm();"';
174 $sBodyTagJs = 'onload="checkForm();"';
177 $urlMailbox = urlencode($mailbox);
178 $startMessage = (int)$startMessage;
180 $sTplDir = $oTemplate->template_dir
;
182 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
184 if (!isset($frame_top)) {
188 if( $javascript_on ||
strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
189 $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
191 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
193 $sHeaderJs . "\n\n// -->\n</script>\n";
195 displayHtmlHeader ('SquirrelMail', $sJsBlock);
197 /* do not use JavaScript */
198 displayHtmlHeader ('SquirrelMail');
202 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
203 readShortMailboxName($mailbox, $delimiter)));
204 if ( $shortBoxName == 'INBOX' ) {
205 $shortBoxName = _("INBOX");
209 if (!$hide_sm_attributions) {
210 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
211 if (empty($provider_uri)) {
212 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
214 if (empty($provider_name)) $provider_name= 'SquirrelMail';
215 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
217 $sm_attributes .= " </td>\n";
220 $oTemplate->assign('body_tag_js', $sBodyTagJs);
221 $oTemplate->assign('shortBoxName', $shortBoxName);
222 $oTemplate->assign('sm_attribute_str', $sm_attributes);
223 $oTemplate->assign('frame_top', $frame_top);
224 $oTemplate->assign('urlMailbox', $urlMailbox);
225 $oTemplate->assign('startMessage', $startMessage);
226 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
227 $oTemplate->display('page_header.tpl');
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 = '') {
242 global $reply_focus, $javascript_on, $action;
244 if (empty($sBodyTagJs)) {
245 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
246 if ($reply_focus == 'select')
247 $sBodyTagJs = 'onload="checkForm(\'select\');"';
248 else if ($reply_focus == 'focus')
249 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
250 else if ($reply_focus != 'none')
251 $sBodyTagJs = 'onload="checkForm();"';
254 $sBodyTagJs = 'onload="checkForm();"';
259 * Locate the first displayable form element (only when JavaScript on)
263 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
265 $sHeaderJs . "\n\n// -->\n</script>\n";
269 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
270 displayHtmlHeader (_("Compose"), $sJsBlock);
273 displayHtmlHeader(_("Compose"));
276 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";