Annotation of loncom/interface/lonprintout.pm, revision 1.4
1.1 www 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: #
1.3 sakharuk 14: # 9/17 Alex Sakharuk
15: #
1.1 www 16: package Apache::lonprintout;
17:
18: use strict;
19: use Apache::Constants qw(:common);
1.2 sakharuk 20: use Apache::lonxml;
21: use Apache::lonnet;
1.3 sakharuk 22: use Apache::File;
1.1 www 23:
1.3 sakharuk 24:
25:
26: sub headerform {
1.1 www 27: my $r = shift;
1.3 sakharuk 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:
1.1 www 39:
1.3 sakharuk 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: }
1.2 sakharuk 52:
53:
1.3 sakharuk 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
1.2 sakharuk 64:
1.3 sakharuk 65: my $choice = $ENV{'form.choice'};
1.2 sakharuk 66: my $result = '';
67: my %mystyle;
68:
1.3 sakharuk 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;
1.4 ! sakharuk 76: my $file = '/home/httpd/prtspool/temp.tex';
1.3 sakharuk 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:
1.2 sakharuk 94:
95:
1.3 sakharuk 96: }
97: $r->print(<<FINALEND);
98: </body>
99: </html>
100: FINALEND
101: }
1.2 sakharuk 102:
1.3 sakharuk 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: }
1.2 sakharuk 131: return OK;
132:
1.1 www 133: }
134:
135: 1;
136: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>