Diff for /loncom/interface/lonhelp.pm between versions 1.3 and 1.11

version 1.3, 2002/07/26 19:58:52 version 1.11, 2003/09/22 18:35:46
Line 31  package Apache::lonhelp; Line 31  package Apache::lonhelp;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::File;  use Apache::File();
 use Apache::loncommon;  use Apache::loncommon();
 use tth;  use Apache::lonacc();
 use GDBM_File;  use Apache::lontexconvert();
   use Apache::lonnavmaps; # for advancedUser
   use Apache::lonlocal;
   use tth();
   use GDBM_File();
   
 # This sub takes the name of a label in, and converts it to something  # This sub takes the name of a label in, and converts it to something
 # that is a valid anchor name.  # that is a valid anchor name.
Line 56  $r->print(<<HEADER); Line 60  $r->print(<<HEADER);
         <title>LON-CAPA Help</title>          <title>LON-CAPA Help</title>
     </head>      </head>
     <body bgcolor="#FFFFFF">      <body bgcolor="#FFFFFF">
       <h3 style="font: sans-serif"><img align="right"
       src="/adm/help/gif/lonhelpheader.gif"/>LON-CAPA Help<hr /></h3>
     <!-- BEGIN -->      <!-- BEGIN -->
 HEADER  HEADER
   
     $r->print($tex);      $r->print($tex);
   
       if (Apache::lonnavmaps::advancedUser()) {
 $r->print(<<FOOTER);  $r->print(<<FOOTER);
     <!-- END -->      <!-- END -->
       <hr />
       <center><font size="-1"><a href="/adm/help/abouthelp.html">About
       LON-CAPA help and More Help</a></font></center>
     </body>      </body>
 </html>  </html>
 FOOTER  FOOTER
   } else {
       $r->print(<<FOOTER);
       <!-- END -->
       </body>
   </html>
   FOOTER
   }
 }  }
   
 # Render takes a tex fragment, transforms it for TtH, and returns the  # Render takes a tex fragment, transforms it for TtH, and returns the
Line 99  sub render Line 116  sub render
                 ' bordercolor="#000000"/>\\end{html}'                  ' bordercolor="#000000"/>\\end{html}'
              |gxe;               |gxe;
   
     $tex = tth::tth($tex);  
   
       $tex=&Apache::lontexconvert::converted(\$tex);
       
     # Finish backslashes      # Finish backslashes
     $tex =~ s/###BACKSLASH###/'\\'/ge;      $tex =~ s/###BACKSLASH###/'\\'/ge;
     
Line 111  sub render Line 129  sub render
     # just duck the issue...      # just duck the issue...
   
     $tex =~ s/Figure 0://g;      $tex =~ s/Figure 0://g;
        $tex.=$Apache::lontexconvert::errorstring;
     untie %fragmentLabels;      untie %fragmentLabels;
   
     return $tex;      return $tex;
Line 124  sub handler Line 142  sub handler
      my $docroot = $r->dir_config('lonDocRoot');       my $docroot = $r->dir_config('lonDocRoot');
      my $serverroot = $ENV{'HTTP_HOST'};       my $serverroot = $ENV{'HTTP_HOST'};
   
      my $filename = substr ($ENV{'REQUEST_URI'} ,        my $filenames = substr ($ENV{'REQUEST_URI'} , 
     rindex($ENV{'REQUEST_URI'}, '/') + 1, -4);      rindex($ENV{'REQUEST_URI'}, '/') + 1, -4);
             
      # Security check on the file; the whole filename must consist       # Security check on the file; the whole filename must consist
      # of nothing but alphanums, ' ,, or ., or the file       # of nothing but alphanums, ' ,, or ., or the file
      # will be "not found", no matter what.       # will be "not found", no matter what.
             
      return 404 if ($filename !~ /\A[-0-9a-zA-z_'',.]+\Z/);       return HTTP_NOT_FOUND if ($filenames !~ /\A[-0-9a-zA-z_'',:.]+\Z/);
   
        &Apache::lonlocal::get_language_handle($r);
   
        # Join together the tex files, return HTTP_NOT_FOUND if any of
        # them are not found
        my $tex = '';
        # Since in insertlist.tab I want to specify multiple files,
        # and insertlist.tab also uses commas, I need something else
        # so replace : with ,
        $filenames =~ s/:/,/g;
        my @files = split(/,/, $filenames);
        
        for my $filename (@files) {
    if (-e $docroot.'/adm/help/tex/'.
        &Apache::lonlocal::current_language().'/'.
        $filename.'.tex') {
        $filename=&Apache::lonlocal::current_language().'/'.$filename;
    }
    (my $file = Apache::File->new($docroot
      . '/adm/help/tex/'.$filename.'.tex'))
        or return HTTP_NOT_FOUND;
    $tex .= join('', <$file>);
        }
   
        # get me my environment if it exists
        &Apache::lonacc::handler($r);
   
        if ($ENV{'browser.mathml'}) {
    &Apache::loncommon::content_type($r,'text/xml');
    &tth::ttminit();
    if ($ENV{'browser.unicode'}) {
        &tth::ttmoptions('-L -u1');
    } else {
        &tth::ttmoptions('-L -u0');
    }
        } else {
    &Apache::loncommon::content_type($r,"text/html");
    &tth::tthinit();
    if ($ENV{'browser.unicode'}) {
        &tth::tthoptions('-L -u1');
    } else {
        &tth::tthoptions('-L -u0');
    }
        }
   
      (my $file = Apache::File->new($docroot . "/adm/help/tex/".$filename.'.tex'))  
  or return 404;  
      my $tex = join('', <$file>);  
      $tex = render($tex, $docroot, $serverroot);       $tex = render($tex, $docroot, $serverroot);
      $r->content_type("text/html");  
      serveTex($tex, $r);       serveTex($tex, $r);
   
      return OK;       return OK;

Removed from v.1.3  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>