page_header.php 4.0 KB

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