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