[LON-CAPA-cvs] cvs: loncom /interface printout.pl

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 13 Feb 2004 21:17:50 -0000


sakharuk		Fri Feb 13 16:17:50 2004 EDT

  Modified files:              
    /loncom/interface	printout.pl 
  Log:
  Changes: 1. Status window from lonhtmlcommon.pm is used now;
           2. Link to original resource (starting point for printing) is added.
  The last change can be temporary until I'll find and implement more reasonable mechanism.
  
  
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.46 loncom/interface/printout.pl:1.47
--- loncom/interface/printout.pl:1.46	Tue Feb 10 19:19:49 2004
+++ loncom/interface/printout.pl	Fri Feb 13 16:17:50 2004
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
 #
-# $Id: printout.pl,v 1.46 2004/02/11 00:19:49 albertel Exp $
+# $Id: printout.pl,v 1.47 2004/02/13 21:17:50 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,8 @@
 use File::Path;
 use IO::File;
 use Image::Magick;
+use Apache::lonhtmlcommon;
+
 
 my %origENV=%ENV;
 if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
@@ -62,6 +64,7 @@
   my $back_ref = $ENV{'cgi.'.$identifier.'backref'};
   my $number_of_files = $ENV{'cgi.'.$identifier.'numberoffiles'}+1;
   my $student_names = $ENV{'cgi.'.$identifier.'studentnames'};
+  my $backref = $ENV{'cgi.'.$identifier.'backref'};
 
   my @names_pack=();
   if ($student_names=~/_END_/) {  
@@ -81,11 +84,11 @@
       my @content_of_file = <$temporary_file>;
       close $temporary_file;  
       my $noteps;
-      &Create_StatWin ('Starting eps pictures creation', 'Pictires Status window');
+      my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Pictures CreationPrint Status','Pictires Status window',$#content_of_file);
       foreach $not_eps (@content_of_file) {
 	  if ($not_eps ne '') {
               my $status_statement='EPS picture for '.$not_eps;
-	      &Update_StaWin ($status_statement);
+	      &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'last PDF file '.$not_eps); 
 	      $not_eps=~s|\/\.\/|\/|g;
 	      my $eps_f = $not_eps;
 	      $eps_f =~ s/\.[^.]*$/\.eps/i;
@@ -122,7 +125,7 @@
 	      }  
 	  }
       }
-      &Close_StatWin();
+      &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state);
   }
   #print "$texfile\n"; #name of the tex file for debugging only   
   my @texfile=($texfile);
@@ -134,9 +137,9 @@
       } 
   }
 my $ind=-1;
-&Create_StatWin ('Starting PDF production for students', 'PDF Status window');
+my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Print Status','Class Print Status',$number_of_files);
 foreach $texfile (@texfile) {
-  my $final_statement="<b>Link to your PDF document:</b> ";
+  my $final_statement="<a href=\"$backref\"><b>Back to where you started</b></a><br /><br /><b>Link to your PDF document:</b> ";
   my $status_statement='PDF document for ';
   if ($number_of_files>1) {
       $ind++;
@@ -150,7 +153,7 @@
 	  $status_statement.=' -  '.$tempo_array[3];
       } 
   }
-&Update_StaWin ($status_statement);
+&Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'last PDF file '.$status_statement); 
   if (-e $texfile) {
       $texfile =~ m/^(.*)\/([^\/]+)$/; 
       my $name_file = $2;
@@ -338,34 +341,7 @@
     $zipfile=~s/\/home\/httpd//;
     print "<br /> <a href=\"$zipfile\">Your ZIP file is here</a>";
 }
-&Close_StatWin();
-
-
-sub Create_StatWin {
-    my ($title, $heading)=@_;
-    print('<script>'.
-    "popwin=window.open('','popwin','width=400,height=100');".
-    "popwin.document.writeln('<html><head><title>$title</title></head>".
-	      "<body bgcolor=\"#88DDFF\">".
-              "<h4>$heading</h4>".
-              "<form name=popremain>".
-              '<input type="text" size="55" name="remaining" value="'.
-	      'Starting'.'"></form>'.
-              "</body></html>');".
-    "popwin.document.close();".
-    "</script>");
-}
-
-sub Update_StaWin {
-    my ($info)=@_;
-    print('<script>popwin.document.popremain.remaining.value="'.
-	      $info.'";'.'</script>');
-}
-   
-sub Close_StatWin {
-    print('<script>popwin.window.close()</script>'."\n");
-
-}
+&Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state);