| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * page_header.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2005 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 | * @version $Id$ |
| 12 | * @package squirrelmail |
| 13 | */ |
| 14 | |
| 15 | /** Include required files from SM */ |
| 16 | require_once(SM_PATH . 'functions/strings.php'); |
| 17 | require_once(SM_PATH . 'functions/html.php'); |
| 18 | require_once(SM_PATH . 'functions/imap_mailbox.php'); |
| 19 | require_once(SM_PATH . 'functions/global.php'); |
| 20 | |
| 21 | /** |
| 22 | * Output a SquirrelMail page header, from <!doctype> to </head> |
| 23 | * Always set up the language before calling these functions. |
| 24 | * |
| 25 | * @param string title the page title, default SquirrelMail. |
| 26 | * @param string xtra extra HTML to insert into the header |
| 27 | * @param bool do_hook whether to execute hooks, default true |
| 28 | * @param bool frames generate html frameset doctype (since 1.5.1) |
| 29 | * @return void |
| 30 | */ |
| 31 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) { |
| 32 | global $squirrelmail_language; |
| 33 | |
| 34 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
| 35 | global $base_uri; |
| 36 | } |
| 37 | global $theme_css, $custom_css, $pageheader_sent; |
| 38 | |
| 39 | if ($frames) { |
| 40 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">'; |
| 41 | } else { |
| 42 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
| 43 | } |
| 44 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
| 45 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
| 46 | |
| 47 | /* |
| 48 | * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional. |
| 49 | * It is not compatible with html 4.01 Transitional |
| 50 | */ |
| 51 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
| 52 | if ($theme_css != '') { |
| 53 | echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">"; |
| 54 | } |
| 55 | } else { |
| 56 | echo '<link rel="stylesheet" type="text/css" href="' . |
| 57 | $base_uri . 'themes/css/'.$custom_css.'">'; |
| 58 | } |
| 59 | |
| 60 | echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'templates/default/squirrelmail.css">'; |
| 61 | |
| 62 | if ($squirrelmail_language == 'ja_JP') { |
| 63 | /* |
| 64 | * force correct detection of charset, when browser does not follow |
| 65 | * http content-type and tries to detect charset from page content. |
| 66 | * Shooting of browser's creator can't be implemented in php. |
| 67 | * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/ |
| 68 | * recommendations and switch to unicode. |
| 69 | */ |
| 70 | echo "<!-- \xfd\xfe -->\n"; |
| 71 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
| 72 | } |
| 73 | if ($do_hook) { |
| 74 | do_hook('generic_header'); |
| 75 | } |
| 76 | |
| 77 | echo "<title>$title</title>\n$xtra\n"; |
| 78 | |
| 79 | /* work around IE6's scrollbar bug */ |
| 80 | echo <<<ECHO |
| 81 | <style type="text/css"> |
| 82 | <!-- |
| 83 | /* avoid stupid IE6 bug with frames and scrollbars */ |
| 84 | body { |
| 85 | voice-family: "\"}\""; |
| 86 | voice-family: inherit; |
| 87 | width: expression(document.documentElement.clientWidth - 30); |
| 88 | } |
| 89 | --> |
| 90 | </style> |
| 91 | |
| 92 | ECHO; |
| 93 | |
| 94 | echo "\n</head>\n\n"; |
| 95 | |
| 96 | /* this is used to check elsewhere whether we should call this function */ |
| 97 | $pageheader_sent = TRUE; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Given a path to a SquirrelMail file, return a HTML link to it |
| 102 | * |
| 103 | * @param string path the SquirrelMail file to link to |
| 104 | * @param string text the link text |
| 105 | * @param string target the target frame for this link |
| 106 | */ |
| 107 | function makeInternalLink($path, $text, $target='') { |
| 108 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
| 109 | if ($target != '') { |
| 110 | $target = " target=\"$target\""; |
| 111 | } |
| 112 | |
| 113 | // This is an inefficient hook and is only used by |
| 114 | // one plugin that still needs to patch this code, |
| 115 | // plus if we are templat-izing SM, visual hooks |
| 116 | // are not needed. However, I am leaving the code |
| 117 | // here just in case we find a good (non-visual?) |
| 118 | // use for the internal_link hook. |
| 119 | // |
| 120 | //$hooktext = do_hook_function('internal_link',$text); |
| 121 | //if ($hooktext != '') |
| 122 | // $text = $hooktext; |
| 123 | |
| 124 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Same as makeInternalLink, but echoes it too |
| 129 | */ |
| 130 | function displayInternalLink($path, $text, $target='') { |
| 131 | echo makeInternalLink($path, $text, $target); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Outputs a complete SquirrelMail page header, starting with <!doctype> and |
| 136 | * including the default menu bar. Uses displayHtmlHeader and takes |
| 137 | * JavaScript and locale settings into account. |
| 138 | * |
| 139 | * @param array color the array of theme colors |
| 140 | * @param string mailbox the current mailbox name to display |
| 141 | * @param string sHeaderJs javascipt code to be inserted in a script block in the header |
| 142 | * @param string sBodyTagJs js events to be inserted in the body tag |
| 143 | * @return void |
| 144 | */ |
| 145 | |
| 146 | function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') { |
| 147 | global $hide_sm_attributions, $frame_top, |
| 148 | $provider_name, $provider_uri, $startMessage, |
| 149 | $javascript_on; |
| 150 | |
| 151 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
| 152 | |
| 153 | if (!isset($frame_top)) { |
| 154 | $frame_top = '_top'; |
| 155 | } |
| 156 | |
| 157 | if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) { |
| 158 | $sJsBlock = '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
| 159 | if ($sHeaderJs) { |
| 160 | $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
| 161 | "\n<!--\n" . |
| 162 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
| 163 | } |
| 164 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
| 165 | } else { |
| 166 | /* do not use JavaScript */ |
| 167 | displayHtmlHeader ('SquirrelMail'); |
| 168 | $sBodyTagJs = ''; |
| 169 | } |
| 170 | |
| 171 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
| 172 | |
| 173 | /** Here is the header and wrapping table **/ |
| 174 | $shortBoxName = htmlspecialchars(imap_utf7_decode_local( |
| 175 | readShortMailboxName($mailbox, $delimiter))); |
| 176 | if ( $shortBoxName == 'INBOX' ) { |
| 177 | $shortBoxName = _("INBOX"); |
| 178 | } |
| 179 | echo "<a name=\"pagetop\"></a>\n" |
| 180 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
| 181 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
| 182 | . html_tag( 'td', '', 'left' ) ."\n"; |
| 183 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
| 184 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
| 185 | } else { |
| 186 | echo ' '; |
| 187 | } |
| 188 | echo " </td>\n" |
| 189 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
| 190 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
| 191 | echo "</b></td>\n" |
| 192 | . " </tr>\n" |
| 193 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
| 194 | . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' ) |
| 195 | : html_tag( 'td', '', 'left' ) ) |
| 196 | . "\n"; |
| 197 | $urlMailbox = urlencode($mailbox); |
| 198 | $startMessage = (int)$startMessage; |
| 199 | |
| 200 | echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage); |
| 201 | echo " \n"; |
| 202 | displayInternalLink ('src/addressbook.php', _("Addresses")); |
| 203 | echo " \n"; |
| 204 | displayInternalLink ('src/folders.php', _("Folders")); |
| 205 | echo " \n"; |
| 206 | displayInternalLink ('src/options.php', _("Options")); |
| 207 | echo " \n"; |
| 208 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search")); |
| 209 | echo " \n"; |
| 210 | displayInternalLink ('src/help.php', _("Help")); |
| 211 | echo " \n"; |
| 212 | |
| 213 | do_hook('menuline'); |
| 214 | |
| 215 | echo " </td>\n"; |
| 216 | |
| 217 | if (!$hide_sm_attributions) |
| 218 | { |
| 219 | echo html_tag( 'td', '', 'right' ) ."\n"; |
| 220 | if (empty($provider_uri)) { |
| 221 | echo '<a href="about.php">SquirrelMail</a>'; |
| 222 | } else { |
| 223 | if (empty($provider_name)) $provider_name= 'SquirrelMail'; |
| 224 | echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'; |
| 225 | } |
| 226 | echo "</td>\n"; |
| 227 | } |
| 228 | echo " </tr>\n". |
| 229 | "</table><br />\n\n"; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Blatantly copied/truncated/modified from displayPageHeader. |
| 234 | * Outputs a page header specifically for the compose_in_new popup window |
| 235 | * |
| 236 | * @param array color the array of theme colors |
| 237 | * @param string mailbox the current mailbox name to display |
| 238 | * @param string sHeaderJs javascipt code to be inserted in a script block in the header |
| 239 | * @param string sBodyTagJs js events to be inserted in the body tag |
| 240 | * @return void |
| 241 | */ |
| 242 | function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') { |
| 243 | global $javascript_on; |
| 244 | /* |
| 245 | * Locate the first displayable form element (only when JavaScript on) |
| 246 | */ |
| 247 | if($javascript_on) { |
| 248 | if ($sHeaderJs) { |
| 249 | $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
| 250 | "\n<!--\n" . |
| 251 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
| 252 | } else { |
| 253 | $sJsBlock = ''; |
| 254 | } |
| 255 | $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
| 256 | displayHtmlHeader (_("Compose"), $sJsBlock); |
| 257 | } else { |
| 258 | /* javascript off */ |
| 259 | displayHtmlHeader(_("Compose")); |
| 260 | $onload = ''; |
| 261 | } |
| 262 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
| 263 | } |
| 264 | ?> |