r2l by Yoav
[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 require_once('../functions/html.php');
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='', $session=false) {
49
50 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
51 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
52 $attachemessages, $session;
53
54 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
55 if ($qmark = strpos($module, '?')) {
56 $module = substr($module, 0, $qmark);
57 }
58 if (!isset($frame_top)) {
59 $frame_top = '_top';
60 }
61
62 /*
63 Locate the first displayable form element
64 */
65
66 if ($session != false) {
67 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
68 } else {
69 $compose_uri = 'src/compose.php?newmessage=1';
70 $session = 0;
71 }
72
73 switch ( $module ) {
74 case 'src/read_body.php':
75 if ($compose_new_win == '1') {
76 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
77 $compose_width = '640';
78 }
79 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
80 $compose_height = '550';
81 }
82 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
83 "\n<!--\n";
84 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
85 ' if (new_mes) { '."\n".
86 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
87 ' } else { '."\n".
88 " if (comp_uri =='') {\n".
89 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
90 ' }'. "\n".
91 ' }'. "\n".
92 ' var newwin = window.open(comp_uri' .
93 ', "_blank",
94 "width='.$compose_width.",height=$compose_height".
95 ",scrollbars=yes,resizable=yes\");\n".
96 "}\n";
97
98 $js .= "// -->\n".
99 "</script>\n";
100 displayHtmlHeader ('Squirrelmail', $js);
101 }
102 displayHtmlHeader();
103 $onload = $xtra;
104 break;
105 case 'src/compose.php':
106 $js = '<script language="JavaScript" type="text/javascript">' .
107 "\n<!--\n" .
108 "function checkForm() {\n".
109 "var f = document.forms.length;\n".
110 "var i = 0;\n".
111 "var pos = -1;\n".
112 "while( pos == -1 && i < f ) {\n".
113 "var e = document.forms[i].elements.length;\n".
114 "var j = 0;\n".
115 "while( pos == -1 && j < e ) {\n".
116 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
117 "pos = j;\n".
118 "}\n".
119 "j++;\n".
120 "}\n".
121 "i++;\n".
122 "}\n".
123 "if( pos >= 0 ) {\n".
124 "document.forms[i-1].elements[pos].focus();\n".
125 "}\n".
126 "}\n";
127
128 $js .= "// -->\n".
129 "</script>\n";
130 $onload = "onLoad=\"checkForm();\"";
131 displayHtmlHeader ('Squirrelmail', $js);
132 break;
133
134 default:
135 $js = '<script language="JavaScript" type="text/javascript">' .
136 "\n<!--\n" .
137 "function checkForm() {\n".
138 "var f = document.forms.length;\n".
139 "var i = 0;\n".
140 "var pos = -1;\n".
141 "while( pos == -1 && i < f ) {\n".
142 "var e = document.forms[i].elements.length;\n".
143 "var j = 0;\n".
144 "while( pos == -1 && j < e ) {\n".
145 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
146 "pos = j;\n".
147 "}\n".
148 "j++;\n".
149 "}\n".
150 "i++;\n".
151 "}\n".
152 "if( pos >= 0 ) {\n".
153 "document.forms[i-1].elements[pos].focus();\n".
154 "}\n".
155 "$xtra\n".
156 "}\n";
157
158 if ($compose_new_win == '1') {
159 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
160 $compose_width = '640';
161 }
162 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
163 $compose_height = '550';
164 }
165 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
166 ' if (new_mes) { '."\n".
167 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
168 ' } else { '."\n".
169 " if (comp_uri =='') {\n".
170 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
171 ' }'. "\n".
172 ' }'. "\n".
173 ' var newwin = window.open(comp_uri' .
174 ', "_blank",
175 "width='.$compose_width.",height=$compose_height".
176 ",scrollbars=yes,resizable=yes\");\n".
177 "}\n";
178 }
179 $js .= "// -->\n".
180 "</script>\n";
181 $onload = "onLoad=\"checkForm();\"";
182 displayHtmlHeader ('Squirrelmail', $js);
183 break;
184
185 }
186
187 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
188 /** Here is the header and wrapping table **/
189 $shortBoxName = imap_utf7_decode_local(
190 readShortMailboxName($mailbox, $delimiter));
191 if ( $shortBoxName == 'INBOX' ) {
192 $shortBoxName = _("INBOX");
193 }
194 echo "<a name=\"pagetop\"></a>\n"
195 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
196 . html_tag( 'tr', '', '', $color[9] ) ."\n"
197 . html_tag( 'td', '', 'left' ) ."\n";
198 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
199 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
200 } else {
201 echo '&nbsp;';
202 }
203 echo " </td>\n"
204 . html_tag( 'td', '', 'right' ) ."<b>\n";
205 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
206 echo "</b></td>\n"
207 . " </tr>\n"
208 . html_tag( 'tr', '', '', $color[4] ) ."\n"
209 . html_tag( 'td', '', 'left' ) ."\n";
210 $urlMailbox = urlencode($mailbox);
211 if ($compose_new_win == '1') {
212 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
213 }
214 else {
215 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
216 }
217 echo "&nbsp;&nbsp;\n";
218 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
219 echo "&nbsp;&nbsp;\n";
220 displayInternalLink ("src/folders.php", _("Folders"), 'right');
221 echo "&nbsp;&nbsp;\n";
222 displayInternalLink ("src/options.php", _("Options"), 'right');
223 echo "&nbsp;&nbsp;\n";
224 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
225 echo "&nbsp;&nbsp;\n";
226 displayInternalLink ("src/help.php", _("Help"), 'right');
227 echo "&nbsp;&nbsp;\n";
228
229 do_hook("menuline");
230
231 echo " </td>\n"
232 . html_tag( 'td', '', 'right' ) ."\n";
233 echo ($hide_sm_attributions ? '&nbsp;' :
234 '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>');
235 echo "</td>\n".
236 " </tr>\n".
237 "</table>\n\n";
238 }
239
240 /* blatently copied/truncated/modified from the above function */
241 function compose_Header($color, $mailbox) {
242
243 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
244
245
246 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
247 if (!isset($frame_top)) {
248 $frame_top = '_top';
249 }
250
251 /*
252 Locate the first displayable form element
253 */
254 switch ( $module ) {
255 case 'src/search.php':
256 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
257 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
258 displayHtmlHeader (_("Compose"));
259 break;
260 default:
261 $js = '<script language="JavaScript" type="text/javascript">' .
262 "\n<!--\n" .
263 "function checkForm() {\n".
264 "var f = document.forms.length;\n".
265 "var i = 0;\n".
266 "var pos = -1;\n".
267 "while( pos == -1 && i < f ) {\n".
268 "var e = document.forms[i].elements.length;\n".
269 "var j = 0;\n".
270 "while( pos == -1 && j < e ) {\n".
271 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
272 "pos = j;\n".
273 "}\n".
274 "j++;\n".
275 "}\n".
276 "i++;\n".
277 "}\n".
278 "if( pos >= 0 ) {\n".
279 "document.forms[i-1].elements[pos].focus();\n".
280 "}\n".
281 "}\n";
282 $js .= "// -->\n".
283 "</script>\n";
284 $onload = "onLoad=\"checkForm();\"";
285 displayHtmlHeader (_("Compose"), $js);
286 break;
287
288 }
289
290 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
291 }
292 ?>