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