page_header.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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\">";
  21. }
  22. } else {
  23. echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' .
  24. $base_uri . 'themes/css/'.$custom_css.'">';
  25. }
  26. echo "\n<title>$title</title>$xtra</head>\n\n";
  27. }
  28. function displayInternalLink($path, $text, $target='') {
  29. global $base_uri;
  30. if ($target != '') {
  31. $target = " target=\"$target\"";
  32. }
  33. echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
  34. }
  35. function displayPageHeader($color, $mailbox, $xtra='') {
  36. global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win, $username, $datadir;
  37. $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
  38. if (!isset($frame_top)) {
  39. $frame_top = '_top';
  40. }
  41. /*
  42. Locate the first displayable form element
  43. */
  44. switch ( $module ) {
  45. default:
  46. $js = '<script language="JavaScript" type="text/javascript">' .
  47. "\n<!--\n" .
  48. "function checkForm() {\n".
  49. "var f = document.forms.length;\n".
  50. "var i = 0;\n".
  51. "var pos = -1;\n".
  52. "while( pos == -1 && i < f ) {\n".
  53. "var e = document.forms[i].elements.length;\n".
  54. "var j = 0;\n".
  55. "while( pos == -1 && j < e ) {\n".
  56. "if ( document.forms[i].elements[j].type == 'text' ) {\n".
  57. "pos = j;\n".
  58. "}\n".
  59. "j++;\n".
  60. "}\n".
  61. "i++;\n".
  62. "}\n".
  63. "if( pos >= 0 ) {\n".
  64. "document.forms[i-1].elements[pos].focus();\n".
  65. "}\n".
  66. "$xtra\n".
  67. "}\n";
  68. if ($compose_new_win == '1') {
  69. $width= getPref($username, $datadir, 'editor_size', 76);
  70. if ($width < 65) {
  71. $pix_width = 560;
  72. }
  73. else {
  74. $width = (.9*$width);
  75. $pix_width = intval($width).'0';
  76. }
  77. $js .= "function comp_in_new() {\n".
  78. " var newwin = window.open(\"".$base_uri."src/compose.php\"".
  79. ", \"compose_window\", \"width=".$pix_width.",height=650".
  80. ",scrollbars=yes,resizable=yes\");\n".
  81. "}\n";
  82. }
  83. $js .= "// -->\n".
  84. "</script>\n";
  85. $onload = "onLoad=\"checkForm();\"";
  86. displayHtmlHeader ('Squirrelmail', $js);
  87. break;
  88. }
  89. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
  90. /** Here is the header and wrapping table **/
  91. $shortBoxName = readShortMailboxName($mailbox, $delimiter);
  92. if ( $shortBoxName == 'INBOX' ) {
  93. $shortBoxName = _("INBOX");
  94. }
  95. echo "<A NAME=pagetop></A>\n"
  96. . "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n"
  97. . " <TR BGCOLOR=\"$color[9]\" >\n"
  98. . " <TD ALIGN=left>\n";
  99. if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
  100. echo ' ' . _("Current Folder") . ": <B>$shortBoxName&nbsp;</B>\n";
  101. } else {
  102. echo '&nbsp;';
  103. }
  104. echo " </TD>\n"
  105. . ' <TD ALIGN=right><b>';
  106. displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
  107. echo "</b></TD>\n"
  108. . " </TR>\n"
  109. . " <TR BGCOLOR=\"$color[4]\">\n"
  110. . " <TD ALIGN=left>\n";
  111. $urlMailbox = urlencode($mailbox);
  112. if ($compose_new_win == '1') {
  113. echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=".
  114. '"compose_window" onClick="comp_in_new()">'. _("Compose"). '</a>';
  115. }
  116. else {
  117. displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
  118. }
  119. echo "&nbsp;&nbsp;\n";
  120. displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
  121. echo "&nbsp;&nbsp;\n";
  122. displayInternalLink ("src/folders.php", _("Folders"), 'right');
  123. echo "&nbsp;&nbsp;\n";
  124. displayInternalLink ("src/options.php", _("Options"), 'right');
  125. echo "&nbsp;&nbsp;\n";
  126. displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right');
  127. echo "&nbsp;&nbsp;\n";
  128. displayInternalLink ("src/help.php", _("Help"), 'right');
  129. echo "&nbsp;&nbsp;\n";
  130. do_hook("menuline");
  131. echo " </TD>\n <TD ALIGN=\"right\">";
  132. echo ($hide_sm_attributions ? '&nbsp;' :
  133. '<A HREF="http://www.squirrelmail.org/" TARGET="_blank">SquirrelMail</A>');
  134. echo "</TD>\n".
  135. " </TR>\n".
  136. "</TABLE>\n\n";
  137. }
  138. /* blatently copied/truncated/modified from the above function */
  139. function compose_Header($color, $mailbox) {
  140. global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
  141. $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
  142. if (!isset($frame_top)) {
  143. $frame_top = '_top';
  144. }
  145. /*
  146. Locate the first displayable form element
  147. */
  148. switch ( $module ) {
  149. case 'src/search.php':
  150. $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
  151. $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\"";
  152. displayHtmlHeader (_("Compose"));
  153. break;
  154. default:
  155. $js = '<script language="JavaScript" type="text/javascript">' .
  156. "\n<!--\n" .
  157. "function checkForm() {\n".
  158. "var f = document.forms.length;\n".
  159. "var i = 0;\n".
  160. "var pos = -1;\n".
  161. "while( pos == -1 && i < f ) {\n".
  162. "var e = document.forms[i].elements.length;\n".
  163. "var j = 0;\n".
  164. "while( pos == -1 && j < e ) {\n".
  165. "if ( document.forms[i].elements[j].type == 'text' ) {\n".
  166. "pos = j;\n".
  167. "}\n".
  168. "j++;\n".
  169. "}\n".
  170. "i++;\n".
  171. "}\n".
  172. "if( pos >= 0 ) {\n".
  173. "document.forms[i-1].elements[pos].focus();\n".
  174. "}\n".
  175. "}\n";
  176. $js .= "// -->\n".
  177. "</script>\n";
  178. $onload = "onLoad=\"checkForm();\"";
  179. displayHtmlHeader (_("Compose"), $js);
  180. break;
  181. }
  182. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
  183. }
  184. ?>