[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 21 Jun 2002 19:52:13 -0000


sakharuk		Fri Jun 21 15:52:13 2002 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  corrections for printing page - the whole table is divided onto small
  tables (for each raw of the original table)
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.32 loncom/interface/lonprintout.pm:1.33
--- loncom/interface/lonprintout.pm:1.32	Thu Jun 20 13:50:24 2002
+++ loncom/interface/lonprintout.pm	Fri Jun 21 15:52:13 2002
@@ -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 @@
 
     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 @@
 
 	
     }
-#-- 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 @@
     $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 @@
     }
     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