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