page_header.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * page_header.php
  4. *
  5. * Copyright (c) 1999-2002 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Prints the page header (duh)
  9. *
  10. * $Id$
  11. */
  12. // Always set up the language before calling these functions
  13. function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
  14. global $theme_css;
  15. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
  16. "\n\n<HTML>\n<HEAD>\n";
  17. if ($theme_css != '') {
  18. echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
  19. }
  20. if( $do_hook ) {
  21. do_hook ("generic_header");
  22. }
  23. echo "<title>$title</title>$xtra</head>\n\n";
  24. }
  25. function displayInternalLink($path, $text, $target='') {
  26. global $base_uri;
  27. if ($target != '') {
  28. $target = " target=\"$target\"";
  29. }
  30. echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
  31. }
  32. function displayPageHeader($color, $mailbox) {
  33. global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF;
  34. displayHtmlHeader ();
  35. $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
  36. /*
  37. Locate the first displayable form element
  38. */
  39. switch ( $module ) {
  40. case 'src/search.php':
  41. $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
  42. $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
  43. break;
  44. default:
  45. echo '
  46. <script language="JavaScript">
  47. <!--
  48. function checkForm() {
  49. var f = document.forms.length;
  50. var i = 0;
  51. var pos = -1;
  52. while( pos == -1 && i < f ) {
  53. var e = document.forms[i].elements.length;
  54. var j = 0;
  55. while( pos == -1 && j < e ) {
  56. if ( document.forms[i].elements[j].type == \'text\' ) {
  57. pos = j;
  58. }
  59. j++;
  60. }
  61. i++;
  62. }
  63. if( pos >= 0 ) {
  64. // document.write( "Si tio" );
  65. document.forms[i-1].elements[pos].focus();
  66. }
  67. }
  68. -->
  69. </script>
  70. ';
  71. $onload = "onLoad=\"checkForm();\"";
  72. break;
  73. }
  74. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
  75. /** Here is the header and wrapping table **/
  76. $shortBoxName = readShortMailboxName($mailbox, $delimiter);
  77. echo "<A NAME=pagetop></A>\n"
  78. . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
  79. . " <TR BGCOLOR=\"$color[9]\" >\n"
  80. . " <TD ALIGN=left>\n"
  81. . ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n"
  82. . " </TD>\n"
  83. . " <TD ALIGN=right><b>\n";
  84. displayInternalLink ('src/signout.php', _("Sign Out"), '_top');
  85. echo " </b></TD>\n"
  86. . " </TR>\n"
  87. . " <TR BGCOLOR=\"$color[4]\">\n"
  88. . " <TD ALIGN=left>\n";
  89. $urlMailbox = urlencode($mailbox);
  90. displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
  91. echo "&nbsp;&nbsp;\n";
  92. displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
  93. echo "&nbsp;&nbsp;\n";
  94. displayInternalLink ("src/folders.php", _("Folders"), 'right');
  95. echo "&nbsp;&nbsp;\n";
  96. displayInternalLink ("src/options.php", _("Options"), 'right');
  97. echo "&nbsp;&nbsp;\n";
  98. displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
  99. echo "&nbsp;&nbsp;\n";
  100. displayInternalLink ("src/help.php", _("Help"), 'right');
  101. echo "&nbsp;&nbsp;\n";
  102. do_hook("menuline");
  103. echo " </TD><TD ALIGN=right>\n";
  104. echo ($hide_sm_attributions ? '&nbsp;' :
  105. "<A HREF=\"http://www.squirrelmail.org/\" TARGET=\"_blank\">SquirrelMail</A>\n");
  106. echo " </TD>\n".
  107. " </TR>\n".
  108. "</TABLE>\n\n";
  109. }
  110. ?>