Multiple css bugfix
[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 // Always set up the language before calling these functions
15 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
16
17 global $theme_css, $custom_css, $base_uri;
18
19 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
20 "\n\n<HTML>\n<HEAD>\n";
21
22 if ( !isset( $custom_css ) || $custom_css == 'none' ) {
23 if ($theme_css != '') {
24 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
25 }
26 } else {
27 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
28 $base_uri . "themes/css/$custom_css\">\n";
29 }
30
31 if( $do_hook ) {
32 do_hook ("generic_header");
33 }
34
35 echo "<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) {
49
50 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF;
51
52 displayHtmlHeader ();
53
54 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
55
56 /*
57 Locate the first displayable form element
58 */
59 switch ( $module ) {
60 case 'src/search.php':
61 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
62 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
63 break;
64 default:
65 echo '
66 <script language="JavaScript">
67 <!--
68 function checkForm() {
69
70 var f = document.forms.length;
71 var i = 0;
72 var pos = -1;
73 while( pos == -1 && i < f ) {
74 var e = document.forms[i].elements.length;
75 var j = 0;
76 while( pos == -1 && j < e ) {
77 if ( document.forms[i].elements[j].type == \'text\' ) {
78 pos = j;
79 }
80 j++;
81 }
82 i++;
83 }
84 if( pos >= 0 ) {
85 document.forms[i-1].elements[pos].focus();
86 }
87
88 }
89 -->
90 </script>
91 ';
92 $onload = "onLoad=\"checkForm();\"";
93 break;
94
95 }
96
97 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
98
99 /** Here is the header and wrapping table **/
100 $shortBoxName = readShortMailboxName($mailbox, $delimiter);
101 echo "<A NAME=pagetop></A>\n"
102 . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
103 . " <TR BGCOLOR=\"$color[9]\" >\n"
104 . " <TD ALIGN=left>\n"
105 . ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n"
106 . " </TD>\n"
107 . " <TD ALIGN=right><b>\n";
108 displayInternalLink ('src/signout.php', _("Sign Out"), '_top');
109 echo " </b></TD>\n"
110 . " </TR>\n"
111 . " <TR BGCOLOR=\"$color[4]\">\n"
112 . " <TD ALIGN=left>\n";
113 $urlMailbox = urlencode($mailbox);
114 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
115 echo "&nbsp;&nbsp;\n";
116 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
117 echo "&nbsp;&nbsp;\n";
118 displayInternalLink ("src/folders.php", _("Folders"), 'right');
119 echo "&nbsp;&nbsp;\n";
120 displayInternalLink ("src/options.php", _("Options"), 'right');
121 echo "&nbsp;&nbsp;\n";
122 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
123 echo "&nbsp;&nbsp;\n";
124 displayInternalLink ("src/help.php", _("Help"), 'right');
125 echo "&nbsp;&nbsp;\n";
126
127 do_hook("menuline");
128
129 echo " </TD><TD ALIGN=right>\n";
130 echo ($hide_sm_attributions ? '&nbsp;' :
131 "<A HREF=\"http://www.squirrelmail.org/\" TARGET=\"_blank\">SquirrelMail</A>\n");
132 echo " </TD>\n".
133 " </TR>\n".
134 "</TABLE>\n\n";
135 }
136
137 ?>