initial files for using vcard in the gui
[squirrelmail.git] / functions / page_header.php
1 <?php
2
3 /**
4 * page_header.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
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
14 require_once(SM_PATH . 'functions/strings.php');
15 require_once(SM_PATH . 'functions/html.php');
16 require_once(SM_PATH . 'functions/imap_mailbox.php');
17 require_once(SM_PATH . 'functions/global.php');
18
19 /* Always set up the language before calling these functions */
20 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
21
22 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
23 global $base_uri;
24 }
25 global $theme_css, $custom_css;
26
27 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
28 "\n\n<html>\n<head>\n";
29
30 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
31 if ($theme_css != '') {
32 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
33 }
34 } else {
35 echo '<link rel="stylesheet" type="text/css" href="' .
36 $base_uri . 'themes/css/'.$custom_css.'" />';
37 }
38
39 if ($do_hook) {
40 do_hook('generic_header');
41 }
42
43 echo "\n<title>$title</title>$xtra\n";
44
45 /* work around IE6's scrollbar bug */
46 echo <<<ECHO
47 <style type="text/css">
48 <!--
49 /* avoid stupid IE6 bug with frames and scrollbars */
50 body {
51 voice-family: "\"}\"";
52 voice-family: inherit;
53 width: expression(document.documentElement.clientWidth - 30);
54 }
55 -->
56 </style>
57
58 ECHO;
59
60 echo "\n</head>\n\n";
61 }
62
63
64 function displayInternalLink($path, $text, $target='') {
65 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
66 if ($target != '') {
67 $target = " target=\"$target\"";
68 }
69 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
70 }
71
72 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
73
74 global $hide_sm_attributions, $PHP_SELF, $frame_top,
75 $compose_new_win, $compose_width, $compose_height,
76 $attachemessages, $provider_name, $provider_uri;
77
78 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
79 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
80 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
81 if ($qmark = strpos($module, '?')) {
82 $module = substr($module, 0, $qmark);
83 }
84 if (!isset($frame_top)) {
85 $frame_top = '_top';
86 }
87
88 if ($session) {
89 $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
90 } else {
91 $compose_uri = $base_uri.'src/compose.php?newmessage=1';
92 $session = 0;
93 }
94
95 switch ( $module ) {
96 case 'src/read_body.php':
97 $js ='';
98 if ($compose_new_win == '1') {
99 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
100 $compose_width = '640';
101 }
102 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
103 $compose_height = '550';
104 }
105 $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
106 "\n<!--\n";
107 $js .= "function comp_in_new(comp_uri) {\n".
108 " if (!comp_uri) {\n".
109 ' comp_uri = "'.$compose_uri."\";\n".
110 ' }'. "\n".
111 ' var newwin = window.open(comp_uri' .
112 ', "_blank",'.
113 '"width='.$compose_width. ',height='.$compose_height.
114 ',scrollbars=yes,resizable=yes");'."\n".
115 "}\n\n";
116
117
118 $js .= 'function sendMDN() {'."\n".
119 "mdnuri=window.location+'&sendreceipt=1';".
120 "var newwin = window.open(mdnuri,'right');".
121 "\n}\n\n";
122
123 $js .= "// -->\n".
124 "</script>\n";
125
126 }
127 displayHtmlHeader ('SquirrelMail', $js);
128 $onload = $xtra;
129 break;
130 case 'src/compose.php':
131 $js = '<script language="JavaScript" type="text/javascript">' .
132 "\n<!--\n" .
133 "function checkForm() {\n".
134 "var f = document.forms.length;\n".
135 "var i = 0;\n".
136 "var pos = -1;\n".
137 "while( pos == -1 && i < f ) {\n".
138 "var e = document.forms[i].elements.length;\n".
139 "var j = 0;\n".
140 "while( pos == -1 && j < e ) {\n".
141 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
142 "pos = j;\n".
143 "}\n".
144 "j++;\n".
145 "}\n".
146 "i++;\n".
147 "}\n".
148 "if( pos >= 0 ) {\n".
149 "document.forms[i-1].elements[pos].focus();\n".
150 "}\n".
151 "}\n";
152
153 $js .= "// -->\n".
154 "</script>\n";
155 $onload = 'onload="checkForm();"';
156 displayHtmlHeader ('SquirrelMail', $js);
157 break;
158
159 default:
160 $js = '<script language="JavaScript" type="text/javascript">' .
161 "\n<!--\n" .
162 "function checkForm() {\n".
163 "var f = document.forms.length;\n".
164 "var i = 0;\n".
165 "var pos = -1;\n".
166 "while( pos == -1 && i < f ) {\n".
167 "var e = document.forms[i].elements.length;\n".
168 "var j = 0;\n".
169 "while( pos == -1 && j < e ) {\n".
170 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
171 "pos = j;\n".
172 "}\n".
173 "j++;\n".
174 "}\n".
175 "i++;\n".
176 "}\n".
177 "if( pos >= 0 ) {\n".
178 "document.forms[i-1].elements[pos].focus();\n".
179 "}\n".
180 "$xtra\n".
181 "}\n";
182
183 if ($compose_new_win == '1') {
184 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
185 $compose_width = '640';
186 }
187 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
188 $compose_height = '550';
189 }
190 $js .= "function comp_in_new(comp_uri) {\n".
191 " if (!comp_uri) {\n".
192 ' comp_uri = "'.$compose_uri."\";\n".
193 ' }'. "\n".
194 ' var newwin = window.open(comp_uri' .
195 ', "_blank",'.
196 '"width='.$compose_width. ',height='.$compose_height.
197 ',scrollbars=yes,resizable=yes");'."\n".
198 "}\n\n";
199
200 }
201 $js .= "// -->\n". "</script>\n";
202
203
204 $onload = 'onload="checkForm();"';
205 displayHtmlHeader ('SquirrelMail', $js);
206 break;
207
208 }
209
210 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
211 /** Here is the header and wrapping table **/
212 $shortBoxName = imap_utf7_decode_local(
213 readShortMailboxName($mailbox, $delimiter));
214 if ( $shortBoxName == 'INBOX' ) {
215 $shortBoxName = _("INBOX");
216 }
217 echo "<a name=\"pagetop\"></a>\n"
218 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
219 . html_tag( 'tr', '', '', $color[9] ) ."\n"
220 . html_tag( 'td', '', 'left' ) ."\n";
221 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
222 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
223 } else {
224 echo '&nbsp;';
225 }
226 echo " </td>\n"
227 . html_tag( 'td', '', 'right' ) ."<b>\n";
228 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
229 echo "</b></td>\n"
230 . " </tr>\n"
231 . html_tag( 'tr', '', '', $color[4] ) ."\n"
232 . html_tag( 'td', '', 'left' ) ."\n";
233 $urlMailbox = urlencode($mailbox);
234 if ($compose_new_win == '1') {
235 echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
236 }
237 else {
238 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
239 }
240 echo "&nbsp;&nbsp;\n";
241 if (getPref($data_dir, $username,"vcard")==1) {
242 displayInternalLink ('src/addressbook_vcard.php', _("Addresses"), 'right');
243 } else {
244 displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
245 }
246 echo "&nbsp;&nbsp;\n";
247 displayInternalLink ('src/folders.php', _("Folders"), 'right');
248 echo "&nbsp;&nbsp;\n";
249 displayInternalLink ('src/options.php', _("Options"), 'right');
250 echo "&nbsp;&nbsp;\n";
251 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
252 echo "&nbsp;&nbsp;\n";
253 displayInternalLink ('src/help.php', _("Help"), 'right');
254 echo "&nbsp;&nbsp;\n";
255
256 do_hook('menuline');
257
258 echo " </td>\n"
259 . html_tag( 'td', '', 'right' ) ."\n";
260 if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
261 if (!isset($provider_name)) $provider_name= 'SquirrelMail';
262 echo ($hide_sm_attributions ? '&nbsp;' :
263 '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>');
264 echo "</td>\n".
265 " </tr>\n".
266 "</table><br>\n\n";
267 }
268
269 /* blatently copied/truncated/modified from the above function */
270 function compose_Header($color, $mailbox) {
271
272 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF,
273 $data_dir, $username, $frame_top, $compose_new_win;
274
275
276 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
277 if (!isset($frame_top)) {
278 $frame_top = '_top';
279 }
280
281 /*
282 Locate the first displayable form element
283 */
284 switch ( $module ) {
285 case 'src/search.php':
286 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
287 $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
288 displayHtmlHeader (_("Compose"));
289 break;
290 default:
291 $js = '<script language="JavaScript" type="text/javascript">' .
292 "\n<!--\n" .
293 "function checkForm() {\n".
294 "var f = document.forms.length;\n".
295 "var i = 0;\n".
296 "var pos = -1;\n".
297 "while( pos == -1 && i < f ) {\n".
298 "var e = document.forms[i].elements.length;\n".
299 "var j = 0;\n".
300 "while( pos == -1 && j < e ) {\n".
301 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
302 "pos = j;\n".
303 "}\n".
304 "j++;\n".
305 "}\n".
306 "i++;\n".
307 "}\n".
308 "if( pos >= 0 ) {\n".
309 "document.forms[i-1].elements[pos].focus();\n".
310 "}\n".
311 "}\n";
312 $js .= "// -->\n".
313 "</script>\n";
314 $onload = 'onload="checkForm();"';
315 displayHtmlHeader (_("Compose"), $js);
316 break;
317
318 }
319
320 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
321 }
322 ?>