page_header.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. /**
  3. * page_header.php
  4. *
  5. * Copyright (c) 1999-2005 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. * @version $Id$
  11. * @package squirrelmail
  12. */
  13. /** Include required files from SM */
  14. require_once(SM_PATH . 'functions/strings.php');
  15. require_once(SM_PATH . 'functions/html.php');
  16. require_once(SM_PATH . 'functions/imap_mailbox.php');
  17. require_once(SM_PATH . 'functions/global.php');
  18. /**
  19. * Output a SquirrelMail page header, from <!doctype> to </head>
  20. * Always set up the language before calling these functions.
  21. *
  22. * @param string title the page title, default SquirrelMail.
  23. * @param string xtra extra HTML to insert into the header
  24. * @param bool do_hook whether to execute hooks, default true
  25. * @param bool frames generate html frameset doctype (since 1.5.1)
  26. * @return void
  27. */
  28. function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = true, $frames = false ) {
  29. global $squirrelmail_language;
  30. if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
  31. global $base_uri;
  32. }
  33. global $theme_css, $custom_css, $pageheader_sent;
  34. if ($frames) {
  35. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
  36. } else {
  37. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
  38. }
  39. echo "\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .
  40. "<head>\n<meta name=\"robots\" content=\"noindex,nofollow\">\n";
  41. /*
  42. * Add closing / to link and meta elements only after switching to xhtml 1.0 Transitional.
  43. * It is not compatible with html 4.01 Transitional
  44. */
  45. if ( !isset( $custom_css ) || $custom_css == 'none' ) {
  46. if ($theme_css != '') {
  47. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">";
  48. }
  49. } else {
  50. echo '<link rel="stylesheet" type="text/css" href="' .
  51. $base_uri . 'themes/css/'.$custom_css.'">';
  52. }
  53. if ($squirrelmail_language == 'ja_JP') {
  54. /*
  55. * force correct detection of charset, when browser does not follow
  56. * http content-type and tries to detect charset from page content.
  57. * Shooting of browser's creator can't be implemented in php.
  58. * We might get rid of it, if we follow http://www.w3.org/TR/japanese-xml/
  59. * recommendations and switch to unicode.
  60. */
  61. echo "<!-- \xfd\xfe -->\n";
  62. echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
  63. }
  64. if ($do_hook) {
  65. do_hook('generic_header');
  66. }
  67. echo "<title>$title</title>\n$xtra\n";
  68. /* work around IE6's scrollbar bug */
  69. echo <<<ECHO
  70. <style type="text/css">
  71. <!--
  72. /* avoid stupid IE6 bug with frames and scrollbars */
  73. body {
  74. voice-family: "\"}\"";
  75. voice-family: inherit;
  76. width: expression(document.documentElement.clientWidth - 30);
  77. }
  78. -->
  79. </style>
  80. ECHO;
  81. echo "\n</head>\n\n";
  82. /* this is used to check elsewhere whether we should call this function */
  83. $pageheader_sent = TRUE;
  84. }
  85. /**
  86. * Given a path to a SquirrelMail file, return a HTML link to it
  87. *
  88. * @param string path the SquirrelMail file to link to
  89. * @param string text the link text
  90. * @param string target the target frame for this link
  91. */
  92. function makeInternalLink($path, $text, $target='') {
  93. sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
  94. if ($target != '') {
  95. $target = " target=\"$target\"";
  96. }
  97. // This is an inefficient hook and is only used by
  98. // one plugin that still needs to patch this code,
  99. // plus if we are templat-izing SM, visual hooks
  100. // are not needed. However, I am leaving the code
  101. // here just in case we find a good (non-visual?)
  102. // use for the internal_link hook.
  103. //
  104. //$hooktext = do_hook_function('internal_link',$text);
  105. //if ($hooktext != '')
  106. // $text = $hooktext;
  107. return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
  108. }
  109. /**
  110. * Same as makeInternalLink, but echoes it too
  111. */
  112. function displayInternalLink($path, $text, $target='') {
  113. echo makeInternalLink($path, $text, $target);
  114. }
  115. /**
  116. * Outputs a complete SquirrelMail page header, starting with <!doctype> and
  117. * including the default menu bar. Uses displayHtmlHeader and takes
  118. * JavaScript and locale settings into account.
  119. *
  120. * @param array color the array of theme colors
  121. * @param string mailbox the current mailbox name to display
  122. * @param string sHeaderJs javascipt code to be inserted in a script block in the header
  123. * @param string sBodyTagJs js events to be inserted in the body tag
  124. * @return void
  125. */
  126. function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
  127. global $hide_sm_attributions, $frame_top,
  128. $provider_name, $provider_uri, $startMessage,
  129. $javascript_on;
  130. sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
  131. if (!isset($frame_top)) {
  132. $frame_top = '_top';
  133. }
  134. if( $javascript_on || strpos($xtra, 'new_js_autodetect_results.value') ) {
  135. if ($sHeaderJs) {
  136. $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
  137. "\n<!--\n" .
  138. $sJsHeader . "\n\n// -->\n</script>\n";
  139. } else {
  140. $sJsBlock = '';
  141. }
  142. $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
  143. displayHtmlHeader ('SquirrelMail', $sJsBlock);
  144. } else {
  145. /* do not use JavaScript */
  146. displayHtmlHeader ('SquirrelMail');
  147. $sBodyTagJs = '';
  148. }
  149. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
  150. /** Here is the header and wrapping table **/
  151. $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
  152. readShortMailboxName($mailbox, $delimiter)));
  153. if ( $shortBoxName == 'INBOX' ) {
  154. $shortBoxName = _("INBOX");
  155. }
  156. echo "<a name=\"pagetop\"></a>\n"
  157. . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n"
  158. . html_tag( 'tr', '', '', $color[9] ) ."\n"
  159. . html_tag( 'td', '', 'left' ) ."\n";
  160. if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
  161. echo ' ' . _("Current Folder") . ": <b>$shortBoxName&nbsp;</b>\n";
  162. } else {
  163. echo '&nbsp;';
  164. }
  165. echo " </td>\n"
  166. . html_tag( 'td', '', 'right' ) ."<b>\n";
  167. displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
  168. echo "</b></td>\n"
  169. . " </tr>\n"
  170. . html_tag( 'tr', '', '', $color[4] ) ."\n"
  171. . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' )
  172. : html_tag( 'td', '', 'left' ) )
  173. . "\n";
  174. $urlMailbox = urlencode($mailbox);
  175. echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&amp;startMessage='.$startMessage);
  176. echo "&nbsp;&nbsp;\n";
  177. displayInternalLink ('src/addressbook.php', _("Addresses"));
  178. echo "&nbsp;&nbsp;\n";
  179. displayInternalLink ('src/folders.php', _("Folders"));
  180. echo "&nbsp;&nbsp;\n";
  181. displayInternalLink ('src/options.php', _("Options"));
  182. echo "&nbsp;&nbsp;\n";
  183. displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"));
  184. echo "&nbsp;&nbsp;\n";
  185. displayInternalLink ('src/help.php', _("Help"));
  186. echo "&nbsp;&nbsp;\n";
  187. do_hook('menuline');
  188. echo " </td>\n";
  189. if (!$hide_sm_attributions)
  190. {
  191. echo html_tag( 'td', '', 'right' ) ."\n";
  192. if (empty($provider_uri)) {
  193. echo '<a href="about.php">SquirrelMail</a>';
  194. } else {
  195. if (empty($provider_name)) $provider_name= 'SquirrelMail';
  196. echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
  197. }
  198. echo "</td>\n";
  199. }
  200. echo " </tr>\n".
  201. "</table><br />\n\n";
  202. }
  203. /**
  204. * Blatantly copied/truncated/modified from displayPageHeader.
  205. * Outputs a page header specifically for the compose_in_new popup window
  206. *
  207. * @param array color the array of theme colors
  208. * @param string mailbox the current mailbox name to display
  209. * @param string sHeaderJs javascipt code to be inserted in a script block in the header
  210. * @param string sBodyTagJs js events to be inserted in the body tag
  211. * @return void
  212. */
  213. function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = 'onload="checkForm();"') {
  214. global $javascript_on;
  215. /*
  216. * Locate the first displayable form element (only when JavaScript on)
  217. */
  218. if($javascript_on) {
  219. if ($sHeaderJs) {
  220. $sJsBlock = "\n<script language=\"JavaScript\" type=\"text/javascript\">" .
  221. "\n<!--\n" .
  222. $sJsHeader . "\n\n// -->\n</script>\n";
  223. } else {
  224. $sJsBlock = '';
  225. }
  226. $sJsBlock .= "\n" . '<script src="'. SM_PATH .'templates/default/js/default.js" type="text/javascript" language="JavaScript"></script>' ."\n";
  227. displayHtmlHeader (_("Compose"), $sJsBlock);
  228. } else {
  229. /* javascript off */
  230. displayHtmlHeader(_("Compose"));
  231. $onload = '';
  232. }
  233. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
  234. }
  235. ?>