6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Prints the page header (duh)
14 require_once('../functions/strings.php');
15 require_once('../functions/imap_utf7_decode_local.php');
16 require_once('../functions/html.php');
17 require_once('../class/html.class.php');
19 /* Always set up the language before calling these functions */
20 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
22 global $theme_css, $custom_css, $base_uri;
24 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
25 "\n\n<HTML>\n<HEAD>\n";
27 if ( !isset( $custom_css ) ||
$custom_css == 'none' ) {
28 if ($theme_css != '') {
29 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">";
32 echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
33 $base_uri . 'themes/css/'.$custom_css.'">';
37 do_hook("generic_header");
40 echo "\n<title>$title</title>$xtra</head>\n\n";
43 function initPage () {
45 $page->addChild('','<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
46 $page->addChild('HTML');
50 function initHead ($title = 'SquirrelMail', $session=false) {
51 global $use_css, $compose_new_win, $compose_width, $compose_height,
54 if ($session != false) {
55 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
57 $compose_uri = 'src/compose.php?newmessage=1';
62 $head = new html('head');
63 $head->addChild('title', $title);
65 // $head->addChild('link','','','','',
66 // array('REL' => 'stylesheet', 'TYPE' => 'text/css',
67 // 'HREF' => $base_uri .'/css/read_body.css'));
69 if ($compose_new_win == '1') {
70 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
71 $compose_width = '640';
73 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
74 $compose_height = '550';
76 $js = "function comp_in_new(comp_uri) {\n".
77 " if (comp_uri =='') {\n".
78 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
80 ' var newwin = window.open(comp_uri' .
82 '"width='.$compose_width. ',height='.$compose_height.
83 '",scrollbars="yes",resizable="yes");'."\n".
87 $head->scriptAdd($js);
89 $js = 'function sendMDN() {'."\n".
90 "mdnuri=window.location+'&sendreceipt=1';".
91 "var newwin = window.open(mdnuri,'right');".
93 $head->scriptAdd($js);
98 function initBody($color, $javascript='') {
102 $body = new html('body','','','','',
103 array('bgcolor' => $color[4], 'text' => $color[8], 'link' => $color[7],
104 'vlink' => $color[7], 'alink' => $color[7]), $javascript);
106 $body = new html('body','','','','','',$javascript);
112 function getTop($color, $mailbox) {
114 global $use_css, $languages, $squirrelmail_language, $frame_top,
115 $delimiter, $base_uri;
117 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
118 $dir = $languages[$squirrelmail_language]['DIR'];
123 if ( $dir == 'ltr' ) {
134 $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%',
135 'cellspacing' => 0, 'cellpadding' => 2);
136 $row_ar = array('bgcolor' => $color[9]);
137 $col_ar = array('align' => $lft);
139 $tbl_ar = array('border' => 0,
140 'cellspacing' => 0, 'cellpadding' => 2);
142 $col_ar = array('align' => $lft);
145 $shortBoxName = imap_utf7_decode_local(
146 readShortMailboxName($mailbox, $delimiter));
147 if ( $shortBoxName == 'INBOX' ) {
148 $shortBoxName = _("INBOX");
151 $top = new html('table','','','tp','tp',$tbl_ar);
152 $row = new html('tr','','','tp_r','tp_r',$row_ar);
154 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
155 $row->addChild('td',_("Current Folder") .':','','tp_c','tp_mbx_k',
156 array('align' => $lft));
157 $row->addChild('td',$shortBoxName .' ',array('b'=>true),'tp_c',
158 'tp_mbx_v',array('align' => $lft));
160 $col = new html('td','','','tp_c','tp_so',array('align' => $rgt));
162 $lnk_ar = array('href' => $base_uri.'src/signout.php', 'target' => $frame_top);
164 $lnk_ar = array('href' => $base_uri.'src/signout.php');
166 $col->addChild('a', _("Sign Out"),array('b'=>true),'','',$lnk_ar);
173 function getMenu($color,$mailbox) {
174 global $use_css, $languages, $squirrelmail_language, $frame_top, $base_uri,
175 $compose_new_win,$hide_sm_attributions;
177 $urlMailbox = urlencode($mailbox);
179 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
180 $dir = $languages[$squirrelmail_language]['DIR'];
185 if ( $dir == 'ltr' ) {
194 $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%',
195 'cellspacing' => 0, 'cellpadding' => 2);
196 $row_ar = array('bgcolor' => $color[4]);
197 $col_ar = array('align' => $lft);
199 $tbl_ar = array('border' => 0,
200 'cellspacing' => 0, 'cellpadding' => 2);
202 $col_ar = array('align' => $lft);
205 $menu = new html('table','','','mn','mn',$tbl_ar);
206 $row = new html('tr','','','mn','mn_r',$row_ar);
207 $col = new html('td','','','mn','mn_c',$col_ar);
208 $delimiter = new html('',' ');
209 if ($compose_new_win == '1') {
210 $col->addChild('a',_("Compose"),'','mn_c','mn_co',
211 array('href' => 'javascript:void(0)'),
212 array('onclick'=> 'comp_in_new()'));
214 $col->addChild('a',_("Compose"),'','mn_c','mn_co',
215 array('href' => $base_uri.'src/compose.php?mailbox='.$urlMailbox,
216 'target' => 'right'));
218 $col->htmlAdd($delimiter);
219 $col->addChild('a',_("Addresses"),'','mn_c','mn_ad',
220 array('href' => $base_uri.'src/addressbook.php',
221 'target' => 'right'));
222 $col->htmlAdd($delimiter);
223 $col->addChild('a',_("Folders"),'','mn_c','mn_fo',
224 array('href' => $base_uri.'src/folders.php',
225 'target' => 'right'));
226 $col->htmlAdd($delimiter);
228 $col->addChild('a',_("Options"),'','mn_c','mn_op',
229 array('href' => $base_uri.'src/options.php',
230 'target' => 'right'));
231 $col->htmlAdd($delimiter);
232 $col->addChild('a',_("Search"),'','mn_c','mn_se',
233 array('href' => $base_uri.'src/search.php?mailbox='.$urlMailbox,
234 'target' => 'right'));
235 $col->htmlAdd($delimiter);
236 $col->addChild('a',_("Help"),'','mn_c','mn_he',
237 array('href' => $base_uri.'src/help.php',
238 'target' => 'right'));
242 if (!$hide_sm_attributions) {
243 $col = new html('td','','','mn','mn_sm',array('align'=>$rgt));
244 $col->addChild('a','SquirrelMail','','','',
245 array('href'=>'http://www.squirrelmail.org','target'=>'_blank'));
248 $menu->htmlAdd($row);
252 function displayInternalLink($path, $text, $target='') {
256 $target = " target=\"$target\"";
258 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
261 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
263 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
264 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
265 $attachemessages, $session;
267 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
268 if ($qmark = strpos($module, '?')) {
269 $module = substr($module, 0, $qmark);
271 if (!isset($frame_top)) {
276 Locate the first displayable form element
279 if ($session != false) {
280 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
282 $compose_uri = 'src/compose.php?newmessage=1';
287 case 'src/read_body.php':
288 if ($compose_new_win == '1') {
289 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
290 $compose_width = '640';
292 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
293 $compose_height = '550';
295 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
297 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
298 ' if (new_mes) { '."\n".
299 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
301 " if (comp_uri =='') {\n".
302 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
305 ' var newwin = window.open(comp_uri' .
307 "width='.$compose_width.",height=$compose_height".
308 ",scrollbars=yes,resizable=yes\");\n".
313 displayHtmlHeader ('Squirrelmail', $js);
318 case 'src/compose.php':
319 $js = '<script language="JavaScript" type="text/javascript">' .
321 "function checkForm() {\n".
322 "var f = document.forms.length;\n".
325 "while( pos == -1 && i < f ) {\n".
326 "var e = document.forms[i].elements.length;\n".
328 "while( pos == -1 && j < e ) {\n".
329 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
336 "if( pos >= 0 ) {\n".
337 "document.forms[i-1].elements[pos].focus();\n".
343 $onload = "onLoad=\"checkForm();\"";
344 displayHtmlHeader ('Squirrelmail', $js);
348 $js = '<script language="JavaScript" type="text/javascript">' .
350 "function checkForm() {\n".
351 "var f = document.forms.length;\n".
354 "while( pos == -1 && i < f ) {\n".
355 "var e = document.forms[i].elements.length;\n".
357 "while( pos == -1 && j < e ) {\n".
358 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
365 "if( pos >= 0 ) {\n".
366 "document.forms[i-1].elements[pos].focus();\n".
371 if ($compose_new_win == '1') {
372 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
373 $compose_width = '640';
375 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
376 $compose_height = '550';
378 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
379 ' if (new_mes) { '."\n".
380 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
382 " if (comp_uri =='') {\n".
383 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
386 ' var newwin = window.open(comp_uri' .
388 "width='.$compose_width.",height=$compose_height".
389 ",scrollbars=yes,resizable=yes\");\n".
394 $onload = "onLoad=\"checkForm();\"";
395 displayHtmlHeader ('Squirrelmail', $js);
400 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
401 /** Here is the header and wrapping table **/
402 $shortBoxName = imap_utf7_decode_local(
403 readShortMailboxName($mailbox, $delimiter));
404 if ( $shortBoxName == 'INBOX' ) {
405 $shortBoxName = _("INBOX");
407 echo "<a name=\"pagetop\"></a>\n"
408 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
409 . html_tag( 'tr', '', '', $color[9] ) ."\n"
410 . html_tag( 'td', '', 'left' ) ."\n";
411 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
412 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
417 . html_tag( 'td', '', 'right' ) ."<b>\n";
418 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
421 . html_tag( 'tr', '', '', $color[4] ) ."\n"
422 . html_tag( 'td', '', 'left' ) ."\n";
423 $urlMailbox = urlencode($mailbox);
424 if ($compose_new_win == '1') {
425 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
428 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
430 echo " \n";
431 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
432 echo " \n";
433 displayInternalLink ("src/folders.php", _("Folders"), 'right');
434 echo " \n";
435 displayInternalLink ("src/options.php", _("Options"), 'right');
436 echo " \n";
437 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
438 echo " \n";
439 displayInternalLink ("src/help.php", _("Help"), 'right');
440 echo " \n";
445 . html_tag( 'td', '', 'right' ) ."\n";
446 echo ($hide_sm_attributions ?
' ' :
447 '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>');
453 /* blatently copied/truncated/modified from the above function */
454 function compose_Header($color, $mailbox) {
456 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
459 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
460 if (!isset($frame_top)) {
465 Locate the first displayable form element
468 case 'src/search.php':
469 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
470 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
471 displayHtmlHeader (_("Compose"));
474 $js = '<script language="JavaScript" type="text/javascript">' .
476 "function checkForm() {\n".
477 "var f = document.forms.length;\n".
480 "while( pos == -1 && i < f ) {\n".
481 "var e = document.forms[i].elements.length;\n".
483 "while( pos == -1 && j < e ) {\n".
484 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
491 "if( pos >= 0 ) {\n".
492 "document.forms[i-1].elements[pos].focus();\n".
497 $onload = "onLoad=\"checkForm();\"";
498 displayHtmlHeader (_("Compose"), $js);
503 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";