--- loncom/interface/lonprintout.pm 2002/06/20 17:50:24 1.32 +++ loncom/interface/lonprintout.pm 2002/06/21 19:52:13 1.33 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.32 2002/06/20 17:50:24 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.33 2002/06/21 19:52:13 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -110,25 +110,19 @@ ENDPART my $choice = $ENV{'form.choice'}; my $layout = $ENV{'form.layout'}; - my $subdirtoprint = $ENV{'form.subdirect'}; my $laystyle = 'book'; my $result = ''; - my %mystyle; - my $filename; if ($choice eq 'Standard LaTeX output for current document') { my %moreenv; - my $currequest=$ENV{'request.filename'}; $moreenv{'form.grade_target'}='tex'; $moreenv{'request.filename'}=$ENV{'form.url'}; &Apache::lonnet::appenv(%moreenv); my $texversion=&Apache::lonnet::ssi($ENV{'form.url'}); &Apache::lonnet::delenv('form.grade_target'); - %moreenv = (); - $moreenv{'request.filename'}=$currequest; - &Apache::lonnet::appenv(%moreenv); $result .= $texversion; $result = &additional_cleanup($result); + if ($ENV{'form.url'}=~m/\.page\s*$/) {$result = &page_cleanup($result);} } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or $choice eq 'Standard LaTeX output for whole primary sequence') { #-- where is the primary sequence containing file? my %moreenv; @@ -236,14 +230,6 @@ ENDPART } -#-- corrections for page layout - $result =~ s/&\s*REMOVE\\\\/\\\\/g; - $_ = $result; - m/\\end{document}(\d*)$/; - my $insert = '{'; - for (my $id=1;$id<=$1;$id++) { $insert .='l'; } - $insert .= '}'; - $result =~ s/(\\begin{tabular})INSERT/$1$insert/g; #-- corrections for the different page formats if ($layout eq 'CBI') { $result =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{-40pt}\\setlength{\\evensidemargin}{-60pt}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{4\.4in}\\setlength{\\textheight}{6\.8in}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt} \\begin{document}/; @@ -277,7 +263,7 @@ ENDPART $result =~ s/\b_+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g; #-- writing .tex file in prtspool my $temp_file; - $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex"; + my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex"; unless ($temp_file = Apache::File->new('>'.$filename)) { $r->log_error("Couldn't open $filename for output $!"); return SERVER_ERROR; @@ -302,7 +288,17 @@ sub additional_cleanup { } return $result; } - +sub page_cleanup { + my $result = shift; + $_ = $result; + m/\\end{document}(\d*)$/; + my $insert = '{'; + for (my $id=1;$id<=$1;$id++) { $insert .='l'; } + $insert .= '}'; + $result =~ s/(\\begin{tabular})INSERT/$1$insert/g; + $result =~ s/&\s*REMOVE\\\\/\\end{tabular}\\\\\\begin{tabular}$insert/g; + return $result; +} sub content_map { #-- find a list of files to print