Source for file page_header.php

Documentation is available at page_header.php

  1. <?php
  2.  
  3. /**
  4.  * page_header.php
  5.  *
  6.  * Prints the page header (duh)
  7.  *
  8.  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: page_header.php,v 1.148.2.27 2006/06/14 14:25:41 indiri69 Exp $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** Include required files from SM */
  15. require_once(SM_PATH 'functions/strings.php');
  16. require_once(SM_PATH 'functions/html.php');
  17. require_once(SM_PATH 'functions/imap_mailbox.php');
  18. require_once(SM_PATH 'functions/global.php');
  19.  
  20. /* Always set up the language before calling these functions */
  21. function displayHtmlHeader$title 'SquirrelMail'$xtra ''$do_hook TRUE {
  22.     global $squirrelmail_language;
  23.  
  24.     if !sqgetGlobalVar('base_uri'$base_uriSQ_SESSION) ) {
  25.         global $base_uri;
  26.     }
  27.     global $theme_css$custom_css$pageheader_sent;
  28.  
  29.     echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
  30.          "\n\n" html_tag'html' ,'' '''''' "\n<head>\n" .
  31.          "<meta name=\"robots\" content=\"noindex,nofollow\">\n";
  32.  
  33.     if !isset$custom_css || $custom_css == 'none' {
  34.         if ($theme_css != ''{
  35.             echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
  36.         }
  37.     else {
  38.         echo '<link rel="stylesheet" type="text/css" href="' .
  39.              $base_uri 'themes/css/'.$custom_css.'" />';
  40.     }
  41.  
  42.     if ($squirrelmail_language == 'ja_JP'{
  43.         // Why is it added here? Header ('Content-Type:..) is used in i18n.php
  44.         echo "<!-- \xfd\xfe -->\n";
  45.         echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' "\n";
  46.     }
  47.  
  48.     if ($do_hook{
  49.         do_hook('generic_header');
  50.     }
  51.  
  52.     echo "\n<title>$title</title>$xtra\n";
  53.  
  54.     /* work around IE6's scrollbar bug */
  55.     echo <<<ECHO
  56. <!--[if IE 6]>
  57. <style type="text/css">
  58. /* avoid stupid IE6 bug with frames and scrollbars */
  59. body {
  60.     widthexpression(document.documentElement.clientWidth - 30);
  61. }
  62. </style>
  63. <![endif]-->
  64.  
  65. ECHO;
  66.  
  67.     echo "\n</head>\n\n";
  68.  
  69.     /* this is used to check elsewhere whether we should call this function */
  70.     $pageheader_sent TRUE;
  71. }
  72.  
  73. function makeInternalLink($path$text$target=''{
  74.     sqgetGlobalVar('base_uri'$base_uriSQ_SESSION);
  75.     if ($target != ''{
  76.         $target " target=\"$target\"";
  77.     }
  78.     return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
  79. }
  80.  
  81. function displayInternalLink($path$text$target=''{
  82.     echo makeInternalLink($path$text$target);
  83. }
  84.  
  85. function displayPageHeader($color$mailbox$xtra=''$session=false{
  86.  
  87.     global $hide_sm_attributions$PHP_SELF$frame_top,
  88.            $compose_new_win$compose_width$compose_height,
  89.            $attachemessages$provider_name$provider_uri,
  90.            $javascript_on$default_use_mdn$mdn_user_support,
  91.            $startMessage;
  92.  
  93.     sqgetGlobalVar('base_uri'$base_uriSQ_SESSION );
  94.     sqgetGlobalVar('delimiter'$delimiterSQ_SESSION );
  95.     $module substr$PHP_SELFstrlen$PHP_SELF strlen$base_uri ) ) * -);
  96.     if ($qmark strpos($module'?')) {
  97.         $module substr($module0$qmark);
  98.     }
  99.     if (!isset($frame_top)) {
  100.         $frame_top '_top';
  101.     }
  102.  
  103.     if ($session{
  104.         $compose_uri $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
  105.     else {
  106.         $compose_uri $base_uri.'src/compose.php?newmessage=1';
  107.         $session 0;
  108.     }
  109.  
  110.     // only output JavaScript if actually turned on
  111.     if($javascript_on || strpos($xtra'new_js_autodetect_results.value') ) {
  112.         switch $module {
  113.         case 'src/read_body.php':
  114.             $js ='';
  115.  
  116.             // compose in new window code
  117.             if ($compose_new_win == '1'{
  118.                 if (!preg_match("/^[0-9]{3,4}$/"$compose_width)) {
  119.                     $compose_width '640';
  120.                 }
  121.                 if (!preg_match("/^[0-9]{3,4}$/"$compose_height)) {
  122.                     $compose_height '550';
  123.                 }
  124.                 $js .= "function comp_in_new(comp_uri) {\n".
  125.                      "       if (!comp_uri) {\n".
  126.                      '           comp_uri = "'.$compose_uri."\";\n".
  127.                      '       }'"\n".
  128.                      '    var newwin = window.open(comp_uri' .
  129.                      ', "_blank",'.
  130.                      '"width='.$compose_width',height='.$compose_height.
  131.                      ',scrollbars=yes,resizable=yes,status=yes");'."\n".
  132.                      "}\n\n";
  133.             }
  134.  
  135.             // javascript for sending read receipts
  136.             if($default_use_mdn && $mdn_user_support{
  137.                 $js .= "function sendMDN() {\n".
  138.                          "    mdnuri=window.location+'&sendreceipt=1';\n" .
  139.                          "    if (window.top != window.self) {\n" .
  140.                          "      var newwin = window.open(mdnuri,'right');\n" .
  141.                          "    } else {\n " .
  142.                          "      var newwin = window.location = mdnuri;\n" .
  143.                          "    }\n" .
  144.                        "\n}\n\n";
  145.             }
  146.  
  147.             // if any of the above passes, add the JS tags too.
  148.             if($js{
  149.                 $js "\n".'<script language="JavaScript" type="text/javascript">' .
  150.                       "\n<!--\n" $js "// -->\n</script>\n";
  151.             }
  152.  
  153.             displayHtmlHeader ('SquirrelMail'$js);
  154.             $onload $xtra;
  155.           break;
  156.         case 'src/compose.php':
  157.             $js '<script language="JavaScript" type="text/javascript">' .
  158.              "\n<!--\n" .
  159.              "var alreadyFocused = false;\n" .
  160.              "function checkForm() {\n" .
  161.              "\n    if (alreadyFocused) return;\n";
  162.  
  163.             global $action$reply_focus;
  164.             if (strpos($action'reply'!== FALSE && $reply_focus)
  165.             {
  166.                 if ($reply_focus == 'select'$js .= "document.forms['compose'].body.select();}\n";
  167.                 else if ($reply_focus == 'focus'$js .= "document.forms['compose'].body.focus();}\n";
  168.                 else if ($reply_focus == 'none'$js .= "}\n";
  169.             }
  170.             // no reply focus also applies to composing new messages
  171.             else if ($reply_focus == 'none')
  172.             {
  173.                 $js .= "}\n";
  174.             }
  175.             else
  176.                 $js .= "    var f = document.forms.length;\n".
  177.                 "    var i = 0;\n".
  178.                 "    var pos = -1;\n".
  179.                 "    while( pos == -1 && i < f ) {\n".
  180.                 "        var e = document.forms[i].elements.length;\n".
  181.                 "        var j = 0;\n".
  182.                 "        while( pos == -1 && j < e ) {\n".
  183.                 "            if ( document.forms[i].elements[j].type == 'text' ) {\n".
  184.                 "                pos = j;\n".
  185.                 "            }\n".
  186.                 "            j++;\n".
  187.                 "        }\n".
  188.                 "        i++;\n".
  189.                 "    }\n".
  190.                 "    if( pos >= 0 ) {\n".
  191.                 "        document.forms[i-1].elements[pos].focus();\n".
  192.                 "    }\n".
  193.                 "}\n";
  194.  
  195.             $js .= "// -->\n".
  196.                  "</script>\n";
  197.             $onload 'onload="checkForm();"';
  198.             displayHtmlHeader ('SquirrelMail'$js);
  199.             break;
  200.  
  201.         default:
  202.             $js '<script language="JavaScript" type="text/javascript">' .
  203.              "\n<!--\n" .
  204.              "function checkForm() {\n".
  205.              "   var f = document.forms.length;\n".
  206.              "   var i = 0;\n".
  207.              "   var pos = -1;\n".
  208.              "   while( pos == -1 && i < f ) {\n".
  209.              "       var e = document.forms[i].elements.length;\n".
  210.              "       var j = 0;\n".
  211.              "       while( pos == -1 && j < e ) {\n".
  212.              "           if ( document.forms[i].elements[j].type == 'text' " .
  213.              "           || document.forms[i].elements[j].type == 'password' ) {\n".
  214.              "               pos = j;\n".
  215.              "           }\n".
  216.              "           j++;\n".
  217.              "       }\n".
  218.              "   i++;\n".
  219.              "   }\n".
  220.              "   if( pos >= 0 ) {\n".
  221.              "       document.forms[i-1].elements[pos].focus();\n".
  222.              "   }\n".
  223.              "   $xtra\n".
  224.              "}\n";
  225.  
  226.             if ($compose_new_win == '1'{
  227.                 if (!preg_match("/^[0-9]{3,4}$/"$compose_width)) {
  228.                     $compose_width '640';
  229.                 }
  230.                 if (!preg_match("/^[0-9]{3,4}$/"$compose_height)) {
  231.                     $compose_height '550';
  232.                 }
  233.                 $js .= "function comp_in_new(comp_uri) {\n".
  234.                      "       if (!comp_uri) {\n".
  235.                      '           comp_uri = "'.$compose_uri."\";\n".
  236.                      '       }'"\n".
  237.                      '    var newwin = window.open(comp_uri' .
  238.                      ', "_blank",'.
  239.                      '"width='.$compose_width',height='.$compose_height.
  240.                      ',scrollbars=yes,resizable=yes,status=yes");'."\n".
  241.                      "}\n\n";
  242.  
  243.             }
  244.         $js .= "// -->\n""</script>\n";
  245.  
  246.  
  247.         $onload 'onload="checkForm();"';
  248.         displayHtmlHeader ('SquirrelMail'$js);
  249.       // end switch module
  250.     else {
  251.         // JavaScript off
  252.         displayHtmlHeader ('SquirrelMail');
  253.         $onload '';
  254.     }
  255.  
  256.     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
  257.     /** Here is the header and wrapping table **/
  258.     $shortBoxName htmlspecialchars(imap_utf7_decode_local(
  259.                       readShortMailboxName($mailbox$delimiter)));
  260.     if $shortBoxName == 'INBOX' {
  261.         $shortBoxName _("INBOX");
  262.     }
  263.     echo "<a name=\"pagetop\"></a>\n"
  264.         . html_tag'table'''''$color[4]'border="0" width="100%" cellspacing="0" cellpadding="2"' ."\n"
  265.         . html_tag'tr'''''$color[9."\n"
  266.         . html_tag'td''''left' ."\n";
  267.     if $shortBoxName <> '' && strtolower$shortBoxName <> 'none' {
  268.         echo '         ' _("Current Folder"": <b>$shortBoxName&nbsp;</b>\n";
  269.     else {
  270.         echo '&nbsp;';
  271.     }
  272.     echo  "      </td>\n"
  273.         . html_tag'td''''right' ."<b>\n";
  274.     displayInternalLink ('src/signout.php'_("Sign Out")$frame_top);
  275.     echo "</b></td>\n"
  276.         . "   </tr>\n"
  277.         . html_tag'tr'''''$color[4."\n"
  278.         . ($hide_sm_attributions html_tag'td''''left''''colspan="2"' )
  279.                                  : html_tag'td''''left' ) )
  280.         . "\n";
  281.     $urlMailbox urlencode($mailbox);
  282.     $startMessage = (int)$startMessage;
  283.     echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&amp;startMessage='.$startMessage);
  284.     echo "&nbsp;&nbsp;\n";
  285.     displayInternalLink ('src/addressbook.php'_("Addresses"));
  286.     echo "&nbsp;&nbsp;\n";
  287.     displayInternalLink ('src/folders.php'_("Folders"));
  288.     echo "&nbsp;&nbsp;\n";
  289.     displayInternalLink ('src/options.php'_("Options"));
  290.     echo "&nbsp;&nbsp;\n";
  291.     displayInternalLink ("src/search.php?mailbox=$urlMailbox"_("Search"));
  292.     echo "&nbsp;&nbsp;\n";
  293.     displayInternalLink ('src/help.php'_("Help"));
  294.     echo "&nbsp;&nbsp;\n";
  295.  
  296.     do_hook('menuline');
  297.  
  298.     echo "      </td>\n";
  299.  
  300.     if (!$hide_sm_attributions)
  301.     {
  302.         echo html_tag'td''''right' ."\n";
  303.         if (!isset($provider_uri)) $provider_uri'http://www.squirrelmail.org/';
  304.         if (!isset($provider_name)) $provider_name'SquirrelMail';
  305.         echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
  306.         echo "</td>\n";
  307.     }
  308.     echo "   </tr>\n".
  309.         "</table><br>\n\n";
  310. }
  311.  
  312. /* blatently copied/truncated/modified from the above function */
  313. function compose_Header($color$mailbox{
  314.  
  315.     global $delimiter$hide_sm_attributions$base_uri$PHP_SELF,
  316.            $data_dir$username$frame_top$compose_new_win;
  317.  
  318.  
  319.     $module substr$PHP_SELFstrlen$PHP_SELF strlen$base_uri ) ) * -);
  320.     if (!isset($frame_top)) {
  321.         $frame_top '_top';
  322.     }
  323.  
  324.     /*
  325.         Locate the first displayable form element
  326.     */
  327.     switch $module {
  328.     case 'src/search.php':
  329.         $pos getPref($data_dir$username'search_pos'1;
  330.         $onload "onload=\"document.forms[$pos].elements[2].focus();\"";
  331.         displayHtmlHeader (_("Compose"));
  332.         break;
  333.     default:
  334.         $js '<script language="JavaScript" type="text/javascript">' .
  335.              "\n<!--\n" .
  336.              "var alreadyFocused = false;\n" .
  337.              "function checkForm() {\n" .
  338.              "\n    if (alreadyFocused) return;\n";
  339.  
  340.             global $action$reply_focus;
  341.             if (strpos($action'reply'!== FALSE && $reply_focus)
  342.             {
  343.                 if ($reply_focus == 'select'$js .= "document.forms['compose'].body.select();}\n";
  344.                 else if ($reply_focus == 'focus'$js .= "document.forms['compose'].body.focus();}\n";
  345.                 else if ($reply_focus == 'none'$js .= "}\n";
  346.             }
  347.             // no reply focus also applies to composing new messages
  348.             else if ($reply_focus == 'none')
  349.             {
  350.                 $js .= "}\n";
  351.             }
  352.             else
  353.                 $js .= "var f = document.forms.length;\n".
  354.                 "var i = 0;\n".
  355.                 "var pos = -1;\n".
  356.                 "while( pos == -1 && i < f ) {\n".
  357.                     "var e = document.forms[i].elements.length;\n".
  358.                     "var j = 0;\n".
  359.                     "while( pos == -1 && j < e ) {\n".
  360.                         "if ( document.forms[i].elements[j].type == 'text' ) {\n".
  361.                             "pos = j;\n".
  362.                         "}\n".
  363.                         "j++;\n".
  364.                     "}\n".
  365.                 "i++;\n".
  366.                 "}\n".
  367.                 "if( pos >= 0 ) {\n".
  368.                     "document.forms[i-1].elements[pos].focus();\n".
  369.                 "}\n".
  370.             "}\n";
  371.         $js .= "// -->\n".
  372.                  "</script>\n";
  373.         $onload 'onload="checkForm();"';
  374.         displayHtmlHeader (_("Compose")$js);
  375.         break;
  376.  
  377.     }
  378.  
  379.     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
  380. }
  381.  
  382. ?>

Documentation generated on Sat, 07 Oct 2006 16:33:00 +0300 by phpDocumentor 1.3.0RC6