59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
35586184 |
6 | * Prints the page header (duh) |
7 | * |
4b4abf93 |
8 | * @copyright © 1999-2005 The SquirrelMail Project Team |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
31841a9e |
10 | * @version $Id$ |
d6c32258 |
11 | * @package squirrelmail |
35586184 |
12 | */ |
13 | |
d6c32258 |
14 | /** Include required files from SM */ |
b68edc75 |
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'); |
0b97a708 |
18 | require_once(SM_PATH . 'functions/global.php'); |
b68edc75 |
19 | |
d6c32258 |
20 | /** |
8b096f0a |
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 |
62b9c984 |
27 | * @param bool frames generate html frameset doctype (since 1.5.1) |
8b096f0a |
28 | * @return void |
d6c32258 |
29 | */ |
62b9c984 |
30 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) { |
e842b215 |
31 | global $squirrelmail_language; |
692155b7 |
32 | |
0365891c |
33 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
0b97a708 |
34 | global $base_uri; |
35 | } |
b6c283c4 |
36 | global $theme_css, $custom_css, $pageheader_sent; |
2c21ef20 |
37 | |
62b9c984 |
38 | if ($frames) { |
39 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">'; |
91e0dccc |
40 | } else { |
62b9c984 |
41 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
42 | } |
f9f738dc |
43 | echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . |
44 | "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n"; |
2c21ef20 |
45 | |
fcae5445 |
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 | */ |
a714cb95 |
50 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
51 | if ($theme_css != '') { |
fcae5445 |
52 | echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">"; |
692155b7 |
53 | } |
8f1ba72b |
54 | } else { |
d68323ff |
55 | echo '<link rel="stylesheet" type="text/css" href="' . |
fcae5445 |
56 | $base_uri . 'themes/css/'.$custom_css.'">'; |
8f1ba72b |
57 | } |
62f7daa5 |
58 | |
6299388d |
59 | echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'templates/default/squirrelmail.css">'; |
e2f43bfa |
60 | |
e842b215 |
61 | if ($squirrelmail_language == 'ja_JP') { |
683b7853 |
62 | /* |
e50f5ac2 |
63 | * force correct detection of charset, when browser does not follow |
683b7853 |
64 | * http content-type and tries to detect charset from page content. |
65 | * Shooting of browser's creator can't be implemented in php. |
e50f5ac2 |
66 | * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/ |
683b7853 |
67 | * recommendations and switch to unicode. |
e50f5ac2 |
68 | */ |
e842b215 |
69 | echo "<!-- \xfd\xfe -->\n"; |
fcae5445 |
70 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
71 | } |
237470b4 |
72 | if ($do_hook) { |
d68323ff |
73 | do_hook('generic_header'); |
237470b4 |
74 | } |
62f7daa5 |
75 | |
f9f738dc |
76 | echo "<title>$title</title>\n$xtra\n"; |
5ca4b1ee |
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 */ |
62f7daa5 |
83 | body { |
84 | voice-family: "\"}\""; |
85 | voice-family: inherit; |
5ca4b1ee |
86 | width: expression(document.documentElement.clientWidth - 30); |
87 | } |
88 | --> |
89 | </style> |
90 | |
91 | ECHO; |
92 | |
93 | echo "\n</head>\n\n"; |
b6c283c4 |
94 | |
95 | /* this is used to check elsewhere whether we should call this function */ |
96 | $pageheader_sent = TRUE; |
a07cd1a4 |
97 | } |
98 | |
8b096f0a |
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 | */ |
d62c4938 |
106 | function makeInternalLink($path, $text, $target='') { |
0365891c |
107 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
dcc1cc82 |
108 | if ($target != '') { |
109 | $target = " target=\"$target\""; |
110 | } |
4910106a |
111 | |
e50f5ac2 |
112 | // This is an inefficient hook and is only used by |
4910106a |
113 | // one plugin that still needs to patch this code, |
e50f5ac2 |
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?) |
4910106a |
117 | // use for the internal_link hook. |
118 | // |
119 | //$hooktext = do_hook_function('internal_link',$text); |
120 | //if ($hooktext != '') |
121 | // $text = $hooktext; |
122 | |
d62c4938 |
123 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
124 | } |
125 | |
8b096f0a |
126 | /** |
127 | * Same as makeInternalLink, but echoes it too |
128 | */ |
d62c4938 |
129 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
130 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
131 | } |
132 | |
8b096f0a |
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 |
91c27aee |
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 |
8b096f0a |
142 | * @return void |
143 | */ |
715225af |
144 | |
91c27aee |
145 | function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') { |
146 | global $hide_sm_attributions, $frame_top, |
ce68b76b |
147 | $provider_name, $provider_uri, $startMessage, |
91c27aee |
148 | $javascript_on; |
715225af |
149 | |
0365891c |
150 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
91c27aee |
151 | |
d03f3582 |
152 | if (!isset($frame_top)) { |
153 | $frame_top = '_top'; |
154 | } |
715225af |
155 | |
c18f58c5 |
156 | if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) { |
a3d59ec3 |
157 | $sJsBlock = '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
91c27aee |
158 | if ($sHeaderJs) { |
a3d59ec3 |
159 | $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
91c27aee |
160 | "\n<!--\n" . |
a3d59ec3 |
161 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
d62c4938 |
162 | } |
91c27aee |
163 | displayHtmlHeader ('SquirrelMail', $sJsBlock); |
164 | } else { |
d62c4938 |
165 | /* do not use JavaScript */ |
166 | displayHtmlHeader ('SquirrelMail'); |
91c27aee |
167 | $sBodyTagJs = ''; |
715225af |
168 | } |
169 | |
91c27aee |
170 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
171 | |
a07cd1a4 |
172 | /** Here is the header and wrapping table **/ |
72520f77 |
173 | $shortBoxName = htmlspecialchars(imap_utf7_decode_local( |
91e0dccc |
174 | readShortMailboxName($mailbox, $delimiter))); |
3b7d68e6 |
175 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
176 | $shortBoxName = _("INBOX"); |
177 | } |
b01b21d0 |
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"; |
5bb2a991 |
182 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
183 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
184 | } else { |
185 | echo ' '; |
186 | } |
b01b21d0 |
187 | echo " </td>\n" |
188 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
189 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
190 | echo "</b></td>\n" |
191 | . " </tr>\n" |
192 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
99ea51d3 |
193 | . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' ) |
194 | : html_tag( 'td', '', 'left' ) ) |
195 | . "\n"; |
a07cd1a4 |
196 | $urlMailbox = urlencode($mailbox); |
0493ed11 |
197 | $startMessage = (int)$startMessage; |
198 | |
e233a3ad |
199 | echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage); |
a07cd1a4 |
200 | echo " \n"; |
21a957a9 |
201 | displayInternalLink ('src/addressbook.php', _("Addresses")); |
a07cd1a4 |
202 | echo " \n"; |
21a957a9 |
203 | displayInternalLink ('src/folders.php', _("Folders")); |
a07cd1a4 |
204 | echo " \n"; |
21a957a9 |
205 | displayInternalLink ('src/options.php', _("Options")); |
a07cd1a4 |
206 | echo " \n"; |
21a957a9 |
207 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search")); |
a07cd1a4 |
208 | echo " \n"; |
21a957a9 |
209 | displayInternalLink ('src/help.php', _("Help")); |
a07cd1a4 |
210 | echo " \n"; |
211 | |
d68323ff |
212 | do_hook('menuline'); |
a07cd1a4 |
213 | |
99ea51d3 |
214 | echo " </td>\n"; |
215 | |
216 | if (!$hide_sm_attributions) |
217 | { |
218 | echo html_tag( 'td', '', 'right' ) ."\n"; |
8b5c49cd |
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 | } |
99ea51d3 |
225 | echo "</td>\n"; |
226 | } |
227 | echo " </tr>\n". |
04fa3c41 |
228 | "</table><br />\n\n"; |
a07cd1a4 |
229 | } |
2ba13803 |
230 | |
8b096f0a |
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 |
91c27aee |
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 |
8b096f0a |
239 | * @return void |
240 | */ |
91c27aee |
241 | function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') { |
d62c4938 |
242 | global $javascript_on; |
9c3e6cd4 |
243 | /* |
d62c4938 |
244 | * Locate the first displayable form element (only when JavaScript on) |
245 | */ |
246 | if($javascript_on) { |
91c27aee |
247 | if ($sHeaderJs) { |
248 | $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" . |
249 | "\n<!--\n" . |
a3d59ec3 |
250 | $sHeaderJs . "\n\n// -->\n</script>\n"; |
91c27aee |
251 | } else { |
252 | $sJsBlock = ''; |
d62c4938 |
253 | } |
91c27aee |
254 | $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n"; |
255 | displayHtmlHeader (_("Compose"), $sJsBlock); |
d62c4938 |
256 | } else { |
257 | /* javascript off */ |
258 | displayHtmlHeader(_("Compose")); |
259 | $onload = ''; |
9c3e6cd4 |
260 | } |
91c27aee |
261 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n"; |
9c3e6cd4 |
262 | } |
f8a1ed5a |
263 | ?> |