Annotation of loncom/interface/lonprintout.pm, revision 1.6
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.5 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.6 ! sakharuk 54:
1.3 sakharuk 55: sub output_data {
56: my $r = shift;
57: $r->print(<<ENDPART);
58: <html>
59: <head>
60: <title>LON-CAPA output for printing</title>
61: </head>
62: <body bgcolor="FFFFFF">
63: <hr>
64: ENDPART
1.2 sakharuk 65:
1.3 sakharuk 66: my $choice = $ENV{'form.choice'};
1.2 sakharuk 67: my $result = '';
68: my %mystyle;
1.6 ! sakharuk 69: my $filename;
1.5 sakharuk 70:
71:
1.3 sakharuk 72: if ($choice eq 'Standard LaTeX output for current document') {
73:
74: my $file=&Apache::lonnet::filelocation("",'/res/'.$ENV{'request.ambiguous'});
75: my $filecontents=&Apache::lonnet::getfile($file);
76: $result = &Apache::lonxml::xmlparse('tex',$filecontents,'',%mystyle);
77:
1.5 sakharuk 78: {
79: my $temp_file;
1.6 ! sakharuk 80: $filename = "/home/httpd/prtspool/$ENV{'environment.firstname'}$ENV{'environment.lastname'}temp$ENV{'user.login.time'}.tex";
1.5 sakharuk 81: unless ($temp_file = Apache::File->new('>'.$filename)) {
82: $r->log_error("Couldn't open $filename for output $!");
83: return SERVER_ERROR;
84: }
85: print $temp_file $result;
1.3 sakharuk 86: }
87:
1.6 ! sakharuk 88:
1.5 sakharuk 89:
1.3 sakharuk 90:
91: } elsif ($choice eq 'Standard LaTeX output for the whole sequence') {
92: my $current_file = '/res/'.$ENV{'request.ambiguous'};
93: $current_file =~ s/(\/res\/physnet\/physnet)(\/m\d+)\/(.*)/$1$2$2\.sequence/;
94: my $file=&Apache::lonnet::filelocation("",$current_file);
95: my $filecontents=&Apache::lonnet::getfile($file);
96: $result = &Apache::lonxml::xmlparse('tex',$filecontents,'',%mystyle);
97:
1.5 sakharuk 98: my @number_seq = &content_map($result);
99: $r->print(@number_seq);
1.3 sakharuk 100:
1.2 sakharuk 101:
102:
1.6 ! sakharuk 103:
1.3 sakharuk 104: }
1.6 ! sakharuk 105:
! 106:
1.3 sakharuk 107: $r->print(<<FINALEND);
1.6 ! sakharuk 108: <meta http-equiv="Refresh" content="0; url=http://bistromath.lite.msu.edu/cgi-bin/printout.pl?$filename">
1.3 sakharuk 109: </body>
110: </html>
111: FINALEND
112: }
1.2 sakharuk 113:
1.3 sakharuk 114:
1.6 ! sakharuk 115:
! 116:
1.3 sakharuk 117: sub content_map {
118: #-- find a list of files to publish
119: my $map_string = shift;
120:
1.5 sakharuk 121: my @number_seq = ();
122: my $startlink = index($map_string,'<link',0);
123: while ($startlink != -1) {
124: my $endlink = index($map_string,'</link>',$startlink);
125: my $chunk = substr($map_string,$startlink,$endlink-$startlink+7);
126: substr($map_string,$startlink,$endlink-$startlink+7) = '';
127: $_ = $chunk;
128: m/from=\"(\d+)\"/;
129: push @number_seq,$1;
130: m/to=\"(\d+)\"/;
131: push @number_seq,$1;
132: $startlink = index($map_string,'<link from="'.$1.'"',$startlink);
133: }
134:
135: return @number_seq;
136:
137:
138: # my @one = ();
139: # my @two = ();
140: # my @three = ();
141: # my $start = index($map_string,'<link',0);
142: # while ($start != -1) {
143: # my $finish = index($map_string,'</link>',$start);
144: # my $chunk = substr($map_string,$start,$finish-$start+7);
145: # substr($map_string,$start,$finish-$start+7) = '';
146: # $_ = $chunk;
147: # m/from=\"(\d+)\"/;
148: # push @one,$1;
149: # m/to=\"(\d+)\"/;
150: # push @two,$1;
151: # $start = index($map_string,'<link',$start);
152: # }
1.3 sakharuk 153:
154:
1.5 sakharuk 155: # return @three;
156: # return $map_string;
1.3 sakharuk 157: }
158:
159:
160: sub handler {
161:
162: my $r = shift;
163: $r->content_type('text/html');
164: $r->send_http_header;
165:
166: #-- start form
167: &headerform($r);
168: #-- menu for output
169: unless ($ENV{'form.phase'}) {
170: &menu_for_output($r);
171: }
172: #-- core part
173: if ($ENV{'form.phase'} eq 'two') {
174: &output_data($r);
1.6 ! sakharuk 175:
1.3 sakharuk 176: }
1.2 sakharuk 177: return OK;
178:
1.1 www 179: }
180:
181: 1;
182: __END__
1.6 ! sakharuk 183:
! 184:
! 185: # my $ere;
! 186: # foreach $ere (%ENV) {
! 187: # $r->print(' SS '.$ere.' => '.$ENV{$ere}.' FF '."\n\n");
! 188: # }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>