File:  [LON-CAPA] / loncom / interface / lonprintout.pm
Revision 1.3: download - view: text, annotated - select for diffs
Tue Sep 18 14:30:55 2001 UTC (22 years, 8 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
new version

    1: # The LearningOnline Network
    2: # Printout
    3: #
    4: # (Internal Server Error Handler
    5: #
    6: # (Login Screen
    7: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
    8: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
    9: #
   10: # 3/1/1 Gerd Kortemeyer)
   11: #
   12: # 3/1 Gerd Kortemeyer
   13: #
   14: # 9/17 Alex Sakharuk
   15: #
   16: package Apache::lonprintout;
   17: 
   18: use strict;
   19: use Apache::Constants qw(:common);
   20: use Apache::lonxml;
   21: use Apache::lonnet;
   22: use Apache::File;
   23: 
   24: 
   25: 
   26: sub headerform {
   27:     my $r = shift;
   28:     $r->print(<<ENDHEADER);
   29: <html>
   30: <head>
   31: <title>LON-CAPA output for printing</title>
   32: </head>
   33: <body bgcolor="FFFFFF">
   34: <form method="post" enctype="multipart/form-data" action="/adm/printout" name="printform">
   35: <h1>Printout:</h1><br></br>
   36: ENDHEADER
   37: }
   38: 
   39: 
   40: sub menu_for_output {
   41:     my $r = shift;
   42:     $r->print(<<ENDMENUOUT);
   43: <input type="hidden" name="phase" value="two">
   44: <input type="radio" name="choice" value="Standard LaTeX output for current document">  Standard LaTeX output for current document<br></br>
   45: <input type="radio" name="choice" value="Standard LaTeX output for the whole sequence">  Standard LaTeX output for the whole sequence<br></br>
   46: <input type="submit" value="Please make a choice">
   47: </form>
   48: </body>
   49: </html>
   50: ENDMENUOUT
   51: }
   52: 
   53: 
   54: sub output_data {
   55:     my $r = shift;
   56:     $r->print(<<ENDPART);
   57: <html>
   58: <head>
   59: <title>LON-CAPA output for printing</title>
   60: </head>
   61: <body bgcolor="FFFFFF">
   62: <hr>
   63: ENDPART
   64: 
   65:     my $choice = $ENV{'form.choice'};
   66:     my $result = '';
   67:     my %mystyle;
   68: 
   69:     if ($choice eq 'Standard LaTeX output for current document') {
   70: 
   71: 	my $file=&Apache::lonnet::filelocation("",'/res/'.$ENV{'request.ambiguous'});
   72: 	my $filecontents=&Apache::lonnet::getfile($file);
   73: 	$result = &Apache::lonxml::xmlparse('tex',$filecontents,'',%mystyle);
   74: 
   75: 	my $tempo_file;
   76:         my $file = 'temp.tex';
   77: 	unless ($tempo_file = Apache::File->new($file)) {
   78: 	    $r->log_error("Couldn't open $file for output");
   79:             return SERVER_ERROR; 
   80: 	}
   81: 
   82: 	$r->print($result);
   83: 
   84:     } elsif ($choice eq 'Standard LaTeX output for the whole sequence') {
   85: 	my $current_file = '/res/'.$ENV{'request.ambiguous'};
   86:         $current_file =~ s/(\/res\/physnet\/physnet)(\/m\d+)\/(.*)/$1$2$2\.sequence/;
   87: 	my $file=&Apache::lonnet::filelocation("",$current_file);
   88: 	my $filecontents=&Apache::lonnet::getfile($file);
   89: 	$result = &Apache::lonxml::xmlparse('tex',$filecontents,'',%mystyle);
   90: 
   91: 	$result = &content_map($result);
   92: 	$r->print($result);
   93: 
   94: 
   95: 
   96:     }
   97: $r->print(<<FINALEND);
   98: </body>
   99: </html>
  100: FINALEND
  101: }
  102: 
  103: 
  104: sub content_map {
  105: #-- find a list of files to publish
  106:     my $map_string = shift;
  107:   
  108: 
  109: 
  110: 
  111:     return $map_string;
  112: }
  113: 
  114: 
  115: sub handler {
  116: 
  117:     my $r = shift;
  118:     $r->content_type('text/html');
  119:     $r->send_http_header;
  120: 
  121: #-- start form
  122:     &headerform($r);
  123: #-- menu for output
  124:     unless ($ENV{'form.phase'}) {
  125: 	&menu_for_output($r);
  126:     }
  127: #-- core part 
  128:     if ($ENV{'form.phase'} eq 'two') {
  129: 	&output_data($r);
  130:     }
  131:     return OK;
  132: 
  133: } 
  134: 
  135: 1;
  136: __END__

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