6 * Prints the page header (duh)
8 * @copyright © 1999-2005 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
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');
21 * Output a SquirrelMail page header, from <!doctype> to </head>
22 * Always set up the language before calling these functions.
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)
30 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
31 global $squirrelmail_language;
33 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
) ) {
36 global $theme_css, $custom_css, $pageheader_sent;
39 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
41 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
43 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
44 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
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
50 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
51 if ($theme_css != '') {
52 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
55 echo '<link rel="stylesheet" type="text/css" href="' .
56 $base_uri . 'themes/css/'.$custom_css.'">';
59 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'templates/default/squirrelmail.css">';
61 if ($squirrelmail_language == 'ja_JP') {
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.
69 echo "<!-- \xfd\xfe -->\n";
70 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
73 do_hook('generic_header');
76 echo "<title>$title</title>\n$xtra\n";
78 /* work around IE6's scrollbar bug */
80 <style type="text/css">
82 /* avoid stupid IE6 bug with frames and scrollbars */
84 voice-family: "\"}\"";
85 voice-family: inherit;
86 width: expression(document.documentElement.clientWidth - 30);
95 /* this is used to check elsewhere whether we should call this function */
96 $pageheader_sent = TRUE;
100 * Given a path to a SquirrelMail file, return a HTML link to it
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
106 function makeInternalLink($path, $text, $target='') {
107 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
109 $target = " target=\"$target\"";
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.
119 //$hooktext = do_hook_function('internal_link',$text);
120 //if ($hooktext != '')
121 // $text = $hooktext;
123 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
127 * Same as makeInternalLink, but echoes it too
129 function displayInternalLink($path, $text, $target='') {
130 echo makeInternalLink($path, $text, $target);
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.
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
145 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
147 global $reply_focus, $hide_sm_attributions, $frame_top,
148 $provider_name, $provider_uri, $startMessage,
149 $javascript_on, $action;
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();"';
161 $sBodyTagJs = 'onload="checkForm();"';
165 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
167 if (!isset($frame_top)) {
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";
174 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
176 $sHeaderJs . "\n\n// -->\n</script>\n";
178 displayHtmlHeader ('SquirrelMail', $sJsBlock);
180 /* do not use JavaScript */
181 displayHtmlHeader ('SquirrelMail');
185 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
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");
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";
203 . html_tag( 'td', '', 'right' ) ."<b>\n";
204 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
207 . html_tag( 'tr', '', '', $color[4] ) ."\n"
208 . ($hide_sm_attributions ?
html_tag( 'td', '', 'left', '', 'colspan="2"' )
209 : html_tag( 'td', '', 'left' ) )
211 $urlMailbox = urlencode($mailbox);
212 $startMessage = (int)$startMessage;
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";
231 if (!$hide_sm_attributions)
233 echo html_tag( 'td', '', 'right' ) ."\n";
234 if (empty($provider_uri)) {
235 echo '<a href="about.php">SquirrelMail</a>';
237 if (empty($provider_name)) $provider_name= 'SquirrelMail';
238 echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
243 "</table><br />\n\n";
247 * Blatantly copied/truncated/modified from displayPageHeader.
248 * Outputs a page header specifically for the compose_in_new popup window
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
256 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
258 global $reply_focus, $javascript_on, $action;
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();"';
270 $sBodyTagJs = 'onload="checkForm();"';
275 * Locate the first displayable form element (only when JavaScript on)
279 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
281 $sHeaderJs . "\n\n// -->\n</script>\n";
285 $sJsBlock .= "\n" . '<script src="'. SM_PATH
.'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
286 displayHtmlHeader (_("Compose"), $sJsBlock);
289 displayHtmlHeader(_("Compose"));
292 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";