67bd6314164a6f13bfa7cf08237ee92f0f684978
[squirrelmail.git] / functions / page_header.php
1 <?php
2
3 /**
4 * page_header.php
5 *
6 * Copyright (c) 1999-2002 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('../functions/strings.php');
15
16 /* Always set up the language before calling these functions */
17 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
18
19 global $theme_css, $custom_css, $base_uri;
20
21 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
22 "\n\n<HTML>\n<HEAD>\n";
23
24 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
25 if ($theme_css != '') {
26 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
27 }
28 } else {
29 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
30 $base_uri . 'themes/css/$custom_css">';
31 }
32
33 echo "\n<title>$title</title>$xtra</head>\n\n";
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
46 function displayPageHeader($color, $mailbox, $xtra='') {
47
48 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win, $username, $datadir;
49
50 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
51 if (!isset($frame_top)) {
52 $frame_top = '_top';
53 }
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();\"";
62 displayHtmlHeader ();
63 break;
64 default:
65 $js = '<script language="JavaScript" type="text/javascript">' .
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".
85 "$xtra\n".
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 }
96 $js .= "function comp_in_new() {\n".
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 }
102 $js .= "// -->\n".
103 "</script>\n";
104 $onload = "onLoad=\"checkForm();\"";
105 displayHtmlHeader ('Squirrelmail', $js);
106 break;
107
108 }
109
110
111 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
112 /** Here is the header and wrapping table **/
113 $shortBoxName = readShortMailboxName($mailbox, $delimiter);
114 if ( $shortBoxName == 'INBOX' ) {
115 $shortBoxName = _("INBOX");
116 }
117 echo "<A NAME=pagetop></A>\n"
118 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
119 . " <TR BGCOLOR=\"$color[9]\" >\n"
120 . " <TD ALIGN=left>\n";
121 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
122 echo ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n";
123 } else {
124 echo '&nbsp;';
125 }
126 echo " </TD>\n"
127 . ' <TD ALIGN=right><b>';
128 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
129 echo "</b></TD>\n"
130 . " </TR>\n"
131 . " <TR BGCOLOR=\"$color[4]\">\n"
132 . " <TD ALIGN=left>\n";
133 $urlMailbox = urlencode($mailbox);
134 if ($compose_new_win == '1') {
135 echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=".
136 '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>';
137 }
138 else {
139 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
140 }
141 echo "&nbsp;&nbsp;\n";
142 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
143 echo "&nbsp;&nbsp;\n";
144 displayInternalLink ("src/folders.php", _("Folders"), 'right');
145 echo "&nbsp;&nbsp;\n";
146 displayInternalLink ("src/options.php", _("Options"), 'right');
147 echo "&nbsp;&nbsp;\n";
148 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
149 echo "&nbsp;&nbsp;\n";
150 displayInternalLink ("src/help.php", _("Help"), 'right');
151 echo "&nbsp;&nbsp;\n";
152
153 do_hook("menuline");
154
155 echo " </TD>\n <TD ALIGN=\"right\">";
156 echo ($hide_sm_attributions ? '&nbsp;' :
157 '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>');
158 echo "</TD>\n".
159 " </TR>\n".
160 "</TABLE>\n\n";
161 }
162
163 /* blatently copied/truncated/modified from the above function */
164 function compose_Header($color, $mailbox) {
165
166 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
167
168
169 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
170 if (!isset($frame_top)) {
171 $frame_top = '_top';
172 }
173
174 /*
175 Locate the first displayable form element
176 */
177 switch ( $module ) {
178 case 'src/search.php':
179 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
180 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
181 displayHtmlHeader (_("Compose"));
182 break;
183 default:
184 $js = '<script language="JavaScript" type="text/javascript">' .
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";
205 $js .= "// -->\n".
206 "</script>\n";
207 $onload = "onLoad=\"checkForm();\"";
208 displayHtmlHeader (_("Compose"), $js);
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 }
215 ?>