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