e32bee31109b8e53781c04378d389404e32464ae
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 displayInternalLink($path, $text, $target='') {
47 $target = " target=\"$target\"";
50 echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
53 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
55 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top,
56 $compose_new_win, $username, $datadir, $compose_width, $compose_height,
57 $attachemessages, $session;
59 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
60 if ($qmark = strpos($module, '?')) {
61 $module = substr($module, 0, $qmark);
63 if (!isset($frame_top)) {
68 Locate the first displayable form element
71 if ($session != false) {
72 $compose_uri = 'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
74 $compose_uri = 'src/compose.php?newmessage=1';
79 case 'src/read_body.php':
80 if ($compose_new_win == '1') {
81 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
82 $compose_width = '640';
84 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
85 $compose_height = '550';
87 $js = "\n".'<script language="JavaScript" type="text/javascript">' .
89 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
90 ' if (new_mes) { '."\n".
91 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
93 " if (comp_uri =='') {\n".
94 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
97 ' var newwin = window.open(comp_uri' .
99 "width='.$compose_width.",height=$compose_height".
100 ",scrollbars=yes,resizable=yes\");\n".
105 displayHtmlHeader ('Squirrelmail', $js);
110 case 'src/compose.php':
111 $js = '<script language="JavaScript" type="text/javascript">' .
113 "function checkForm() {\n".
114 "var f = document.forms.length;\n".
117 "while( pos == -1 && i < f ) {\n".
118 "var e = document.forms[i].elements.length;\n".
120 "while( pos == -1 && j < e ) {\n".
121 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
128 "if( pos >= 0 ) {\n".
129 "document.forms[i-1].elements[pos].focus();\n".
135 $onload = "onLoad=\"checkForm();\"";
136 displayHtmlHeader ('Squirrelmail', $js);
140 $js = '<script language="JavaScript" type="text/javascript">' .
142 "function checkForm() {\n".
143 "var f = document.forms.length;\n".
146 "while( pos == -1 && i < f ) {\n".
147 "var e = document.forms[i].elements.length;\n".
149 "while( pos == -1 && j < e ) {\n".
150 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
157 "if( pos >= 0 ) {\n".
158 "document.forms[i-1].elements[pos].focus();\n".
163 if ($compose_new_win == '1') {
164 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
165 $compose_width = '640';
167 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
168 $compose_height = '550';
170 $js .= "function comp_in_new(new_mes, comp_uri) {\n".
171 ' if (new_mes) { '."\n".
172 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
174 " if (comp_uri =='') {\n".
175 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
178 ' var newwin = window.open(comp_uri' .
180 "width='.$compose_width.",height=$compose_height".
181 ",scrollbars=yes,resizable=yes\");\n".
186 $onload = "onLoad=\"checkForm();\"";
187 displayHtmlHeader ('Squirrelmail', $js);
192 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
193 /** Here is the header and wrapping table **/
194 $shortBoxName = imap_utf7_decode_local(
195 readShortMailboxName($mailbox, $delimiter));
196 if ( $shortBoxName == 'INBOX' ) {
197 $shortBoxName = _("INBOX");
199 echo "<a name=\"pagetop\"></a>\n"
200 . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
201 . html_tag( 'tr', '', '', $color[9] ) ."\n"
202 . html_tag( 'td', '', 'left' ) ."\n";
203 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
204 echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n";
209 . html_tag( 'td', '', 'right' ) ."<b>\n";
210 displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
213 . html_tag( 'tr', '', '', $color[4] ) ."\n"
214 . html_tag( 'td', '', 'left' ) ."\n";
215 $urlMailbox = urlencode($mailbox);
216 if ($compose_new_win == '1') {
217 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(true,'')\">". _("Compose"). '</a>';
220 displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
222 echo " \n";
223 displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
224 echo " \n";
225 displayInternalLink ("src/folders.php", _("Folders"), 'right');
226 echo " \n";
227 displayInternalLink ("src/options.php", _("Options"), 'right');
228 echo " \n";
229 displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
230 echo " \n";
231 displayInternalLink ("src/help.php", _("Help"), 'right');
232 echo " \n";
237 . html_tag( 'td', '', 'right' ) ."\n";
238 echo ($hide_sm_attributions ?
' ' :
239 '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>');
245 /* blatently copied/truncated/modified from the above function */
246 function compose_Header($color, $mailbox) {
248 global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
251 $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
252 if (!isset($frame_top)) {
257 Locate the first displayable form element
260 case 'src/search.php':
261 $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
262 $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
263 displayHtmlHeader (_("Compose"));
266 $js = '<script language="JavaScript" type="text/javascript">' .
268 "function checkForm() {\n".
269 "var f = document.forms.length;\n".
272 "while( pos == -1 && i < f ) {\n".
273 "var e = document.forms[i].elements.length;\n".
275 "while( pos == -1 && j < e ) {\n".
276 "if ( document.forms[i].elements[j].type == 'text' ) {\n".
283 "if( pos >= 0 ) {\n".
284 "document.forms[i-1].elements[pos].focus();\n".
289 $onload = "onLoad=\"checkForm();\"";
290 displayHtmlHeader (_("Compose"), $js);
295 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
298 function initPage () {
300 global $theme_css, $custom_css, $base_uri;
302 $page->addChild('','<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
303 $page->addChild('HTML');
307 function initHead ($title = 'SquirrelMail') {
308 global $use_css, $compose_new_win, $compose_width, $compose_height,
311 $head = new html('head');
312 $head->addChild('title', $title);
314 $head->addChild('link','','','','',
315 array('REL' => 'stylesheet', 'TYPE' => 'text/css',
316 'HREF' => $base_uri .'/css/read_body.css'));
318 if ($compose_new_win == '1') {
319 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
320 $compose_width = '640';
322 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
323 $compose_height = '550';
325 $js = "function comp_in_new(new_mes, comp_uri) {\n".
326 ' if (new_mes) { '."\n".
327 " comp_uri = \"".$base_uri."src/compose.php?newmessage=1\";\n".
329 " if (comp_uri =='') {\n".
330 ' comp_uri = "'.$base_uri.$compose_uri."\";\n".
333 ' var newwin = window.open(comp_uri' .
335 "width='.$compose_width.",height=$compose_height".
336 ",scrollbars=yes,resizable=yes\");\n".
338 $head->scriptAdd($js);
343 function initBody($color, $javascript='') {
347 $body = new html('body','','','','',
348 array('bgcolor' => $color[4], 'text' => $color[8], 'link' => $color[7],
349 'vlink' => $color[7], 'alink' => $color[7]), $javascript);
351 $body = new html('body','','','','','',$javascript);
357 function getTop($color, $mailbox) {
359 global $use_css, $languages, $squirrelmail_language, $frame_top,
360 $delimiter, $base_uri;
362 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
363 $dir = $languages[$squirrelmail_language]['DIR'];
368 if ( $dir == 'ltr' ) {
379 $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%',
380 'cellspacing' => 0, 'cellpadding' => 2);
381 $row_ar = array('bgcolor' => $color[9]);
382 $col_ar = array('align' => $lft);
384 $tbl_ar = array('border' => 0,
385 'cellspacing' => 0, 'cellpadding' => 2);
387 $col_ar = array('align' => $lft);
390 $shortBoxName = imap_utf7_decode_local(
391 readShortMailboxName($mailbox, $delimiter));
392 if ( $shortBoxName == 'INBOX' ) {
393 $shortBoxName = _("INBOX");
396 $top = new html('table','','','tp','tp',$tbl_ar);
397 $row = new html('tr','','','tp_r','tp_r',$row_ar);
399 if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
400 $row->addChild('td',_("Current Folder") .':','','tp_c','tp_mbx_k',
401 array('align' => $lft));
402 $row->addChild('td',$shortBoxName .' ',array('b'=>true),'tp_c',
403 'tp_mbx_v',array('align' => $lft));
405 $col = new html('td','','','tp_c','tp_so',array('align' => $rgt));
407 $lnk_ar = array('href' => $base_uri.'src/signout.php', 'target' => $frame_top);
409 $lnk_ar = array('href' => $base_uri.'src/signout.php');
411 $col->addChild('a', _("Sign Out"),array('b'=>true),'','',$lnk_ar);
418 function getMenu($color,$mailbox) {
419 global $use_css, $languages, $squirrelmail_language, $frame_top, $base_uri,
420 $compose_new_win,$hide_sm_attributions;
422 $urlMailbox = urlencode($mailbox);
424 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
425 $dir = $languages[$squirrelmail_language]['DIR'];
430 if ( $dir == 'ltr' ) {
439 $tbl_ar = array('bgcolor' => $color[4], 'border' => 0, 'width' => '100%',
440 'cellspacing' => 0, 'cellpadding' => 2);
441 $row_ar = array('bgcolor' => $color[4]);
442 $col_ar = array('align' => $lft);
444 $tbl_ar = array('border' => 0,
445 'cellspacing' => 0, 'cellpadding' => 2);
447 $col_ar = array('align' => $lft);
450 $menu = new html('table','','','mn','mn',$tbl_ar);
451 $row = new html('tr','','','mn','mn_r',$row_ar);
452 $col = new html('td','','','mn','mn_c',$col_ar);
453 $delimiter = new html('',' ');
454 if ($compose_new_win == '1') {
455 $col->addChild('a',_("Compose"),'','mn_c','mn_co',
456 array('href' => 'javascript:void(0)'),
457 array('onclick'=>'comp_in_new(true,"")'));
459 $col->addChild('a',_("Compose"),'','mn_c','mn_co',
460 array('href' => $base_uri.'src/compose.php?mailbox='.$urlMailbox,
461 'target' => 'right'));
463 $col->htmlAdd($delimiter);
464 $col->addChild('a',_("Addresses"),'','mn_c','mn_ad',
465 array('href' => $base_uri.'src/addressbook.php',
466 'target' => 'right'));
467 $col->htmlAdd($delimiter);
468 $col->addChild('a',_("Folders"),'','mn_c','mn_fo',
469 array('href' => $base_uri.'src/folders.php',
470 'target' => 'right'));
471 $col->htmlAdd($delimiter);
473 $col->addChild('a',_("Options"),'','mn_c','mn_op',
474 array('href' => $base_uri.'src/options.php',
475 'target' => 'right'));
476 $col->htmlAdd($delimiter);
477 $col->addChild('a',_("Search"),'','mn_c','mn_se',
478 array('href' => $base_uri.'src/search.php?mailbox='.$urlMailbox,
479 'target' => 'right'));
480 $col->htmlAdd($delimiter);
481 $col->addChild('a',_("Help"),'','mn_c','mn_he',
482 array('href' => $base_uri.'src/help.php',
483 'target' => 'right'));
487 if (!$hide_sm_attributions) {
488 $col = new html('td','','','mn','mn_sm',array('align'=>$rgt));
489 $col->addChild('a','SquirrelMail','','','',
490 array('href'=>'http://www.squirrelmail.org','target'=>'_blank'));
493 $menu->htmlAdd($row);