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