Inbox fix
[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\">\n";
27 }
28 } else {
29 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
30 $base_uri . "themes/css/$custom_css\">\n";
31 }
32
33 if( $do_hook ) {
34 do_hook ("generic_header");
35 }
36
37 echo "<title>$title</title>$xtra</head>\n\n";
38 }
39
40 function 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
50 function displayPageHeader($color, $mailbox) {
51
52 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top;
53
54 displayHtmlHeader ();
55
56 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
57 if (!isset($frame_top)) {
58 $frame_top = '_top';
59 }
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:
70 echo '
71 <script language="JavaScript">
72 <!--
73 function checkForm() {
74
75 var f = document.forms.length;
76 var i = 0;
77 var pos = -1;
78 while( pos == -1 && i < f ) {
79 var e = document.forms[i].elements.length;
80 var j = 0;
81 while( pos == -1 && j < e ) {
82 if ( document.forms[i].elements[j].type == \'text\' ) {
83 pos = j;
84 }
85 j++;
86 }
87 i++;
88 }
89 if( pos >= 0 ) {
90 document.forms[i-1].elements[pos].focus();
91 }
92
93 }
94 // -->
95 </script>
96 ';
97 $onload = "onLoad=\"checkForm();\"";
98 break;
99
100 }
101
102 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
103
104 /** Here is the header and wrapping table **/
105 $shortBoxName = readShortMailboxName($mailbox, $delimiter);
106 if ( $shorBoxName == 'INBOX' ) {
107 $shortBoxName = _("INBOX");
108 }
109 echo "<A NAME=pagetop></A>\n"
110 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
111 . " <TR BGCOLOR=\"$color[9]\" >\n"
112 . " <TD ALIGN=left>\n";
113 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
114 echo ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n";
115 } else {
116 echo '&nbsp;';
117 }
118 echo " </TD>\n"
119 . " <TD ALIGN=right><b>\n";
120 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
121 echo " </b></TD>\n"
122 . " </TR>\n"
123 . " <TR BGCOLOR=\"$color[4]\">\n"
124 . " <TD ALIGN=left>\n";
125 $urlMailbox = urlencode($mailbox);
126 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
127 echo "&nbsp;&nbsp;\n";
128 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
129 echo "&nbsp;&nbsp;\n";
130 displayInternalLink ("src/folders.php", _("Folders"), 'right');
131 echo "&nbsp;&nbsp;\n";
132 displayInternalLink ("src/options.php", _("Options"), 'right');
133 echo "&nbsp;&nbsp;\n";
134 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
135 echo "&nbsp;&nbsp;\n";
136 displayInternalLink ("src/help.php", _("Help"), 'right');
137 echo "&nbsp;&nbsp;\n";
138
139 do_hook("menuline");
140
141 echo " </TD><TD ALIGN=right>\n";
142 echo ($hide_sm_attributions ? '&nbsp;' :
143 "<A HREF=\"http://www.squirrelmail.org/\" TARGET=\"_blank\">SquirrelMail</A>\n");
144 echo " </TD>\n".
145 " </TR>\n".
146 "</TABLE>\n\n";
147 }
148
149 ?>