Fix a variable typo.
[squirrelmail.git] / functions / page_header.php
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 if ($squirrelmail_language == 'ja_JP') {
61 /*
62 * force correct detection of charset, when browser does not follow
63 * http content-type and tries to detect charset from page content.
64 * Shooting of browser's creator can't be implemented in php.
65 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
66 * recommendations and switch to unicode.
67 */
68 echo "<!-- \xfd\xfe -->\n";
69 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
70 }
71 if ($do_hook) {
72 do_hook('generic_header');
73 }
74
75 echo "<title>$title</title>\n$xtra\n";
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 */
82 body {
83 voice-family: "\"}\"";
84 voice-family: inherit;
85 width: expression(document.documentElement.clientWidth - 30);
86 }
87 -->
88 </style>
89
90 ECHO;
91
92 echo "\n</head>\n\n";
93
94 /* this is used to check elsewhere whether we should call this function */
95 $pageheader_sent = TRUE;
96 }
97
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 */
105 function makeInternalLink($path, $text, $target='') {
106 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
107 if ($target != '') {
108 $target = " target=\"$target\"";
109 }
110
111 // This is an inefficient hook and is only used by
112 // one plugin that still needs to patch this code,
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?)
116 // use for the internal_link hook.
117 //
118 //$hooktext = do_hook_function('internal_link',$text);
119 //if ($hooktext != '')
120 // $text = $hooktext;
121
122 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
123 }
124
125 /**
126 * Same as makeInternalLink, but echoes it too
127 */
128 function displayInternalLink($path, $text, $target='') {
129 echo makeInternalLink($path, $text, $target);
130 }
131
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
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
141 * @return void
142 */
143
144 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
145 global $hide_sm_attributions, $frame_top,
146 $provider_name, $provider_uri, $startMessage,
147 $javascript_on;
148
149 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
150
151 if (!isset($frame_top)) {
152 $frame_top = '_top';
153 }
154
155 if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
156 $sJsBlock = '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
157 if ($sHeaderJs) {
158 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
159 "\n<!--\n" .
160 $sHeaderJs . "\n\n// -->\n</script>\n";
161 }
162 displayHtmlHeader ('SquirrelMail', $sJsBlock);
163 } else {
164 /* do not use JavaScript */
165 displayHtmlHeader ('SquirrelMail');
166 $sBodyTagJs = '';
167 }
168
169 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
170
171 /** Here is the header and wrapping table **/
172 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
173 readShortMailboxName($mailbox, $delimiter)));
174 if ( $shortBoxName == 'INBOX' ) {
175 $shortBoxName = _("INBOX");
176 }
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";
181 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
182 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
183 } else {
184 echo '&nbsp;';
185 }
186 echo " </td>\n"
187 . html_tag( 'td', '', 'right' ) ."<b>\n";
188 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
189 echo "</b></td>\n"
190 . " </tr>\n"
191 . html_tag( 'tr', '', '', $color[4] ) ."\n"
192 . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' )
193 : html_tag( 'td', '', 'left' ) )
194 . "\n";
195 $urlMailbox = urlencode($mailbox);
196 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&amp;startMessage='.$startMessage);
197 echo "&nbsp;&nbsp;\n";
198 displayInternalLink ('src/addressbook.php', _("Addresses"));
199 echo "&nbsp;&nbsp;\n";
200 displayInternalLink ('src/folders.php', _("Folders"));
201 echo "&nbsp;&nbsp;\n";
202 displayInternalLink ('src/options.php', _("Options"));
203 echo "&nbsp;&nbsp;\n";
204 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
205 echo "&nbsp;&nbsp;\n";
206 displayInternalLink ('src/help.php', _("Help"));
207 echo "&nbsp;&nbsp;\n";
208
209 do_hook('menuline');
210
211 echo " </td>\n";
212
213 if (!$hide_sm_attributions)
214 {
215 echo html_tag( 'td', '', 'right' ) ."\n";
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 }
222 echo "</td>\n";
223 }
224 echo " </tr>\n".
225 "</table><br />\n\n";
226 }
227
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
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
236 * @return void
237 */
238 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
239 global $javascript_on;
240 /*
241 * Locate the first displayable form element (only when JavaScript on)
242 */
243 if($javascript_on) {
244 if ($sHeaderJs) {
245 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
246 "\n<!--\n" .
247 $sHeaderJs . "\n\n// -->\n</script>\n";
248 } else {
249 $sJsBlock = '';
250 }
251 $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
252 displayHtmlHeader (_("Compose"), $sJsBlock);
253 } else {
254 /* javascript off */
255 displayHtmlHeader(_("Compose"));
256 $onload = '';
257 }
258 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
259 }
260 ?>