Request a sqimap_run_command_list instead of a sqimap_run_command because in
[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-2006 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 /** @ignore */
15 if (! defined('SM_PATH')) define('SM_PATH','../');
16
17 /** Include required files from SM */
18 require_once(SM_PATH . 'functions/strings.php');
19 require_once(SM_PATH . 'functions/html.php');
20 require_once(SM_PATH . 'functions/imap_mailbox.php');
21 require_once(SM_PATH . 'functions/global.php');
22 include_once(SM_PATH . 'class/template/template.class.php');
23
24 /**
25 * Output a SquirrelMail page header, from <!doctype> to </head>
26 * Always set up the language before calling these functions.
27 *
28 * Since 1.5.1 function sends http headers. Function should be called
29 * before any output is started.
30 * @param string title the page title, default SquirrelMail.
31 * @param string xtra extra HTML to insert into the header
32 * @param bool do_hook whether to execute hooks, default true
33 * @param bool frames generate html frameset doctype (since 1.5.1)
34 * @return void
35 */
36 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
37 global $squirrelmail_language, $sTplDir;
38
39 if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
40 global $base_uri;
41 }
42 global $theme_css, $custom_css, $pageheader_sent,
43 $chosen_fontset, $chosen_fontsize, $chosen_theme;
44
45 /* add no cache headers here */
46 header('Pragma: no-cache'); // http 1.0 (rfc1945)
47 header('Cache-Control: private, no-cache, no-store'); // http 1.1 (rfc2616)
48
49 if ($frames) {
50 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
51 } else {
52 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
53 }
54 echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
55 "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
56
57
58 $used_theme = basename($chosen_theme,'.php');
59
60 /*
61 * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
62 * It is not compatible with html 4.01 Transitional
63 */
64 echo '<link rel="stylesheet" type="text/css" href="'. $base_uri .'src/style.php'
65 .'?fontset='.$chosen_fontset
66 .'&themeid='.$used_theme
67 .(isset($chosen_fontsize) ? '&fontsize='.$chosen_fontsize : '')."\">\n";
68
69 // load custom style sheet (deprecated)
70 if ( !isset( $theme_css ) || empty($theme_css) ) {
71 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
72 }
73
74 if ($squirrelmail_language == 'ja_JP') {
75 /*
76 * force correct detection of charset, when browser does not follow
77 * http content-type and tries to detect charset from page content.
78 * Shooting of browser's creator can't be implemented in php.
79 * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
80 * recommendations and switch to unicode.
81 */
82 echo "<!-- \xfd\xfe -->\n";
83 echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
84 }
85 if ($do_hook) {
86 do_hook('generic_header');
87 }
88
89 echo "<title>$title</title>\n$xtra\n";
90
91 /* work around IE6's scrollbar bug */
92 echo <<<ECHO
93 <style type="text/css">
94 <!--
95 /* avoid stupid IE6 bug with frames and scrollbars */
96 body {
97 voice-family: "\"}\"";
98 voice-family: inherit;
99 width: expression(document.documentElement.clientWidth - 30);
100 }
101 -->
102 </style>
103
104 ECHO;
105
106 echo "\n</head>\n\n";
107
108 /* this is used to check elsewhere whether we should call this function */
109 $pageheader_sent = TRUE;
110 }
111
112 /**
113 * Given a path to a SquirrelMail file, return a HTML link to it
114 *
115 * @param string path the SquirrelMail file to link to
116 * @param string text the link text
117 * @param string target the target frame for this link
118 */
119 function makeInternalLink($path, $text, $target='') {
120 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
121 if ($target != '') {
122 $target = " target=\"$target\"";
123 }
124
125 // This is an inefficient hook and is only used by
126 // one plugin that still needs to patch this code,
127 // plus if we are templat-izing SM, visual hooks
128 // are not needed. However, I am leaving the code
129 // here just in case we find a good (non-visual?)
130 // use for the internal_link hook.
131 //
132 //$hooktext = do_hook_function('internal_link',$text);
133 //if ($hooktext != '')
134 // $text = $hooktext;
135
136 return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
137 }
138
139 /**
140 * Same as makeInternalLink, but echoes it too
141 */
142 function displayInternalLink($path, $text, $target='') {
143 echo makeInternalLink($path, $text, $target);
144 }
145
146 /**
147 * Outputs a complete SquirrelMail page header, starting with <!doctype> and
148 * including the default menu bar. Uses displayHtmlHeader and takes
149 * JavaScript and locale settings into account.
150 *
151 * @param array color the array of theme colors
152 * @param string mailbox the current mailbox name to display
153 * @param string sHeaderJs javascipt code to be inserted in a script block in the header
154 * @param string sBodyTagJs js events to be inserted in the body tag
155 * @return void
156 */
157
158 function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
159
160 global $reply_focus, $hide_sm_attributions, $frame_top,
161 $provider_name, $provider_uri, $startMessage,
162 $javascript_on, $action, $oTemplate;
163
164 if (empty($sBodyTagJs)) {
165 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
166 if ($reply_focus == 'select')
167 $sBodyTagJs = 'onload="checkForm(\'select\');"';
168 else if ($reply_focus == 'focus')
169 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
170 else if ($reply_focus != 'none')
171 $sBodyTagJs = 'onload="checkForm();"';
172 }
173 else
174 $sBodyTagJs = 'onload="checkForm();"';
175 }
176
177 $urlMailbox = urlencode($mailbox);
178 $startMessage = (int)$startMessage;
179
180 $sTplDir = $oTemplate->template_dir;
181
182 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
183
184 if (!isset($frame_top)) {
185 $frame_top = '_top';
186 }
187
188 if( $javascript_on || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
189 $sJsBlock = '<script src="'. $sTplDir. 'js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
190 if ($sHeaderJs) {
191 $sJsBlock .= "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
192 "\n<!--\n" .
193 $sHeaderJs . "\n\n// -->\n</script>\n";
194 }
195 displayHtmlHeader ('SquirrelMail', $sJsBlock);
196 } else {
197 /* do not use JavaScript */
198 displayHtmlHeader ('SquirrelMail');
199 $sBodyTagJs = '';
200 }
201
202 $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
203 readShortMailboxName($mailbox, $delimiter)));
204 if ( $shortBoxName == 'INBOX' ) {
205 $shortBoxName = _("INBOX");
206 }
207
208 $sm_attributes = '';
209 if (!$hide_sm_attributions) {
210 $sm_attributes .= '<td class="sqm_providerInfo">' ."\n";
211 if (empty($provider_uri)) {
212 $sm_attributes .= ' <a href="about.php">SquirrelMail</a>';
213 } else {
214 if (empty($provider_name)) $provider_name= 'SquirrelMail';
215 $sm_attributes .= ' <a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'."\n";
216 }
217 $sm_attributes .= " </td>\n";
218 }
219
220 $oTemplate->assign('body_tag_js', $sBodyTagJs);
221 $oTemplate->assign('shortBoxName', $shortBoxName);
222 $oTemplate->assign('sm_attribute_str', $sm_attributes);
223 $oTemplate->assign('frame_top', $frame_top);
224 $oTemplate->assign('urlMailbox', $urlMailbox);
225 $oTemplate->assign('startMessage', $startMessage);
226 $oTemplate->assign('hide_sm_attributions', $hide_sm_attributions);
227 $oTemplate->display('page_header.tpl');
228 }
229
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
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
238 * @return void
239 */
240 function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') {
241
242 global $reply_focus, $javascript_on, $action;
243
244 if (empty($sBodyTagJs)) {
245 if (strpos($action, 'reply') !== FALSE && $reply_focus) {
246 if ($reply_focus == 'select')
247 $sBodyTagJs = 'onload="checkForm(\'select\');"';
248 else if ($reply_focus == 'focus')
249 $sBodyTagJs = 'onload="checkForm(\'focus\');"';
250 else if ($reply_focus != 'none')
251 $sBodyTagJs = 'onload="checkForm();"';
252 }
253 else
254 $sBodyTagJs = 'onload="checkForm();"';
255 }
256
257
258 /*
259 * Locate the first displayable form element (only when JavaScript on)
260 */
261 if($javascript_on) {
262 if ($sHeaderJs) {
263 $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
264 "\n<!--\n" .
265 $sHeaderJs . "\n\n// -->\n</script>\n";
266 } else {
267 $sJsBlock = '';
268 }
269 $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
270 displayHtmlHeader (_("Compose"), $sJsBlock);
271 } else {
272 /* javascript off */
273 displayHtmlHeader(_("Compose"));
274 $onload = '';
275 }
276 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
277 }
278 ?>