templates
[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
04f8889b 155 if( $javascript_on || strpos($xtra, 'new_js_autodetect_results.value') ) {
91c27aee 156 if ($sHeaderJs) {
157 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
158 "\n<!--\n" .
159 $sJsHeader . "\n\n// -->\n</script>\n";
160 } else {
161 $sJsBlock = '';
d62c4938 162 }
91c27aee 163 $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
164 displayHtmlHeader ('SquirrelMail', $sJsBlock);
165 } else {
d62c4938 166 /* do not use JavaScript */
167 displayHtmlHeader ('SquirrelMail');
91c27aee 168 $sBodyTagJs = '';
715225af 169 }
170
91c27aee 171 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
172
a07cd1a4 173 /** Here is the header and wrapping table **/
72520f77 174 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
91e0dccc 175 readShortMailboxName($mailbox, $delimiter)));
3b7d68e6 176 if ( $shortBoxName == 'INBOX' ) {
7da23762 177 $shortBoxName = _("INBOX");
178 }
b01b21d0 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";
5bb2a991 183 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
b01b21d0 184 echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
5bb2a991 185 } else {
186 echo '&nbsp;';
187 }
b01b21d0 188 echo " </td>\n"
189 . html_tag( 'td', '', 'right' ) ."<b>\n";
80e86e94 190 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
b01b21d0 191 echo "</b></td>\n"
192 . " </tr>\n"
193 . html_tag( 'tr', '', '', $color[4] ) ."\n"
99ea51d3 194 . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' )
195 : html_tag( 'td', '', 'left' ) )
196 . "\n";
a07cd1a4 197 $urlMailbox = urlencode($mailbox);
e233a3ad 198 echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&amp;startMessage='.$startMessage);
a07cd1a4 199 echo "&nbsp;&nbsp;\n";
21a957a9 200 displayInternalLink ('src/addressbook.php', _("Addresses"));
a07cd1a4 201 echo "&nbsp;&nbsp;\n";
21a957a9 202 displayInternalLink ('src/folders.php', _("Folders"));
a07cd1a4 203 echo "&nbsp;&nbsp;\n";
21a957a9 204 displayInternalLink ('src/options.php', _("Options"));
a07cd1a4 205 echo "&nbsp;&nbsp;\n";
21a957a9 206 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
a07cd1a4 207 echo "&nbsp;&nbsp;\n";
21a957a9 208 displayInternalLink ('src/help.php', _("Help"));
a07cd1a4 209 echo "&nbsp;&nbsp;\n";
210
d68323ff 211 do_hook('menuline');
a07cd1a4 212
99ea51d3 213 echo " </td>\n";
214
215 if (!$hide_sm_attributions)
216 {
217 echo html_tag( 'td', '', 'right' ) ."\n";
8b5c49cd 218 if (empty($provider_uri)) {
219 echo '<a href="about.php">SquirrelMail</a>';
220 } else {
221 if (empty($provider_name)) $provider_name= 'SquirrelMail';
222 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
223 }
99ea51d3 224 echo "</td>\n";
225 }
226 echo " </tr>\n".
04fa3c41 227 "</table><br />\n\n";
a07cd1a4 228}
2ba13803 229
8b096f0a 230/**
231 * Blatantly copied/truncated/modified from displayPageHeader.
232 * Outputs a page header specifically for the compose_in_new popup window
233 *
234 * @param array color the array of theme colors
235 * @param string mailbox the current mailbox name to display
91c27aee 236 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
237 * @param string sBodyTagJs js events to be inserted in the body tag
8b096f0a 238 * @return void
239 */
91c27aee 240function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
d62c4938 241 global $javascript_on;
9c3e6cd4 242 /*
d62c4938 243 * Locate the first displayable form element (only when JavaScript on)
244 */
245 if($javascript_on) {
91c27aee 246 if ($sHeaderJs) {
247 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
248 "\n<!--\n" .
249 $sJsHeader . "\n\n// -->\n</script>\n";
250 } else {
251 $sJsBlock = '';
d62c4938 252 }
91c27aee 253 $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
254 displayHtmlHeader (_("Compose"), $sJsBlock);
d62c4938 255 } else {
256 /* javascript off */
257 displayHtmlHeader(_("Compose"));
258 $onload = '';
9c3e6cd4 259 }
91c27aee 260 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
9c3e6cd4 261}
cc681ac9 262?>