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