| 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, $compose_new_win, $username, $datadir; |
| 53 | |
| 54 | |
| 55 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
| 56 | if (!isset($frame_top)) { |
| 57 | $frame_top = '_top'; |
| 58 | } |
| 59 | |
| 60 | /* |
| 61 | Locate the first displayable form element |
| 62 | */ |
| 63 | switch ( $module ) { |
| 64 | case 'src/search.php': |
| 65 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
| 66 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
| 67 | displayHtmlHeader (); |
| 68 | break; |
| 69 | default: |
| 70 | $js = '<script language="JavaScript" type="text/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". |
| 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 | $js .= "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 | $js .= "// -->\n". |
| 107 | "</script>\n"; |
| 108 | $onload = "onLoad=\"checkForm();\""; |
| 109 | displayHtmlHeader ('Squirrelmail', $js); |
| 110 | break; |
| 111 | |
| 112 | } |
| 113 | |
| 114 | |
| 115 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
| 116 | /** Here is the header and wrapping table **/ |
| 117 | $shortBoxName = readShortMailboxName($mailbox, $delimiter); |
| 118 | if ( $shortBoxName == 'INBOX' ) { |
| 119 | $shortBoxName = _("INBOX"); |
| 120 | } |
| 121 | echo "<A NAME=pagetop></A>\n" |
| 122 | . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n" |
| 123 | . " <TR BGCOLOR=\"$color[9]\" >\n" |
| 124 | . " <TD ALIGN=left>\n"; |
| 125 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
| 126 | echo ' ' . _("Current Folder") . ": <B>$shortBoxName </B>\n"; |
| 127 | } else { |
| 128 | echo ' '; |
| 129 | } |
| 130 | echo " </TD>\n" |
| 131 | . " <TD ALIGN=right><b>\n"; |
| 132 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
| 133 | echo " </b></TD>\n" |
| 134 | . " </TR>\n" |
| 135 | . " <TR BGCOLOR=\"$color[4]\">\n" |
| 136 | . " <TD ALIGN=left>\n"; |
| 137 | $urlMailbox = urlencode($mailbox); |
| 138 | if ($compose_new_win == '1') { |
| 139 | echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=". |
| 140 | '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>'; |
| 141 | } |
| 142 | else { |
| 143 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
| 144 | } |
| 145 | echo " \n"; |
| 146 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
| 147 | echo " \n"; |
| 148 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
| 149 | echo " \n"; |
| 150 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
| 151 | echo " \n"; |
| 152 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
| 153 | echo " \n"; |
| 154 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
| 155 | echo " \n"; |
| 156 | |
| 157 | do_hook("menuline"); |
| 158 | |
| 159 | echo " </TD><TD ALIGN=right>\n"; |
| 160 | echo ($hide_sm_attributions ? ' ' : |
| 161 | "<A HREF=\"http://www.squirrelmail.org/\" TARGET=\"_blank\">SquirrelMail</A>\n"); |
| 162 | echo " </TD>\n". |
| 163 | " </TR>\n". |
| 164 | "</TABLE>\n\n"; |
| 165 | } |
| 166 | |
| 167 | /* blatently copied/truncated/modified from the above function */ |
| 168 | function compose_Header($color, $mailbox) { |
| 169 | |
| 170 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
| 171 | |
| 172 | |
| 173 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
| 174 | if (!isset($frame_top)) { |
| 175 | $frame_top = '_top'; |
| 176 | } |
| 177 | |
| 178 | /* |
| 179 | Locate the first displayable form element |
| 180 | */ |
| 181 | switch ( $module ) { |
| 182 | case 'src/search.php': |
| 183 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
| 184 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
| 185 | displayHtmlHeader (_("Compose")); |
| 186 | break; |
| 187 | default: |
| 188 | $js = '<script language="JavaScript" type="text/javascript">' . |
| 189 | "\n<!--\n" . |
| 190 | "function checkForm() {\n". |
| 191 | "var f = document.forms.length;\n". |
| 192 | "var i = 0;\n". |
| 193 | "var pos = -1;\n". |
| 194 | "while( pos == -1 && i < f ) {\n". |
| 195 | "var e = document.forms[i].elements.length;\n". |
| 196 | "var j = 0;\n". |
| 197 | "while( pos == -1 && j < e ) {\n". |
| 198 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
| 199 | "pos = j;\n". |
| 200 | "}\n". |
| 201 | "j++;\n". |
| 202 | "}\n". |
| 203 | "i++;\n". |
| 204 | "}\n". |
| 205 | "if( pos >= 0 ) {\n". |
| 206 | "document.forms[i-1].elements[pos].focus();\n". |
| 207 | "}\n". |
| 208 | "}\n"; |
| 209 | $js .= "// -->\n". |
| 210 | "</script>\n"; |
| 211 | $onload = "onLoad=\"checkForm();\""; |
| 212 | displayHtmlHeader (_("Compose"), $js); |
| 213 | break; |
| 214 | |
| 215 | } |
| 216 | |
| 217 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n"; |
| 218 | } |
| 219 | ?> |