page_header.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. include_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;
  40. displayHtmlHeader ();
  41. $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
  42. /*
  43. Locate the first displayable form element
  44. */
  45. switch ( $module ) {
  46. case 'src/search.php':
  47. $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
  48. $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
  49. break;
  50. default:
  51. echo '
  52. <script language="JavaScript">
  53. <!--
  54. function checkForm() {
  55. var f = document.forms.length;
  56. var i = 0;
  57. var pos = -1;
  58. while( pos == -1 && i < f ) {
  59. var e = document.forms[i].elements.length;
  60. var j = 0;
  61. while( pos == -1 && j < e ) {
  62. if ( document.forms[i].elements[j].type == \'text\' ) {
  63. pos = j;
  64. }
  65. j++;
  66. }
  67. i++;
  68. }
  69. if( pos >= 0 ) {
  70. document.forms[i-1].elements[pos].focus();
  71. }
  72. }
  73. // -->
  74. </script>
  75. ';
  76. $onload = "onLoad=\"checkForm();\"";
  77. break;
  78. }
  79. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
  80. /** Here is the header and wrapping table **/
  81. $shortBoxName = readShortMailboxName($mailbox, $delimiter);
  82. echo "<A NAME=pagetop></A>\n"
  83. . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
  84. . " <TR BGCOLOR=\"$color[9]\" >\n"
  85. . " <TD ALIGN=left>\n"
  86. . ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n"
  87. . " </TD>\n"
  88. . " <TD ALIGN=right><b>\n";
  89. displayInternalLink ('src/signout.php', _("Sign Out"), '_top');
  90. echo " </b></TD>\n"
  91. . " </TR>\n"
  92. . " <TR BGCOLOR=\"$color[4]\">\n"
  93. . " <TD ALIGN=left>\n";
  94. $urlMailbox = urlencode($mailbox);
  95. displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
  96. echo "&nbsp;&nbsp;\n";
  97. displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
  98. echo "&nbsp;&nbsp;\n";
  99. displayInternalLink ("src/folders.php", _("Folders"), 'right');
  100. echo "&nbsp;&nbsp;\n";
  101. displayInternalLink ("src/options.php", _("Options"), 'right');
  102. echo "&nbsp;&nbsp;\n";
  103. displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
  104. echo "&nbsp;&nbsp;\n";
  105. displayInternalLink ("src/help.php", _("Help"), 'right');
  106. echo "&nbsp;&nbsp;\n";
  107. do_hook("menuline");
  108. echo " </TD><TD ALIGN=right>\n";
  109. echo ($hide_sm_attributions ? '&nbsp;' :
  110. "<A HREF=\"http://www.squirrelmail.org/\" TARGET=\"_blank\">SquirrelMail</A>\n");
  111. echo " </TD>\n".
  112. " </TR>\n".
  113. "</TABLE>\n\n";
  114. }
  115. ?>