page_header.php 4.2 KB

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