Replacing HTML "script" element deprecated attribute "language".
[squirrelmail.git] / functions / page_header.php
CommitLineData
59177427 1<?php
7350889b 2
35586184 3/**
4 * page_header.php
5 *
35586184 6 * Prints the page header (duh)
7 *
47ccfad4 8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
31841a9e 10 * @version $Id$
d6c32258 11 * @package squirrelmail
35586184 12 */
13
81132de8 14/** @ignore */
15if (! defined('SM_PATH')) define('SM_PATH','../');
16
d6c32258 17/** Include required files from SM */
b68edc75 18require_once(SM_PATH . 'functions/strings.php');
19require_once(SM_PATH . 'functions/html.php');
20require_once(SM_PATH . 'functions/imap_mailbox.php');
0b97a708 21require_once(SM_PATH . 'functions/global.php');
5fe8257d 22include_once(SM_PATH . 'class/template/template.class.php');
b68edc75 23
d6c32258 24/**
8b096f0a 25 * Output a SquirrelMail page header, from <!doctype> to </head>
26 * Always set up the language before calling these functions.
27 *
81132de8 28 * Since 1.5.1 function sends http headers. Function should be called
29 * before any output is started.
8b096f0a 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
62b9c984 33 * @param bool frames generate html frameset doctype (since 1.5.1)
8b096f0a 34 * @return void
d6c32258 35 */
d88941c7 36function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE, $frames = FALSE ) {
5fe8257d 37 global $squirrelmail_language, $sTplDir;
692155b7 38
0365891c 39 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
0b97a708 40 global $base_uri;
41 }
d88941c7 42 global $theme_css, $custom_css, $pageheader_sent, $theme, $theme_default,
43 $default_fontset, $chosen_fontset, $default_fontsize, $chosen_fontsize, $chosen_theme;
81132de8 44
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)
2c21ef20 48
62b9c984 49 if ($frames) {
d88941c7 50 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"'."\n"
51 .' "http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">';
91e0dccc 52 } else {
d88941c7 53 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'."\n"
54 .' "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">';
62b9c984 55 }
f9f738dc 56 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
57 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
2c21ef20 58
d88941c7 59 $used_fontset = (!empty($chosen_fontset) ? $chosen_fontset : $default_fontset);
60 $used_fontsize = (!empty($chosen_fontsize) ? $chosen_fontsize : $default_fontsize);
61 $used_theme = basename((!empty($chosen_theme) ? $chosen_theme : $theme[$theme_default]['PATH']),'.php');
5fe8257d 62
cbd8c251 63 /*
64 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
65 * It is not compatible with html 4.01 Transitional
66 */
d88941c7 67 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
68 .'?themeid='.$used_theme
69 .'&amp;templateid='.basename($sTplDir)
70 .(!empty($used_fontset) ? '&amp;fontset='.$used_fontset : '')
71 .(!empty($used_fontsize) ? '&amp;fontsize='.$used_fontsize : '')."\">\n";
72
81132de8 73
74 // load custom style sheet (deprecated)
d88941c7 75 if ( ! empty($theme_css) ) {
76 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">\n";
8f1ba72b 77 }
62f7daa5 78
e842b215 79 if ($squirrelmail_language == 'ja_JP') {
683b7853 80 /*
cbd8c251 81 * force correct detection of charset, when browser does not follow
82 * http content-type and tries to detect charset from page content.
83 * Shooting of browser's creator can't be implemented in php.
84 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
85 * recommendations and switch to unicode.
86 */
e842b215 87 echo "<!-- \xfd\xfe -->\n";
fcae5445 88 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
e842b215 89 }
237470b4 90 if ($do_hook) {
d68323ff 91 do_hook('generic_header');
237470b4 92 }
62f7daa5 93
f9f738dc 94 echo "<title>$title</title>\n$xtra\n";
5ca4b1ee 95
96 /* work around IE6's scrollbar bug */
97 echo <<<ECHO
98<style type="text/css">
99<!--
5fe8257d 100/* avoid stupid IE6 bug with frames and scrollbars */
101body {
102 voice-family: "\"}\"";
103 voice-family: inherit;
104 width: expression(document.documentElement.clientWidth - 30);
105}
5ca4b1ee 106-->
107</style>
108
109ECHO;
110
111 echo "\n</head>\n\n";
b6c283c4 112
113 /* this is used to check elsewhere whether we should call this function */
114 $pageheader_sent = TRUE;
a07cd1a4 115}
116
8b096f0a 117/**
118 * Given a path to a SquirrelMail file, return a HTML link to it
119 *
120 * @param string path the SquirrelMail file to link to
121 * @param string text the link text
122 * @param string target the target frame for this link
123 */
d62c4938 124function makeInternalLink($path, $text, $target='') {
0365891c 125 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
dcc1cc82 126 if ($target != '') {
127 $target = " target=\"$target\"";
128 }
4910106a 129
e50f5ac2 130 // This is an inefficient hook and is only used by
4910106a 131 // one plugin that still needs to patch this code,
e50f5ac2 132 // plus if we are templat-izing SM, visual hooks
133 // are not needed. However, I am leaving the code
134 // here just in case we find a good (non-visual?)
4910106a 135 // use for the internal_link hook.
136 //
137 //$hooktext = do_hook_function('internal_link',$text);
138 //if ($hooktext != '')
139 // $text = $hooktext;
140
d62c4938 141 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
142}
143
8b096f0a 144/**
145 * Same as makeInternalLink, but echoes it too
146 */
d62c4938 147function displayInternalLink($path, $text, $target='') {
b26d81e5 148 echo makeInternalLink($path, $text, $target);
a07cd1a4 149}
150
8b096f0a 151/**
152 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
153 * including the default menu bar. Uses displayHtmlHeader and takes
154 * JavaScript and locale settings into account.
155 *
156 * @param array color the array of theme colors
157 * @param string mailbox the current mailbox name to display
91c27aee 158 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
159 * @param string sBodyTagJs js events to be inserted in the body tag
8b096f0a 160 * @return void
161 */
715225af 162
10bf80c0 163function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
164
165 global $reply_focus, $hide_sm_attributions, $frame_top,
5fe8257d 166 $provider_name, $provider_uri, $startMessage,
167 $javascript_on, $action, $oTemplate;
10bf80c0 168
169 if (empty($sBodyTagJs)) {
170 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
5fe8257d 171 if ($reply_focus == 'select')
172 $sBodyTagJs = 'onload="checkForm(\'select\');"';
173 else if ($reply_focus == 'focus')
174 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
175 else if ($reply_focus != 'none')
176 $sBodyTagJs = 'onload="checkForm();"';
10bf80c0 177 }
178 else
5fe8257d 179 $sBodyTagJs = 'onload="checkForm();"';
10bf80c0 180 }
181
5fe8257d 182 $urlMailbox = urlencode($mailbox);
183 $startMessage = (int)$startMessage;
184
185 $sTplDir = $oTemplate->template_dir;
715225af 186
0365891c 187 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
91c27aee 188
d03f3582 189 if (!isset($frame_top)) {
190 $frame_top = '_top';
191 }
715225af 192
c18f58c5 193 if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
2c92ea9d 194 $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript"></script>' ."\n";
91c27aee 195 if ($sHeaderJs) {
2c92ea9d 196 $sJsBlock .= "\n<script type=\"text/javascript\">" .
91c27aee 197 "\n<!--\n" .
a3d59ec3 198 $sHeaderJs . "\n\n// -->\n</script>\n";
d62c4938 199 }
91c27aee 200 displayHtmlHeader ('SquirrelMail', $sJsBlock);
5fe8257d 201 } else {
d62c4938 202 /* do not use JavaScript */
203 displayHtmlHeader ('SquirrelMail');
91c27aee 204 $sBodyTagJs = '';
715225af 205 }
206
72520f77 207 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
91e0dccc 208 readShortMailboxName($mailbox, $delimiter)));
3b7d68e6 209 if ( $shortBoxName == 'INBOX' ) {
7da23762 210 $shortBoxName = _("INBOX");
211 }
0493ed11 212
5fe8257d 213 $sm_attributes = '';
214 if (!$hide_sm_attributions) {
215 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
8b5c49cd 216 if (empty($provider_uri)) {
5fe8257d 217 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
8b5c49cd 218 } else {
219 if (empty($provider_name)) $provider_name= 'SquirrelMail';
5fe8257d 220 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
8b5c49cd 221 }
5fe8257d 222 $sm_attributes .= " </td>\n";
99ea51d3 223 }
5fe8257d 224
225 $oTemplate->assign('body_tag_js', $sBodyTagJs);
226 $oTemplate->assign('shortBoxName', $shortBoxName);
227 $oTemplate->assign('sm_attribute_str', $sm_attributes);
228 $oTemplate->assign('frame_top', $frame_top);
229 $oTemplate->assign('urlMailbox', $urlMailbox);
230 $oTemplate->assign('startMessage', $startMessage);
231 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
232 $oTemplate->display('page_header.tpl');
a07cd1a4 233}
2ba13803 234
8b096f0a 235/**
236 * Blatantly copied/truncated/modified from displayPageHeader.
237 * Outputs a page header specifically for the compose_in_new popup window
238 *
239 * @param array color the array of theme colors
240 * @param string mailbox the current mailbox name to display
91c27aee 241 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
242 * @param string sBodyTagJs js events to be inserted in the body tag
8b096f0a 243 * @return void
244 */
10bf80c0 245function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
246
247 global $reply_focus, $javascript_on, $action;
248
249 if (empty($sBodyTagJs)) {
250 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
5fe8257d 251 if ($reply_focus == 'select')
252 $sBodyTagJs = 'onload="checkForm(\'select\');"';
253 else if ($reply_focus == 'focus')
254 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
255 else if ($reply_focus != 'none')
256 $sBodyTagJs = 'onload="checkForm();"';
10bf80c0 257 }
258 else
5fe8257d 259 $sBodyTagJs = 'onload="checkForm();"';
10bf80c0 260 }
261
262
9c3e6cd4 263 /*
d62c4938 264 * Locate the first displayable form element (only when JavaScript on)
265 */
266 if($javascript_on) {
91c27aee 267 if ($sHeaderJs) {
2c92ea9d 268 $sJsBlock = "\n<script type=\"text/javascript\">" .
91c27aee 269 "\n<!--\n" .
a3d59ec3 270 $sHeaderJs . "\n\n// -->\n</script>\n";
91c27aee 271 } else {
5fe8257d 272 $sJsBlock = '';
d62c4938 273 }
2c92ea9d 274 $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript"></script>' ."\n";
91c27aee 275 displayHtmlHeader (_("Compose"), $sJsBlock);
d62c4938 276 } else {
277 /* javascript off */
278 displayHtmlHeader(_("Compose"));
279 $onload = '';
9c3e6cd4 280 }
91c27aee 281 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
9c3e6cd4 282}
cbd8c251 283?>