59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Prints the page header (duh) |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
46d38f78 |
14 | require_once('../functions/strings.php'); |
f3e14140 |
15 | require_once('../functions/imap_utf7_decode_local.php'); |
b01b21d0 |
16 | require_once('../functions/html.php'); |
ec291321 |
17 | require_once('../class/html.class'); |
43fdb2a4 |
18 | |
34c90574 |
19 | /* Always set up the language before calling these functions */ |
a07cd1a4 |
20 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
692155b7 |
21 | |
2c21ef20 |
22 | global $theme_css, $custom_css, $base_uri; |
23 | |
8f1ba72b |
24 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' . |
25 | "\n\n<HTML>\n<HEAD>\n"; |
2c21ef20 |
26 | |
a714cb95 |
27 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
28 | if ($theme_css != '') { |
34c90574 |
29 | echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">"; |
692155b7 |
30 | } |
8f1ba72b |
31 | } else { |
2c21ef20 |
32 | echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' . |
67dfe419 |
33 | $base_uri . 'themes/css/'.$custom_css.'">'; |
8f1ba72b |
34 | } |
cdaf8338 |
35 | |
36 | if ($do_hook) { |
37 | do_hook ("generic_header"); |
38 | } |
8f1ba72b |
39 | |
34c90574 |
40 | echo "\n<title>$title</title>$xtra</head>\n\n"; |
a07cd1a4 |
41 | } |
42 | |
43 | function displayInternalLink($path, $text, $target='') { |
44 | global $base_uri; |
45 | |
46 | if ($target != '') { |
47 | $target = " target=\"$target\""; |
48 | } |
49 | |
50 | echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
51 | } |
52 | |
aca403fa |
53 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
715225af |
54 | |
07687736 |
55 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, |
aca403fa |
56 | $compose_new_win, $username, $datadir, $compose_width, $compose_height, |
57 | $attachemessages, $session; |
715225af |
58 | |
715225af |
59 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
f3e14140 |
60 | if ($qmark = strpos($module, '?')) { |
61 | $module = substr($module, 0, $qmark); |
62 | } |
d03f3582 |
63 | if (!isset($frame_top)) { |
64 | $frame_top = '_top'; |
65 | } |
715225af |
66 | |
67 | /* |
68 | Locate the first displayable form element |
69 | */ |
aca403fa |
70 | |
cb6b53c6 |
71 | if ($session != false) { |
aca403fa |
72 | $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
73 | } else { |
d7f8e6e6 |
74 | $compose_uri = 'src/compose.php?newmessage=1'; |
75 | $session = 0; |
aca403fa |
76 | } |
cb6b53c6 |
77 | |
715225af |
78 | switch ( $module ) { |
f3e14140 |
79 | case 'src/read_body.php': |
80 | if ($compose_new_win == '1') { |
81 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
82 | $compose_width = '640'; |
83 | } |
84 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
85 | $compose_height = '550'; |
86 | } |
87 | $js = "\n".'<script language="JavaScript" type="text/javascript">' . |
88 | "\n<!--\n"; |
d7f8e6e6 |
89 | $js .= "function comp_in_new(new_mes, comp_uri) {\n". |
90 | ' if (new_mes) { '."\n". |
43ee2b5c |
91 | " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n". |
d7f8e6e6 |
92 | ' } else { '."\n". |
93 | " if (comp_uri =='') {\n". |
94 | ' comp_uri = "'.$base_uri.$compose_uri."\";\n". |
95 | ' }'. "\n". |
96 | ' }'. "\n". |
97 | ' var newwin = window.open(comp_uri' . |
98 | ', "_blank", |
99 | "width='.$compose_width.",height=$compose_height". |
f3e14140 |
100 | ",scrollbars=yes,resizable=yes\");\n". |
101 | "}\n"; |
d7f8e6e6 |
102 | |
f3e14140 |
103 | $js .= "// -->\n". |
104 | "</script>\n"; |
105 | displayHtmlHeader ('Squirrelmail', $js); |
106 | } |
107 | displayHtmlHeader(); |
aca403fa |
108 | $onload = $xtra; |
f3e14140 |
109 | break; |
d7f8e6e6 |
110 | case 'src/compose.php': |
111 | $js = '<script language="JavaScript" type="text/javascript">' . |
112 | "\n<!--\n" . |
113 | "function checkForm() {\n". |
114 | "var f = document.forms.length;\n". |
115 | "var i = 0;\n". |
116 | "var pos = -1;\n". |
117 | "while( pos == -1 && i < f ) {\n". |
118 | "var e = document.forms[i].elements.length;\n". |
119 | "var j = 0;\n". |
120 | "while( pos == -1 && j < e ) {\n". |
121 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
122 | "pos = j;\n". |
123 | "}\n". |
124 | "j++;\n". |
125 | "}\n". |
126 | "i++;\n". |
127 | "}\n". |
128 | "if( pos >= 0 ) {\n". |
129 | "document.forms[i-1].elements[pos].focus();\n". |
130 | "}\n". |
131 | "}\n"; |
132 | |
133 | $js .= "// -->\n". |
134 | "</script>\n"; |
135 | $onload = "onLoad=\"checkForm();\""; |
136 | displayHtmlHeader ('Squirrelmail', $js); |
137 | break; |
138 | |
715225af |
139 | default: |
aaf16822 |
140 | $js = '<script language="JavaScript" type="text/javascript">' . |
353616c4 |
141 | "\n<!--\n" . |
142 | "function checkForm() {\n". |
143 | "var f = document.forms.length;\n". |
144 | "var i = 0;\n". |
145 | "var pos = -1;\n". |
146 | "while( pos == -1 && i < f ) {\n". |
147 | "var e = document.forms[i].elements.length;\n". |
148 | "var j = 0;\n". |
149 | "while( pos == -1 && j < e ) {\n". |
150 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
151 | "pos = j;\n". |
152 | "}\n". |
153 | "j++;\n". |
154 | "}\n". |
155 | "i++;\n". |
156 | "}\n". |
157 | "if( pos >= 0 ) {\n". |
158 | "document.forms[i-1].elements[pos].focus();\n". |
159 | "}\n". |
de19cd73 |
160 | "$xtra\n". |
9c3e6cd4 |
161 | "}\n"; |
f3e14140 |
162 | |
9c3e6cd4 |
163 | if ($compose_new_win == '1') { |
07687736 |
164 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
165 | $compose_width = '640'; |
9c3e6cd4 |
166 | } |
07687736 |
167 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
168 | $compose_height = '550'; |
9c3e6cd4 |
169 | } |
d7f8e6e6 |
170 | $js .= "function comp_in_new(new_mes, comp_uri) {\n". |
171 | ' if (new_mes) { '."\n". |
cb6b53c6 |
172 | " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n". |
d7f8e6e6 |
173 | ' } else { '."\n". |
174 | " if (comp_uri =='') {\n". |
175 | ' comp_uri = "'.$base_uri.$compose_uri."\";\n". |
176 | ' }'. "\n". |
177 | ' }'. "\n". |
d7f8e6e6 |
178 | ' var newwin = window.open(comp_uri' . |
179 | ', "_blank", |
f3e14140 |
180 | "width='.$compose_width.",height=$compose_height". |
9c3e6cd4 |
181 | ",scrollbars=yes,resizable=yes\");\n". |
182 | "}\n"; |
183 | } |
aaf16822 |
184 | $js .= "// -->\n". |
de19cd73 |
185 | "</script>\n"; |
715225af |
186 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
187 | displayHtmlHeader ('Squirrelmail', $js); |
715225af |
188 | break; |
189 | |
190 | } |
191 | |
b01b21d0 |
192 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
193 | /** Here is the header and wrapping table **/ |
f3e14140 |
194 | $shortBoxName = imap_utf7_decode_local( |
195 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
196 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
197 | $shortBoxName = _("INBOX"); |
198 | } |
b01b21d0 |
199 | echo "<a name=\"pagetop\"></a>\n" |
200 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
201 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
202 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
203 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
204 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
205 | } else { |
206 | echo ' '; |
207 | } |
b01b21d0 |
208 | echo " </td>\n" |
209 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
210 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
211 | echo "</b></td>\n" |
212 | . " </tr>\n" |
213 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
214 | . html_tag( 'td', '', 'left' ) ."\n"; |
a07cd1a4 |
215 | $urlMailbox = urlencode($mailbox); |
9c3e6cd4 |
216 | if ($compose_new_win == '1') { |
d7f8e6e6 |
217 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>'; |
9c3e6cd4 |
218 | } |
219 | else { |
220 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
221 | } |
a07cd1a4 |
222 | echo " \n"; |
223 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
224 | echo " \n"; |
225 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
226 | echo " \n"; |
227 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
228 | echo " \n"; |
229 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
230 | echo " \n"; |
231 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
232 | echo " \n"; |
233 | |
234 | do_hook("menuline"); |
235 | |
b01b21d0 |
236 | echo " </td>\n" |
237 | . html_tag( 'td', '', 'right' ) ."\n"; |
a07cd1a4 |
238 | echo ($hide_sm_attributions ? ' ' : |
b01b21d0 |
239 | '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>'); |
240 | echo "</td>\n". |
241 | " </tr>\n". |
242 | "</table>\n\n"; |
a07cd1a4 |
243 | } |
2ba13803 |
244 | |
9c3e6cd4 |
245 | /* blatently copied/truncated/modified from the above function */ |
246 | function compose_Header($color, $mailbox) { |
247 | |
248 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
249 | |
9c3e6cd4 |
250 | |
251 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
252 | if (!isset($frame_top)) { |
253 | $frame_top = '_top'; |
254 | } |
255 | |
256 | /* |
257 | Locate the first displayable form element |
258 | */ |
259 | switch ( $module ) { |
260 | case 'src/search.php': |
261 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
262 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
aaf16822 |
263 | displayHtmlHeader (_("Compose")); |
9c3e6cd4 |
264 | break; |
265 | default: |
aaf16822 |
266 | $js = '<script language="JavaScript" type="text/javascript">' . |
9c3e6cd4 |
267 | "\n<!--\n" . |
268 | "function checkForm() {\n". |
269 | "var f = document.forms.length;\n". |
270 | "var i = 0;\n". |
271 | "var pos = -1;\n". |
272 | "while( pos == -1 && i < f ) {\n". |
273 | "var e = document.forms[i].elements.length;\n". |
274 | "var j = 0;\n". |
275 | "while( pos == -1 && j < e ) {\n". |
276 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
277 | "pos = j;\n". |
278 | "}\n". |
279 | "j++;\n". |
280 | "}\n". |
281 | "i++;\n". |
282 | "}\n". |
283 | "if( pos >= 0 ) {\n". |
284 | "document.forms[i-1].elements[pos].focus();\n". |
285 | "}\n". |
286 | "}\n"; |
aaf16822 |
287 | $js .= "// -->\n". |
de19cd73 |
288 | "</script>\n"; |
9c3e6cd4 |
289 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
290 | displayHtmlHeader (_("Compose"), $js); |
9c3e6cd4 |
291 | break; |
292 | |
293 | } |
294 | |
b01b21d0 |
295 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
9c3e6cd4 |
296 | } |
ec291321 |
297 | |
298 | function initPage () { |
299 | |
300 | global $theme_css, $custom_css, $base_uri; |
301 | $page = new html(); |
e5128562 |
302 | $page->addChild('','<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'); |
303 | $page->addChild('HTML'); |
ec291321 |
304 | return $page; |
305 | } |
306 | |
307 | function initHead ($title = 'SquirrelMail') { |
308 | global $use_css, $compose_new_win, $compose_width, $compose_height, |
309 | $base_uri; |
310 | |
311 | $head = new html('head'); |
312 | $head->addChild('title', $title); |
313 | if ($use_css) { |
314 | $head->addChild('link','','','','', |
315 | array('REL' => 'stylesheet', 'TYPE' => 'text/css', |
316 | 'HREF' => $base_uri .'/css/read_body.css')); |
317 | } |
318 | if ($compose_new_win == '1') { |
319 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
320 | $compose_width = '640'; |
321 | } |
322 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
323 | $compose_height = '550'; |
324 | } |
325 | $js = "function comp_in_new(new_mes, comp_uri) {\n". |
326 | ' if (new_mes) { '."\n". |
327 | " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n". |
328 | ' } else { '."\n". |
329 | " if (comp_uri =='') {\n". |
330 | ' comp_uri = "'.$base_uri.$compose_uri."\";\n". |
331 | ' }'. "\n". |
332 | ' }'. "\n". |
333 | ' var newwin = window.open(comp_uri' . |
334 | ', "_blank", |
335 | "width='.$compose_width.",height=$compose_height". |
336 | ",scrollbars=yes,resizable=yes\");\n". |
337 | "}\n"; |
338 | $head->scriptAdd($js); |
339 | } |
340 | return $head; |
341 | } |
342 | |
343 | function initBody($color, $javascript='') { |
344 | global $use_css; |
345 | |
346 | if (!$use_css) { |
347 | $body = new html('body','','','','', |
348 | array('bgcolor' => $color[4], 'text' => $color[8], 'link' => $color[7], |
349 | 'vlink' => $color[7], 'alink' => $color[7]), $javascript); |
350 | } else { |
351 | $body = new html('body','','','','','',$javascript); |
352 | } |
353 | return $body; |
354 | } |
355 | |
356 | |
357 | function getTop($color, $mailbox) { |
358 | |
359 | global $use_css, $languages, $squirrelmail_language, $frame_top, |
360 | $delimiter, $base_uri; |
361 | |
362 | if ( isset( $languages[$squirrelmail_language]['DIR']) ) { |
363 | $dir = $languages[$squirrelmail_language]['DIR']; |
364 | } else { |
365 | $dir = 'ltr'; |
366 | } |
367 | |
368 | if ( $dir == 'ltr' ) { |
369 | $rgt = 'right'; |
370 | $lft = 'left'; |
371 | } else { |
372 | $rgt = 'left'; |
373 | $lft = 'right'; |
374 | } |
375 | |
376 | |
377 | |
378 | if (!$use_css) { |
379 | $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%', |
380 | 'cellspacing' => 0, 'cellpadding' => 2); |
381 | $row_ar = array('bgcolor' => $color[9]); |
382 | $col_ar = array('align' => $lft); |
383 | } else { |
384 | $tbl_ar = array('border' => 0, |
385 | 'cellspacing' => 0, 'cellpadding' => 2); |
386 | $row_ar = ''; |
387 | $col_ar = array('align' => $lft); |
388 | } |
389 | |
390 | $shortBoxName = imap_utf7_decode_local( |
391 | readShortMailboxName($mailbox, $delimiter)); |
392 | if ( $shortBoxName == 'INBOX' ) { |
393 | $shortBoxName = _("INBOX"); |
394 | } |
395 | |
396 | $top = new html('table','','','tp','tp',$tbl_ar); |
397 | $row = new html('tr','','','tp_r','tp_r',$row_ar); |
398 | |
399 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
400 | $row->addChild('td',_("Current Folder") .':','','tp_c','tp_mbx_k', |
401 | array('align' => $lft)); |
d8286bfa |
402 | $row->addChild('td',$shortBoxName .' ',array('b'=>true),'tp_c', |
ec291321 |
403 | 'tp_mbx_v',array('align' => $lft)); |
404 | } |
405 | $col = new html('td','','','tp_c','tp_so',array('align' => $rgt)); |
406 | if ($frame_top) { |
407 | $lnk_ar = array('href' => $base_uri.'src/signout.php', 'target' => $frame_top); |
408 | } else { |
409 | $lnk_ar = array('href' => $base_uri.'src/signout.php'); |
410 | } |
411 | $col->addChild('a', _("Sign Out"),array('b'=>true),'','',$lnk_ar); |
412 | $row->htmlAdd($col); |
413 | $top->htmlAdd($row); |
414 | |
415 | return $top; |
416 | } |
417 | |
418 | function getMenu($color,$mailbox) { |
419 | global $use_css, $languages, $squirrelmail_language, $frame_top, $base_uri, |
420 | $compose_new_win,$hide_sm_attributions; |
421 | |
422 | $urlMailbox = urlencode($mailbox); |
423 | |
424 | if ( isset( $languages[$squirrelmail_language]['DIR']) ) { |
425 | $dir = $languages[$squirrelmail_language]['DIR']; |
426 | } else { |
427 | $dir = 'ltr'; |
428 | } |
429 | |
430 | if ( $dir == 'ltr' ) { |
431 | $rgt = 'right'; |
432 | $lft = 'left'; |
433 | } else { |
434 | $rgt = 'left'; |
435 | $lft = 'right'; |
436 | } |
437 | |
438 | if (!$use_css) { |
439 | $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%', |
440 | 'cellspacing' => 0, 'cellpadding' => 2); |
441 | $row_ar = array('bgcolor' => $color[4]); |
442 | $col_ar = array('align' => $lft); |
443 | } else { |
444 | $tbl_ar = array('border' => 0, |
445 | 'cellspacing' => 0, 'cellpadding' => 2); |
446 | $row_ar = ''; |
447 | $col_ar = array('align' => $lft); |
448 | } |
449 | |
450 | $menu = new html('table','','','mn','mn',$tbl_ar); |
451 | $row = new html('tr','','','mn','mn_r',$row_ar); |
452 | $col = new html('td','','','mn','mn_c',$col_ar); |
453 | $delimiter = new html('',' '); |
454 | if ($compose_new_win == '1') { |
455 | $col->addChild('a',_("Compose"),'','mn_c','mn_co', |
456 | array('href' => 'javascript:void(0)'), |
457 | array('onclick'=>'comp_in_new(true,"")')); |
458 | } else { |
459 | $col->addChild('a',_("Compose"),'','mn_c','mn_co', |
460 | array('href' => $base_uri.'src/compose.php?mailbox='.$urlMailbox, |
461 | 'target' => 'right')); |
462 | } |
463 | $col->htmlAdd($delimiter); |
464 | $col->addChild('a',_("Addresses"),'','mn_c','mn_ad', |
465 | array('href' => $base_uri.'src/addressbook.php', |
466 | 'target' => 'right')); |
467 | $col->htmlAdd($delimiter); |
468 | $col->addChild('a',_("Folders"),'','mn_c','mn_fo', |
469 | array('href' => $base_uri.'src/folders.php', |
470 | 'target' => 'right')); |
471 | $col->htmlAdd($delimiter); |
472 | |
473 | $col->addChild('a',_("Options"),'','mn_c','mn_op', |
474 | array('href' => $base_uri.'src/options.php', |
475 | 'target' => 'right')); |
476 | $col->htmlAdd($delimiter); |
477 | $col->addChild('a',_("Search"),'','mn_c','mn_se', |
478 | array('href' => $base_uri.'src/search.php?mailbox='.$urlMailbox, |
479 | 'target' => 'right')); |
480 | $col->htmlAdd($delimiter); |
481 | $col->addChild('a',_("Help"),'','mn_c','mn_he', |
482 | array('href' => $base_uri.'src/help.php', |
483 | 'target' => 'right')); |
484 | |
485 | do_hook("menuline"); |
486 | $row->htmlAdd($col); |
487 | if (!$hide_sm_attributions) { |
488 | $col = new html('td','','','mn','mn_sm',array('align'=>$rgt)); |
489 | $col->addChild('a','SquirrelMail','','','', |
490 | array('href'=>'http://www.squirrelmail.org','target'=>'_blank')); |
491 | $row->htmlAdd($col); |
492 | } |
493 | $menu->htmlAdd($row); |
494 | return $menu; |
495 | } |
496 | |
43fdb2a4 |
497 | ?> |