59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
35586184 |
6 | * Prints the page header (duh) |
7 | * |
47ccfad4 |
8 | * @copyright © 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 | |
d6c32258 |
14 | /** Include required files from SM */ |
202bcbcc |
15 | include_once(SM_PATH . 'functions/imap_mailbox.php'); |
b68edc75 |
16 | |
d6c32258 |
17 | /** |
8b096f0a |
18 | * Output a SquirrelMail page header, from <!doctype> to </head> |
19 | * Always set up the language before calling these functions. |
20 | * |
81132de8 |
21 | * Since 1.5.1 function sends http headers. Function should be called |
22 | * before any output is started. |
8b096f0a |
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 |
62b9c984 |
26 | * @param bool frames generate html frameset doctype (since 1.5.1) |
8b096f0a |
27 | * @return void |
d6c32258 |
28 | */ |
d88941c7 |
29 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE, $frames = FALSE ) { |
e6c4caae |
30 | global $squirrelmail_language, $sTplDir, $oErrorHandler; |
692155b7 |
31 | |
0365891c |
32 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
0b97a708 |
33 | global $base_uri; |
34 | } |
f549a706 |
35 | global $theme_css, $custom_css, $pageheader_sent, $theme, $theme_default, $text_direction, |
d88941c7 |
36 | $default_fontset, $chosen_fontset, $default_fontsize, $chosen_fontsize, $chosen_theme; |
81132de8 |
37 | |
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) |
2c21ef20 |
41 | |
62b9c984 |
42 | if ($frames) { |
d88941c7 |
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">'; |
91e0dccc |
45 | } else { |
d88941c7 |
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">'; |
62b9c984 |
48 | } |
f9f738dc |
49 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
50 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
2c21ef20 |
51 | |
d88941c7 |
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'); |
5fe8257d |
55 | |
cbd8c251 |
56 | /* |
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 |
59 | */ |
d88941c7 |
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 : '') |
f549a706 |
64 | .(!empty($used_fontsize) ? '&fontsize='.$used_fontsize : '') |
65 | .(!empty($text_direction) ? '&dir='.$text_direction : '')."\">\n"; |
d88941c7 |
66 | |
81132de8 |
67 | // load custom style sheet (deprecated) |
d88941c7 |
68 | if ( ! empty($theme_css) ) { |
69 | echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">\n"; |
8f1ba72b |
70 | } |
62f7daa5 |
71 | |
e842b215 |
72 | if ($squirrelmail_language == 'ja_JP') { |
683b7853 |
73 | /* |
cbd8c251 |
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. |
79 | */ |
e842b215 |
80 | echo "<!-- \xfd\xfe -->\n"; |
fcae5445 |
81 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
82 | } |
237470b4 |
83 | if ($do_hook) { |
d68323ff |
84 | do_hook('generic_header'); |
237470b4 |
85 | } |
62f7daa5 |
86 | |
f9f738dc |
87 | echo "<title>$title</title>\n$xtra\n"; |
5ca4b1ee |
88 | |
89 | /* work around IE6's scrollbar bug */ |
90 | echo <<<ECHO |
292a9c32 |
91 | <!--[if IE 6]> |
5ca4b1ee |
92 | <style type="text/css"> |
5fe8257d |
93 | /* avoid stupid IE6 bug with frames and scrollbars */ |
94 | body { |
5fe8257d |
95 | width: expression(document.documentElement.clientWidth - 30); |
96 | } |
5ca4b1ee |
97 | </style> |
292a9c32 |
98 | <![endif]--> |
5ca4b1ee |
99 | |
100 | ECHO; |
101 | |
102 | echo "\n</head>\n\n"; |
b6c283c4 |
103 | |
104 | /* this is used to check elsewhere whether we should call this function */ |
105 | $pageheader_sent = TRUE; |
81de00c0 |
106 | if (isset($oErrorHandler)) { |
e6c4caae |
107 | $oErrorHandler->HeaderSent(); |
81de00c0 |
108 | } |
a07cd1a4 |
109 | } |
110 | |
8b096f0a |
111 | /** |
112 | * Given a path to a SquirrelMail file, return a HTML link to it |
113 | * |
114 | * @param string path the SquirrelMail file to link to |
115 | * @param string text the link text |
116 | * @param string target the target frame for this link |
117 | */ |
d62c4938 |
118 | function makeInternalLink($path, $text, $target='') { |
202bcbcc |
119 | global $base_uri; |
120 | // sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
dcc1cc82 |
121 | if ($target != '') { |
122 | $target = " target=\"$target\""; |
123 | } |
4910106a |
124 | |
e50f5ac2 |
125 | // This is an inefficient hook and is only used by |
4910106a |
126 | // one plugin that still needs to patch this code, |
e50f5ac2 |
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?) |
4910106a |
130 | // use for the internal_link hook. |
131 | // |
132 | //$hooktext = do_hook_function('internal_link',$text); |
133 | //if ($hooktext != '') |
134 | // $text = $hooktext; |
135 | |
d62c4938 |
136 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
137 | } |
138 | |
8b096f0a |
139 | /** |
140 | * Same as makeInternalLink, but echoes it too |
141 | */ |
d62c4938 |
142 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
143 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
144 | } |
145 | |
8b096f0a |
146 | /** |
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. |
150 | * |
151 | * @param array color the array of theme colors |
152 | * @param string mailbox the current mailbox name to display |
91c27aee |
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 |
8b096f0a |
155 | * @return void |
156 | */ |
715225af |
157 | |
10bf80c0 |
158 | function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
159 | |
160 | global $reply_focus, $hide_sm_attributions, $frame_top, |
5fe8257d |
161 | $provider_name, $provider_uri, $startMessage, |
162 | $javascript_on, $action, $oTemplate; |
10bf80c0 |
163 | |
164 | if (empty($sBodyTagJs)) { |
165 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
5fe8257d |
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();"'; |
10bf80c0 |
172 | } |
173 | else |
5fe8257d |
174 | $sBodyTagJs = 'onload="checkForm();"'; |
10bf80c0 |
175 | } |
176 | |
5fe8257d |
177 | $urlMailbox = urlencode($mailbox); |
178 | $startMessage = (int)$startMessage; |
179 | |
180 | $sTplDir = $oTemplate->template_dir; |
715225af |
181 | |
0365891c |
182 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
91c27aee |
183 | |
d03f3582 |
184 | if (!isset($frame_top)) { |
185 | $frame_top = '_top'; |
186 | } |
715225af |
187 | |
c18f58c5 |
188 | if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) { |
6373ad12 |
189 | $js_includes = $oTemplate->getJavascriptIncludes(); |
190 | $sJsBlock = ''; |
191 | foreach ($js_includes as $js_file) { |
192 | $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n"; |
193 | } |
91c27aee |
194 | if ($sHeaderJs) { |
2c92ea9d |
195 | $sJsBlock .= "\n<script type=\"text/javascript\">" . |
91c27aee |
196 | "\n<!--\n" . |
a3d59ec3 |
197 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
d62c4938 |
198 | } |
91c27aee |
199 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
5fe8257d |
200 | } else { |
d62c4938 |
201 | /* do not use JavaScript */ |
202 | displayHtmlHeader ('SquirrelMail'); |
91c27aee |
203 | $sBodyTagJs = ''; |
715225af |
204 | } |
202bcbcc |
205 | /* |
206 | * this explains the imap_mailbox.php dependency. We should instead store |
207 | * the selected mailbox in the session and fallback to the session var. |
208 | */ |
72520f77 |
209 | $shortBoxName = htmlspecialchars(imap_utf7_decode_local( |
91e0dccc |
210 | readShortMailboxName($mailbox, $delimiter))); |
3b7d68e6 |
211 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
212 | $shortBoxName = _("INBOX"); |
213 | } |
0493ed11 |
214 | |
5fe8257d |
215 | $sm_attributes = ''; |
216 | if (!$hide_sm_attributions) { |
217 | $sm_attributes .= '<td class="sqm_providerInfo">' ."\n"; |
8b5c49cd |
218 | if (empty($provider_uri)) { |
5fe8257d |
219 | $sm_attributes .= ' <a href="about.php">SquirrelMail</a>'; |
8b5c49cd |
220 | } else { |
221 | if (empty($provider_name)) $provider_name= 'SquirrelMail'; |
5fe8257d |
222 | $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n"; |
8b5c49cd |
223 | } |
5fe8257d |
224 | $sm_attributes .= " </td>\n"; |
99ea51d3 |
225 | } |
5fe8257d |
226 | |
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'); |
a07cd1a4 |
235 | } |
2ba13803 |
236 | |
8b096f0a |
237 | /** |
238 | * Blatantly copied/truncated/modified from displayPageHeader. |
239 | * Outputs a page header specifically for the compose_in_new popup window |
240 | * |
241 | * @param array color the array of theme colors |
242 | * @param string mailbox the current mailbox name to display |
91c27aee |
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 |
8b096f0a |
245 | * @return void |
246 | */ |
10bf80c0 |
247 | function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
248 | |
6373ad12 |
249 | global $reply_focus, $javascript_on, $action, $oTemplate; |
10bf80c0 |
250 | |
251 | if (empty($sBodyTagJs)) { |
252 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
5fe8257d |
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();"'; |
10bf80c0 |
259 | } |
260 | else |
5fe8257d |
261 | $sBodyTagJs = 'onload="checkForm();"'; |
10bf80c0 |
262 | } |
263 | |
264 | |
9c3e6cd4 |
265 | /* |
d62c4938 |
266 | * Locate the first displayable form element (only when JavaScript on) |
267 | */ |
268 | if($javascript_on) { |
91c27aee |
269 | if ($sHeaderJs) { |
2c92ea9d |
270 | $sJsBlock = "\n<script type=\"text/javascript\">" . |
91c27aee |
271 | "\n<!--\n" . |
a3d59ec3 |
272 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
91c27aee |
273 | } else { |
5fe8257d |
274 | $sJsBlock = ''; |
d62c4938 |
275 | } |
6373ad12 |
276 | $sJsBlock .= "\n"; |
277 | |
278 | $js_includes = $oTemplate->getJavascriptIncludes(); |
6373ad12 |
279 | foreach ($js_includes as $js_file) { |
280 | $sJsBlock .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n"; |
281 | } |
282 | |
91c27aee |
283 | displayHtmlHeader (_("Compose"), $sJsBlock); |
d62c4938 |
284 | } else { |
285 | /* javascript off */ |
286 | displayHtmlHeader(_("Compose")); |
287 | $onload = ''; |
9c3e6cd4 |
288 | } |
91c27aee |
289 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
9c3e6cd4 |
290 | } |