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