page_header.php 7.9 KB

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