page_header.php 7.4 KB

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