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