59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
35586184 |
6 | * Prints the page header (duh) |
7 | * |
4b4abf93 |
8 | * @copyright © 1999-2005 The SquirrelMail Project Team |
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'); |
b68edc75 |
22 | |
d6c32258 |
23 | /** |
8b096f0a |
24 | * Output a SquirrelMail page header, from <!doctype> to </head> |
25 | * Always set up the language before calling these functions. |
26 | * |
81132de8 |
27 | * Since 1.5.1 function sends http headers. Function should be called |
28 | * before any output is started. |
8b096f0a |
29 | * @param string title the page title, default SquirrelMail. |
30 | * @param string xtra extra HTML to insert into the header |
31 | * @param bool do_hook whether to execute hooks, default true |
62b9c984 |
32 | * @param bool frames generate html frameset doctype (since 1.5.1) |
8b096f0a |
33 | * @return void |
d6c32258 |
34 | */ |
62b9c984 |
35 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) { |
e842b215 |
36 | global $squirrelmail_language; |
692155b7 |
37 | |
0365891c |
38 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
0b97a708 |
39 | global $base_uri; |
40 | } |
81132de8 |
41 | global $theme_css, $custom_css, $pageheader_sent, |
42 | $chosen_fontset, $chosen_fontsize, $chosen_theme; |
43 | |
44 | /* add no cache headers here */ |
45 | header('Pragma: no-cache'); // http 1.0 (rfc1945) |
46 | header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616) |
2c21ef20 |
47 | |
62b9c984 |
48 | if ($frames) { |
49 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">'; |
91e0dccc |
50 | } else { |
62b9c984 |
51 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
52 | } |
f9f738dc |
53 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
54 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
2c21ef20 |
55 | |
81132de8 |
56 | |
57 | $used_theme = basename($chosen_theme,'.php'); |
58 | |
fcae5445 |
59 | /* |
60 | * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional. |
61 | * It is not compatible with html 4.01 Transitional |
62 | */ |
81132de8 |
63 | echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php' |
64 | .'?fontset='.$chosen_fontset |
65 | .'&themeid='.$used_theme |
66 | .(isset($chosen_fontsize) ? '&fontsize='.$chosen_fontsize : '')."\">\n"; |
67 | |
68 | // load custom style sheet (deprecated) |
69 | if ( !isset( $theme_css ) || empty($theme_css) ) { |
70 | echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">"; |
8f1ba72b |
71 | } |
62f7daa5 |
72 | |
e842b215 |
73 | if ($squirrelmail_language == 'ja_JP') { |
683b7853 |
74 | /* |
e50f5ac2 |
75 | * force correct detection of charset, when browser does not follow |
683b7853 |
76 | * http content-type and tries to detect charset from page content. |
77 | * Shooting of browser's creator can't be implemented in php. |
e50f5ac2 |
78 | * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/ |
683b7853 |
79 | * recommendations and switch to unicode. |
e50f5ac2 |
80 | */ |
e842b215 |
81 | echo "<!-- \xfd\xfe -->\n"; |
fcae5445 |
82 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
83 | } |
237470b4 |
84 | if ($do_hook) { |
d68323ff |
85 | do_hook('generic_header'); |
237470b4 |
86 | } |
62f7daa5 |
87 | |
f9f738dc |
88 | echo "<title>$title</title>\n$xtra\n"; |
5ca4b1ee |
89 | |
90 | /* work around IE6's scrollbar bug */ |
91 | echo <<<ECHO |
92 | <style type="text/css"> |
93 | <!-- |
94 | /* avoid stupid IE6 bug with frames and scrollbars */ |
62f7daa5 |
95 | body { |
96 | voice-family: "\"}\""; |
97 | voice-family: inherit; |
5ca4b1ee |
98 | width: expression(document.documentElement.clientWidth - 30); |
99 | } |
100 | --> |
101 | </style> |
102 | |
103 | ECHO; |
104 | |
105 | echo "\n</head>\n\n"; |
b6c283c4 |
106 | |
107 | /* this is used to check elsewhere whether we should call this function */ |
108 | $pageheader_sent = TRUE; |
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='') { |
0365891c |
119 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
dcc1cc82 |
120 | if ($target != '') { |
121 | $target = " target=\"$target\""; |
122 | } |
4910106a |
123 | |
e50f5ac2 |
124 | // This is an inefficient hook and is only used by |
4910106a |
125 | // one plugin that still needs to patch this code, |
e50f5ac2 |
126 | // plus if we are templat-izing SM, visual hooks |
127 | // are not needed. However, I am leaving the code |
128 | // here just in case we find a good (non-visual?) |
4910106a |
129 | // use for the internal_link hook. |
130 | // |
131 | //$hooktext = do_hook_function('internal_link',$text); |
132 | //if ($hooktext != '') |
133 | // $text = $hooktext; |
134 | |
d62c4938 |
135 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
136 | } |
137 | |
8b096f0a |
138 | /** |
139 | * Same as makeInternalLink, but echoes it too |
140 | */ |
d62c4938 |
141 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
142 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
143 | } |
144 | |
8b096f0a |
145 | /** |
146 | * Outputs a complete SquirrelMail page header, starting with <!doctype> and |
147 | * including the default menu bar. Uses displayHtmlHeader and takes |
148 | * JavaScript and locale settings into account. |
149 | * |
150 | * @param array color the array of theme colors |
151 | * @param string mailbox the current mailbox name to display |
91c27aee |
152 | * @param string sHeaderJs javascipt code to be inserted in a script block in the header |
153 | * @param string sBodyTagJs js events to be inserted in the body tag |
8b096f0a |
154 | * @return void |
155 | */ |
715225af |
156 | |
10bf80c0 |
157 | function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
158 | |
159 | global $reply_focus, $hide_sm_attributions, $frame_top, |
ce68b76b |
160 | $provider_name, $provider_uri, $startMessage, |
10bf80c0 |
161 | $javascript_on, $action; |
162 | |
163 | if (empty($sBodyTagJs)) { |
164 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
165 | if ($reply_focus == 'select') |
166 | $sBodyTagJs = 'onload="checkForm(\'select\');"'; |
167 | else if ($reply_focus == 'focus') |
168 | $sBodyTagJs = 'onload="checkForm(\'focus\');"'; |
169 | else if ($reply_focus != 'none') |
170 | $sBodyTagJs = 'onload="checkForm();"'; |
171 | } |
172 | else |
173 | $sBodyTagJs = 'onload="checkForm();"'; |
174 | } |
175 | |
715225af |
176 | |
0365891c |
177 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
91c27aee |
178 | |
d03f3582 |
179 | if (!isset($frame_top)) { |
180 | $frame_top = '_top'; |
181 | } |
715225af |
182 | |
c18f58c5 |
183 | if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) { |
a3d59ec3 |
184 | $sJsBlock = '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
91c27aee |
185 | if ($sHeaderJs) { |
a3d59ec3 |
186 | $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
91c27aee |
187 | "\n<!--\n" . |
a3d59ec3 |
188 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
d62c4938 |
189 | } |
91c27aee |
190 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
191 | } else { |
d62c4938 |
192 | /* do not use JavaScript */ |
193 | displayHtmlHeader ('SquirrelMail'); |
91c27aee |
194 | $sBodyTagJs = ''; |
715225af |
195 | } |
196 | |
81132de8 |
197 | echo "<body $sBodyTagJs>\n\n"; |
91c27aee |
198 | |
a07cd1a4 |
199 | /** Here is the header and wrapping table **/ |
72520f77 |
200 | $shortBoxName = htmlspecialchars(imap_utf7_decode_local( |
91e0dccc |
201 | readShortMailboxName($mailbox, $delimiter))); |
3b7d68e6 |
202 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
203 | $shortBoxName = _("INBOX"); |
204 | } |
b01b21d0 |
205 | echo "<a name=\"pagetop\"></a>\n" |
206 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
207 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
208 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
209 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
210 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
211 | } else { |
212 | echo ' '; |
213 | } |
b01b21d0 |
214 | echo " </td>\n" |
215 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
216 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
217 | echo "</b></td>\n" |
218 | . " </tr>\n" |
219 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
99ea51d3 |
220 | . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' ) |
221 | : html_tag( 'td', '', 'left' ) ) |
222 | . "\n"; |
a07cd1a4 |
223 | $urlMailbox = urlencode($mailbox); |
0493ed11 |
224 | $startMessage = (int)$startMessage; |
225 | |
e233a3ad |
226 | echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage); |
a07cd1a4 |
227 | echo " \n"; |
21a957a9 |
228 | displayInternalLink ('src/addressbook.php', _("Addresses")); |
a07cd1a4 |
229 | echo " \n"; |
21a957a9 |
230 | displayInternalLink ('src/folders.php', _("Folders")); |
a07cd1a4 |
231 | echo " \n"; |
21a957a9 |
232 | displayInternalLink ('src/options.php', _("Options")); |
a07cd1a4 |
233 | echo " \n"; |
21a957a9 |
234 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search")); |
a07cd1a4 |
235 | echo " \n"; |
21a957a9 |
236 | displayInternalLink ('src/help.php', _("Help")); |
a07cd1a4 |
237 | echo " \n"; |
238 | |
d68323ff |
239 | do_hook('menuline'); |
a07cd1a4 |
240 | |
99ea51d3 |
241 | echo " </td>\n"; |
242 | |
243 | if (!$hide_sm_attributions) |
244 | { |
245 | echo html_tag( 'td', '', 'right' ) ."\n"; |
8b5c49cd |
246 | if (empty($provider_uri)) { |
247 | echo '<a href="about.php">SquirrelMail</a>'; |
248 | } else { |
249 | if (empty($provider_name)) $provider_name= 'SquirrelMail'; |
250 | echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'; |
251 | } |
99ea51d3 |
252 | echo "</td>\n"; |
253 | } |
254 | echo " </tr>\n". |
04fa3c41 |
255 | "</table><br />\n\n"; |
a07cd1a4 |
256 | } |
2ba13803 |
257 | |
8b096f0a |
258 | /** |
259 | * Blatantly copied/truncated/modified from displayPageHeader. |
260 | * Outputs a page header specifically for the compose_in_new popup window |
261 | * |
262 | * @param array color the array of theme colors |
263 | * @param string mailbox the current mailbox name to display |
91c27aee |
264 | * @param string sHeaderJs javascipt code to be inserted in a script block in the header |
265 | * @param string sBodyTagJs js events to be inserted in the body tag |
8b096f0a |
266 | * @return void |
267 | */ |
10bf80c0 |
268 | function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { |
269 | |
270 | global $reply_focus, $javascript_on, $action; |
271 | |
272 | if (empty($sBodyTagJs)) { |
273 | if (strpos($action, 'reply') !== FALSE && $reply_focus) { |
274 | if ($reply_focus == 'select') |
275 | $sBodyTagJs = 'onload="checkForm(\'select\');"'; |
276 | else if ($reply_focus == 'focus') |
277 | $sBodyTagJs = 'onload="checkForm(\'focus\');"'; |
278 | else if ($reply_focus != 'none') |
279 | $sBodyTagJs = 'onload="checkForm();"'; |
280 | } |
281 | else |
282 | $sBodyTagJs = 'onload="checkForm();"'; |
283 | } |
284 | |
285 | |
9c3e6cd4 |
286 | /* |
d62c4938 |
287 | * Locate the first displayable form element (only when JavaScript on) |
288 | */ |
289 | if($javascript_on) { |
91c27aee |
290 | if ($sHeaderJs) { |
291 | $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
292 | "\n<!--\n" . |
a3d59ec3 |
293 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
91c27aee |
294 | } else { |
295 | $sJsBlock = ''; |
d62c4938 |
296 | } |
91c27aee |
297 | $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
298 | displayHtmlHeader (_("Compose"), $sJsBlock); |
d62c4938 |
299 | } else { |
300 | /* javascript off */ |
301 | displayHtmlHeader(_("Compose")); |
302 | $onload = ''; |
9c3e6cd4 |
303 | } |
91c27aee |
304 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
9c3e6cd4 |
305 | } |
10bf80c0 |
306 | ?> |