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