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 | |
81132de8 |
14 | /** @ignore */ |
15 | if (! defined('SM_PATH')) define('SM_PATH','../'); |
16 | |
d6c32258 |
17 | /** Include required files from SM */ |
b68edc75 |
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'); |
0b97a708 |
21 | require_once(SM_PATH . 'functions/global.php'); |
5fe8257d |
22 | include_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) |
cbd8c251 |
34 | * @param bool style use style.php CSS, default true (since 1.5.1) |
8b096f0a |
35 | * @return void |
d6c32258 |
36 | */ |
cbd8c251 |
37 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE, $frames = FALSE, $style = TRUE ) { |
5fe8257d |
38 | global $squirrelmail_language, $sTplDir; |
692155b7 |
39 | |
0365891c |
40 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
0b97a708 |
41 | global $base_uri; |
42 | } |
5fe8257d |
43 | global $theme_css, $custom_css, $pageheader_sent, |
81132de8 |
44 | $chosen_fontset, $chosen_fontsize, $chosen_theme; |
45 | |
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) |
2c21ef20 |
49 | |
62b9c984 |
50 | if ($frames) { |
51 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">'; |
91e0dccc |
52 | } else { |
62b9c984 |
53 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
54 | } |
f9f738dc |
55 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
56 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
2c21ef20 |
57 | |
5fe8257d |
58 | |
81132de8 |
59 | $used_theme = basename($chosen_theme,'.php'); |
60 | |
fcae5445 |
61 | /* |
cbd8c251 |
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. |
64 | */ |
65 | if ($style) { |
66 | /* |
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 |
69 | */ |
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"; |
74 | } |
81132de8 |
75 | |
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\">"; |
8f1ba72b |
79 | } |
62f7daa5 |
80 | |
e842b215 |
81 | if ($squirrelmail_language == 'ja_JP') { |
683b7853 |
82 | /* |
cbd8c251 |
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. |
88 | */ |
e842b215 |
89 | echo "<!-- \xfd\xfe -->\n"; |
fcae5445 |
90 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
91 | } |
237470b4 |
92 | if ($do_hook) { |
d68323ff |
93 | do_hook('generic_header'); |
237470b4 |
94 | } |
62f7daa5 |
95 | |
f9f738dc |
96 | echo "<title>$title</title>\n$xtra\n"; |
5ca4b1ee |
97 | |
98 | /* work around IE6's scrollbar bug */ |
99 | echo <<<ECHO |
100 | <style type="text/css"> |
101 | <!-- |
5fe8257d |
102 | /* avoid stupid IE6 bug with frames and scrollbars */ |
103 | body { |
104 | voice-family: "\"}\""; |
105 | voice-family: inherit; |
106 | width: expression(document.documentElement.clientWidth - 30); |
107 | } |
5ca4b1ee |
108 | --> |
109 | </style> |
110 | |
111 | ECHO; |
112 | |
113 | echo "\n</head>\n\n"; |
b6c283c4 |
114 | |
115 | /* this is used to check elsewhere whether we should call this function */ |
116 | $pageheader_sent = TRUE; |
a07cd1a4 |
117 | } |
118 | |
8b096f0a |
119 | /** |
120 | * Given a path to a SquirrelMail file, return a HTML link to it |
121 | * |
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 |
125 | */ |
d62c4938 |
126 | function makeInternalLink($path, $text, $target='') { |
0365891c |
127 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
dcc1cc82 |
128 | if ($target != '') { |
129 | $target = " target=\"$target\""; |
130 | } |
4910106a |
131 | |
e50f5ac2 |
132 | // This is an inefficient hook and is only used by |
4910106a |
133 | // one plugin that still needs to patch this code, |
e50f5ac2 |
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?) |
4910106a |
137 | // use for the internal_link hook. |
138 | // |
139 | //$hooktext = do_hook_function('internal_link',$text); |
140 | //if ($hooktext != '') |
141 | // $text = $hooktext; |
142 | |
d62c4938 |
143 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
144 | } |
145 | |
8b096f0a |
146 | /** |
147 | * Same as makeInternalLink, but echoes it too |
148 | */ |
d62c4938 |
149 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
150 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
151 | } |
152 | |
8b096f0a |
153 | /** |
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. |
157 | * |
158 | * @param array color the array of theme colors |
159 | * @param string mailbox the current mailbox name to display |
91c27aee |
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 |
8b096f0a |
162 | * @return void |
163 | */ |
715225af |
164 | |
10bf80c0 |
165 | function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
166 | |
167 | global $reply_focus, $hide_sm_attributions, $frame_top, |
5fe8257d |
168 | $provider_name, $provider_uri, $startMessage, |
169 | $javascript_on, $action, $oTemplate; |
10bf80c0 |
170 | |
171 | if (empty($sBodyTagJs)) { |
172 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
5fe8257d |
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();"'; |
10bf80c0 |
179 | } |
180 | else |
5fe8257d |
181 | $sBodyTagJs = 'onload="checkForm();"'; |
10bf80c0 |
182 | } |
183 | |
5fe8257d |
184 | $urlMailbox = urlencode($mailbox); |
185 | $startMessage = (int)$startMessage; |
186 | |
187 | $sTplDir = $oTemplate->template_dir; |
715225af |
188 | |
0365891c |
189 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
91c27aee |
190 | |
d03f3582 |
191 | if (!isset($frame_top)) { |
192 | $frame_top = '_top'; |
193 | } |
715225af |
194 | |
c18f58c5 |
195 | if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) { |
5fe8257d |
196 | $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
91c27aee |
197 | if ($sHeaderJs) { |
a3d59ec3 |
198 | $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
91c27aee |
199 | "\n<!--\n" . |
a3d59ec3 |
200 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
d62c4938 |
201 | } |
91c27aee |
202 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
5fe8257d |
203 | } else { |
d62c4938 |
204 | /* do not use JavaScript */ |
205 | displayHtmlHeader ('SquirrelMail'); |
91c27aee |
206 | $sBodyTagJs = ''; |
715225af |
207 | } |
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 | |
249 | global $reply_focus, $javascript_on, $action; |
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) { |
270 | $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
271 | "\n<!--\n" . |
a3d59ec3 |
272 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
91c27aee |
273 | } else { |
5fe8257d |
274 | $sJsBlock = ''; |
d62c4938 |
275 | } |
91c27aee |
276 | $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
277 | displayHtmlHeader (_("Compose"), $sJsBlock); |
d62c4938 |
278 | } else { |
279 | /* javascript off */ |
280 | displayHtmlHeader(_("Compose")); |
281 | $onload = ''; |
9c3e6cd4 |
282 | } |
91c27aee |
283 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
9c3e6cd4 |
284 | } |
cbd8c251 |
285 | ?> |