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'); |
7884e6c4 |
15 | require_once('../functions/imap_utf7_decode_local.php'); |
16 | |
43fdb2a4 |
17 | |
34c90574 |
18 | /* Always set up the language before calling these functions */ |
a07cd1a4 |
19 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
692155b7 |
20 | |
2c21ef20 |
21 | global $theme_css, $custom_css, $base_uri; |
22 | |
8f1ba72b |
23 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' . |
24 | "\n\n<HTML>\n<HEAD>\n"; |
2c21ef20 |
25 | |
a714cb95 |
26 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
27 | if ($theme_css != '') { |
34c90574 |
28 | echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">"; |
692155b7 |
29 | } |
8f1ba72b |
30 | } else { |
2c21ef20 |
31 | echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' . |
67dfe419 |
32 | $base_uri . 'themes/css/'.$custom_css.'">'; |
8f1ba72b |
33 | } |
34 | |
34c90574 |
35 | echo "\n<title>$title</title>$xtra</head>\n\n"; |
a07cd1a4 |
36 | } |
37 | |
38 | function displayInternalLink($path, $text, $target='') { |
39 | global $base_uri; |
40 | |
41 | if ($target != '') { |
42 | $target = " target=\"$target\""; |
43 | } |
44 | |
45 | echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
46 | } |
47 | |
de19cd73 |
48 | function displayPageHeader($color, $mailbox, $xtra='') { |
715225af |
49 | |
07687736 |
50 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, |
ef0ea59e |
51 | $compose_new_win, $username, $datadir, $compose_width, $compose_height, $session, $attachemessages; |
715225af |
52 | |
715225af |
53 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
d03f3582 |
54 | if (!isset($frame_top)) { |
55 | $frame_top = '_top'; |
56 | } |
715225af |
57 | |
58 | /* |
59 | Locate the first displayable form element |
60 | */ |
61 | switch ( $module ) { |
715225af |
62 | default: |
aaf16822 |
63 | $js = '<script language="JavaScript" type="text/javascript">' . |
353616c4 |
64 | "\n<!--\n" . |
65 | "function checkForm() {\n". |
66 | "var f = document.forms.length;\n". |
67 | "var i = 0;\n". |
68 | "var pos = -1;\n". |
69 | "while( pos == -1 && i < f ) {\n". |
70 | "var e = document.forms[i].elements.length;\n". |
71 | "var j = 0;\n". |
72 | "while( pos == -1 && j < e ) {\n". |
73 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
74 | "pos = j;\n". |
75 | "}\n". |
76 | "j++;\n". |
77 | "}\n". |
78 | "i++;\n". |
79 | "}\n". |
80 | "if( pos >= 0 ) {\n". |
81 | "document.forms[i-1].elements[pos].focus();\n". |
82 | "}\n". |
de19cd73 |
83 | "$xtra\n". |
9c3e6cd4 |
84 | "}\n"; |
ef0ea59e |
85 | if (isset($attachemessages) && isset($session)) { |
86 | $compose_uri = 'compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
87 | } else { |
88 | $compose_uri = 'src/compose.php'; |
89 | } |
90 | |
9c3e6cd4 |
91 | if ($compose_new_win == '1') { |
07687736 |
92 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
93 | $compose_width = '640'; |
9c3e6cd4 |
94 | } |
07687736 |
95 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
96 | $compose_height = '550'; |
9c3e6cd4 |
97 | } |
aaf16822 |
98 | $js .= "function comp_in_new() {\n". |
ef0ea59e |
99 | ' var newwin = window.open("'.$base_uri.$compose_uri . '"' . |
100 | ', "compose_window", |
101 | "width='.$compose_width.",height=$compose_height". |
9c3e6cd4 |
102 | ",scrollbars=yes,resizable=yes\");\n". |
103 | "}\n"; |
104 | } |
aaf16822 |
105 | $js .= "// -->\n". |
de19cd73 |
106 | "</script>\n"; |
715225af |
107 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
108 | displayHtmlHeader ('Squirrelmail', $js); |
715225af |
109 | break; |
110 | |
111 | } |
112 | |
113 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
114 | /** Here is the header and wrapping table **/ |
7884e6c4 |
115 | $shortBoxName = imap_utf7_decode_local(readShortMailboxName($mailbox, $delimiter)); |
116 | |
3b7d68e6 |
117 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
118 | $shortBoxName = _("INBOX"); |
119 | } |
a07cd1a4 |
120 | echo "<A NAME=pagetop></A>\n" |
121 | . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n" |
122 | . " <TR BGCOLOR=\"$color[9]\" >\n" |
5bb2a991 |
123 | . " <TD ALIGN=left>\n"; |
124 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
125 | echo ' ' . _("Current Folder") . ": <B>$shortBoxName </B>\n"; |
126 | } else { |
127 | echo ' '; |
128 | } |
129 | echo " </TD>\n" |
34c90574 |
130 | . ' <TD ALIGN=right><b>'; |
80e86e94 |
131 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
34c90574 |
132 | echo "</b></TD>\n" |
a07cd1a4 |
133 | . " </TR>\n" |
134 | . " <TR BGCOLOR=\"$color[4]\">\n" |
135 | . " <TD ALIGN=left>\n"; |
136 | $urlMailbox = urlencode($mailbox); |
9c3e6cd4 |
137 | if ($compose_new_win == '1') { |
138 | echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=". |
9c8ba651 |
139 | '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>'; |
9c3e6cd4 |
140 | } |
141 | else { |
142 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
143 | } |
a07cd1a4 |
144 | echo " \n"; |
145 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
146 | echo " \n"; |
147 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
148 | echo " \n"; |
149 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
150 | echo " \n"; |
151 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
152 | echo " \n"; |
153 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
154 | echo " \n"; |
155 | |
156 | do_hook("menuline"); |
157 | |
34c90574 |
158 | echo " </TD>\n <TD ALIGN=\"right\">"; |
a07cd1a4 |
159 | echo ($hide_sm_attributions ? ' ' : |
34c90574 |
160 | '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>'); |
161 | echo "</TD>\n". |
a07cd1a4 |
162 | " </TR>\n". |
163 | "</TABLE>\n\n"; |
164 | } |
2ba13803 |
165 | |
9c3e6cd4 |
166 | /* blatently copied/truncated/modified from the above function */ |
167 | function compose_Header($color, $mailbox) { |
168 | |
169 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
170 | |
9c3e6cd4 |
171 | |
172 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
173 | if (!isset($frame_top)) { |
174 | $frame_top = '_top'; |
175 | } |
176 | |
177 | /* |
178 | Locate the first displayable form element |
179 | */ |
180 | switch ( $module ) { |
181 | case 'src/search.php': |
182 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
183 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
aaf16822 |
184 | displayHtmlHeader (_("Compose")); |
9c3e6cd4 |
185 | break; |
186 | default: |
aaf16822 |
187 | $js = '<script language="JavaScript" type="text/javascript">' . |
9c3e6cd4 |
188 | "\n<!--\n" . |
189 | "function checkForm() {\n". |
190 | "var f = document.forms.length;\n". |
191 | "var i = 0;\n". |
192 | "var pos = -1;\n". |
193 | "while( pos == -1 && i < f ) {\n". |
194 | "var e = document.forms[i].elements.length;\n". |
195 | "var j = 0;\n". |
196 | "while( pos == -1 && j < e ) {\n". |
197 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
198 | "pos = j;\n". |
199 | "}\n". |
200 | "j++;\n". |
201 | "}\n". |
202 | "i++;\n". |
203 | "}\n". |
204 | "if( pos >= 0 ) {\n". |
205 | "document.forms[i-1].elements[pos].focus();\n". |
206 | "}\n". |
207 | "}\n"; |
aaf16822 |
208 | $js .= "// -->\n". |
de19cd73 |
209 | "</script>\n"; |
9c3e6cd4 |
210 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
211 | displayHtmlHeader (_("Compose"), $js); |
9c3e6cd4 |
212 | break; |
213 | |
214 | } |
215 | |
216 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
217 | } |
43fdb2a4 |
218 | ?> |