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) |
8b096f0a |
34 | * @return void |
d6c32258 |
35 | */ |
62b9c984 |
36 | function 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 | } |
5fe8257d |
42 | global $theme_css, $custom_css, $pageheader_sent, |
81132de8 |
43 | $chosen_fontset, $chosen_fontsize, $chosen_theme; |
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) { |
50 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">'; |
91e0dccc |
51 | } else { |
62b9c984 |
52 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
53 | } |
f9f738dc |
54 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
55 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
2c21ef20 |
56 | |
5fe8257d |
57 | |
81132de8 |
58 | $used_theme = basename($chosen_theme,'.php'); |
59 | |
fcae5445 |
60 | /* |
5fe8257d |
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 |
63 | */ |
81132de8 |
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"; |
68 | |
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\">"; |
8f1ba72b |
72 | } |
62f7daa5 |
73 | |
e842b215 |
74 | if ($squirrelmail_language == 'ja_JP') { |
683b7853 |
75 | /* |
5fe8257d |
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. |
81 | */ |
e842b215 |
82 | echo "<!-- \xfd\xfe -->\n"; |
fcae5445 |
83 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
84 | } |
237470b4 |
85 | if ($do_hook) { |
d68323ff |
86 | do_hook('generic_header'); |
237470b4 |
87 | } |
62f7daa5 |
88 | |
f9f738dc |
89 | echo "<title>$title</title>\n$xtra\n"; |
5ca4b1ee |
90 | |
91 | /* work around IE6's scrollbar bug */ |
92 | echo <<<ECHO |
93 | <style type="text/css"> |
94 | <!-- |
5fe8257d |
95 | /* avoid stupid IE6 bug with frames and scrollbars */ |
96 | body { |
97 | voice-family: "\"}\""; |
98 | voice-family: inherit; |
99 | width: expression(document.documentElement.clientWidth - 30); |
100 | } |
5ca4b1ee |
101 | --> |
102 | </style> |
103 | |
104 | ECHO; |
105 | |
106 | echo "\n</head>\n\n"; |
b6c283c4 |
107 | |
108 | /* this is used to check elsewhere whether we should call this function */ |
109 | $pageheader_sent = TRUE; |
a07cd1a4 |
110 | } |
111 | |
8b096f0a |
112 | /** |
113 | * Given a path to a SquirrelMail file, return a HTML link to it |
114 | * |
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 |
118 | */ |
d62c4938 |
119 | function makeInternalLink($path, $text, $target='') { |
0365891c |
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') ) { |
5fe8257d |
189 | $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
91c27aee |
190 | if ($sHeaderJs) { |
a3d59ec3 |
191 | $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
91c27aee |
192 | "\n<!--\n" . |
a3d59ec3 |
193 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
d62c4938 |
194 | } |
91c27aee |
195 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
5fe8257d |
196 | } else { |
d62c4938 |
197 | /* do not use JavaScript */ |
198 | displayHtmlHeader ('SquirrelMail'); |
91c27aee |
199 | $sBodyTagJs = ''; |
715225af |
200 | } |
201 | |
72520f77 |
202 | $shortBoxName = htmlspecialchars(imap_utf7_decode_local( |
91e0dccc |
203 | readShortMailboxName($mailbox, $delimiter))); |
3b7d68e6 |
204 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
205 | $shortBoxName = _("INBOX"); |
206 | } |
0493ed11 |
207 | |
5fe8257d |
208 | $sm_attributes = ''; |
209 | if (!$hide_sm_attributions) { |
210 | $sm_attributes .= '<td class="sqm_providerInfo">' ."\n"; |
8b5c49cd |
211 | if (empty($provider_uri)) { |
5fe8257d |
212 | $sm_attributes .= ' <a href="about.php">SquirrelMail</a>'; |
8b5c49cd |
213 | } else { |
214 | if (empty($provider_name)) $provider_name= 'SquirrelMail'; |
5fe8257d |
215 | $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n"; |
8b5c49cd |
216 | } |
5fe8257d |
217 | $sm_attributes .= " </td>\n"; |
99ea51d3 |
218 | } |
5fe8257d |
219 | |
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'); |
a07cd1a4 |
228 | } |
2ba13803 |
229 | |
8b096f0a |
230 | /** |
231 | * Blatantly copied/truncated/modified from displayPageHeader. |
232 | * Outputs a page header specifically for the compose_in_new popup window |
233 | * |
234 | * @param array color the array of theme colors |
235 | * @param string mailbox the current mailbox name to display |
91c27aee |
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 |
8b096f0a |
238 | * @return void |
239 | */ |
10bf80c0 |
240 | function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
241 | |
242 | global $reply_focus, $javascript_on, $action; |
243 | |
244 | if (empty($sBodyTagJs)) { |
245 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
5fe8257d |
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();"'; |
10bf80c0 |
252 | } |
253 | else |
5fe8257d |
254 | $sBodyTagJs = 'onload="checkForm();"'; |
10bf80c0 |
255 | } |
256 | |
257 | |
9c3e6cd4 |
258 | /* |
d62c4938 |
259 | * Locate the first displayable form element (only when JavaScript on) |
260 | */ |
261 | if($javascript_on) { |
91c27aee |
262 | if ($sHeaderJs) { |
263 | $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
264 | "\n<!--\n" . |
a3d59ec3 |
265 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
91c27aee |
266 | } else { |
5fe8257d |
267 | $sJsBlock = ''; |
d62c4938 |
268 | } |
91c27aee |
269 | $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
270 | displayHtmlHeader (_("Compose"), $sJsBlock); |
d62c4938 |
271 | } else { |
272 | /* javascript off */ |
273 | displayHtmlHeader(_("Compose")); |
274 | $onload = ''; |
9c3e6cd4 |
275 | } |
91c27aee |
276 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
9c3e6cd4 |
277 | } |
10bf80c0 |
278 | ?> |