a08c5e5fff0660fbd864d59878473bd21b5b3bcd
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, $sTemplateID, $oErrorHandler, $oTemplate;
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 //FIXME: should change all header() calls in SM core to use $oTemplate->header()!!
40 $oTemplate->header('Pragma: no-cache'); // http 1.0 (rfc1945)
41 $oTemplate->header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
43 $oTemplate->assign('frames', $frames);
44 $oTemplate->assign('lang', $squirrelmail_language);
48 $header_tags .= "<meta name=\"robots\" content=\"noindex,nofollow\">\n";
50 $used_fontset = (!empty($chosen_fontset) ?
$chosen_fontset : $default_fontset);
51 $used_fontsize = (!empty($chosen_fontsize) ?
$chosen_fontsize : $default_fontsize);
52 $used_theme = basename((!empty($chosen_theme) ?
$chosen_theme : $theme[$theme_default]['PATH']),'.php');
55 * Stylesheets are loaded in the following order:
56 * 1) All stylesheets provided by the template. Normally, these are
57 * stylsheets in templates/<template>/css/. This is accomplished by calling
58 * $oTemplate->fetch_standard_stylesheet_links().
59 * 2) An optional user-defined stylesheet. This is set in the Display
61 * 3) src/style.php which sets some basic font prefs.
62 * 4) If we are dealing with an RTL language, we load rtl.css from the
66 // 1. Stylesheets from the template.
67 $header_tags .= $oTemplate->fetch_standard_stylesheet_links();
69 $aUserStyles = array();
71 // 2. Option user-defined stylesheet from preferences.
72 // FIXME: the following user pref ("sUserStyle"; rename as necessary) will have to be populated by the display prefs screen from a widget similar to the color themes widget (which it replaces) where its values should be full relative paths (from SM_PATH) to the selected css "themes" (either in template css/alternates dir or SM_PATH/css/alternates dir)
73 // FIXME: uhhh, getPref() is not available yet here. (at least on login page) Ugh. Nor has load_prefs been included yet -- how do we fix this?
74 // $aUserStyles[] = getPref($data_dir, $username, 'sUserStyle', '');
75 // Steve, can you please document what u_ means? Will it work with the
76 // new template inheritance system and auto-detection of alternate sheets?
77 if (!empty($chosen_theme) && substr($chosen_theme, 0, 2) == 'u_') {
78 $aUserStyles[] = substr($chosen_theme, 2) .'default.css';
82 $aUserStyles[] = $base_uri .'src/style.php?'
83 . (!empty($used_fontset) ?
'&fontset='.$used_fontset : '')
84 . (!empty($used_fontsize) ?
'&fontsize='.$used_fontsize : '');
85 $header_tags .= $oTemplate->fetch_external_stylesheet_links($aUserStyles);
87 // 4. Optional rtl.css stylesheet
88 if ($text_direction == 'rtl') {
89 $header_tags .= $oTemplate->fetch_right_to_left_stylesheet_link();
92 if ($squirrelmail_language == 'ja_JP') {
94 * force correct detection of charset, when browser does not follow
95 * http content-type and tries to detect charset from page content.
96 * Shooting of browser's creator can't be implemented in php.
97 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
98 * recommendations and switch to unicode.
100 $header_tags .= "<!-- \xfd\xfe -->\n";
101 $header_tags .= '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
104 // NOTE! plugins here must assign output to template
105 // and NOT echo anything directly!!
106 do_hook('generic_header');
109 $header_tags .= $xtra;
110 $oTemplate->assign('page_title', $title);
112 /* work around IE6's scrollbar bug */
113 $header_tags .= <<<EOS
115 <style type="text/css">
116 /* avoid stupid IE6 bug with frames and scrollbars */
118 width: expression(document.documentElement.clientWidth - 30);
125 $oTemplate->assign('header_tags', $header_tags);
126 $oTemplate->display('protocol_header.tpl');
128 /* this is used to check elsewhere whether we should call this function */
129 $pageheader_sent = TRUE;
130 if (isset($oErrorHandler)) {
131 $oErrorHandler->HeaderSent();
137 * Given a path to a SquirrelMail file, return a HTML link to it
139 * @param string path the SquirrelMail file to link to
140 * @param string text the link text
141 * @param string target the target frame for this link
143 function makeInternalLink($path, $text, $target='') {
145 // sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
147 $target = " target=\"$target\"";
150 // This is an inefficient hook and is only used by
151 // one plugin that still needs to patch this code,
152 // plus if we are templat-izing SM, visual hooks
153 // are not needed. However, I am leaving the code
154 // here just in case we find a good (non-visual?)
155 // use for the internal_link hook.
157 //$hooktext = do_hook_function('internal_link',$text);
158 //if ($hooktext != '')
159 // $text = $hooktext;
161 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
165 * Same as makeInternalLink, but echoes it too
167 function displayInternalLink($path, $text, $target='') {
168 // FIXME: should let the template echo all these kinds of things
169 echo makeInternalLink($path, $text, $target);
173 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
174 * including the default menu bar. Uses displayHtmlHeader and takes
175 * JavaScript and locale settings into account.
177 * @param array color the array of theme colors
178 * @param string mailbox the current mailbox name to display
179 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
180 * @param string sBodyTagJs js events to be inserted in the body tag
184 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
186 global $reply_focus, $hide_sm_attributions, $frame_top,
187 $provider_name, $provider_uri, $startMessage,
188 $javascript_on, $action, $oTemplate;
190 if (empty($sBodyTagJs)) {
191 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
192 if ($reply_focus == 'select')
193 $sBodyTagJs = 'onload="checkForm(\'select\');"';
194 else if ($reply_focus == 'focus')
195 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
196 else if ($reply_focus != 'none')
197 $sBodyTagJs = 'onload="checkForm();"';
200 $sBodyTagJs = 'onload="checkForm();"';
203 $urlMailbox = urlencode($mailbox);
204 $startMessage = (int)$startMessage;
206 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
208 if (!isset($frame_top)) {
212 if( $javascript_on ||
strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
213 $js_includes = $oTemplate->get_javascript_includes(TRUE);
215 foreach ($js_includes as $js_file) {
216 $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
219 $sJsBlock .= "\n<script type=\"text/javascript\">" .
221 $sHeaderJs . "\n\n// -->\n</script>\n";
223 displayHtmlHeader ('SquirrelMail', $sJsBlock);
225 /* do not use JavaScript */
226 displayHtmlHeader ('SquirrelMail');
230 * this explains the imap_mailbox.php dependency. We should instead store
231 * the selected mailbox in the session and fallback to the session var.
233 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
234 readShortMailboxName($mailbox, $delimiter)));
235 if ( $shortBoxName == 'INBOX' ) {
236 $shortBoxName = _("INBOX");
240 if (!$hide_sm_attributions) {
241 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
242 if (empty($provider_uri)) {
243 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
245 if (empty($provider_name)) $provider_name= 'SquirrelMail';
246 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
248 $sm_attributes .= " </td>\n";
251 $oTemplate->assign('body_tag_js', $sBodyTagJs);
252 $oTemplate->assign('shortBoxName', $shortBoxName);
253 $oTemplate->assign('sm_attribute_str', $sm_attributes);
254 $oTemplate->assign('frame_top', $frame_top);
255 $oTemplate->assign('urlMailbox', $urlMailbox);
256 $oTemplate->assign('startMessage', $startMessage);
257 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
258 $oTemplate->display('page_header.tpl');
262 * Blatantly copied/truncated/modified from displayPageHeader.
263 * Outputs a page header specifically for the compose_in_new popup window
265 * @param array color the array of theme colors
266 * @param string mailbox the current mailbox name to display
267 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
268 * @param string sBodyTagJs js events to be inserted in the body tag
271 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
273 global $reply_focus, $javascript_on, $action, $oTemplate;
275 if (empty($sBodyTagJs)) {
276 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
277 if ($reply_focus == 'select')
278 $sBodyTagJs = 'onload="checkForm(\'select\');"';
279 else if ($reply_focus == 'focus')
280 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
281 else if ($reply_focus != 'none')
282 $sBodyTagJs = 'onload="checkForm();"';
285 $sBodyTagJs = 'onload="checkForm();"';
290 * Locate the first displayable form element (only when JavaScript on)
294 $sJsBlock = "\n<script type=\"text/javascript\">" .
296 $sHeaderJs . "\n\n// -->\n</script>\n";
302 $js_includes = $oTemplate->get_javascript_includes(TRUE);
303 foreach ($js_includes as $js_file) {
304 $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
307 displayHtmlHeader (_("Compose"), $sJsBlock);
310 displayHtmlHeader(_("Compose"));
313 // FIXME: should let the template echo all these kinds of things
314 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";