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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 14 Aug 2006 10:52:10 -0000


foxr		Mon Aug 14 06:52:10 2006 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Get printing of current resource working when browsing /res  part of
  bug 4039
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.477 loncom/interface/lonprintout.pm:1.478
--- loncom/interface/lonprintout.pm:1.477	Tue Aug  8 13:32:02 2006
+++ loncom/interface/lonprintout.pm	Mon Aug 14 06:52:04 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.477 2006/08/08 17:32:02 albertel Exp $
+# $Id: lonprintout.pm,v 1.478 2006/08/14 10:52:04 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1110,7 +1110,10 @@
 		$answerform{'answer_output_mode'}='tex';
 		$answerform{'rndseed'}=$rndseed;
 		$answerform{'problem_split'}=$parmhash{'problem_stream_switch'};
-		if ($urlp=~/\/res\//) {$env{'request.state'}='published';}
+		if ($urlp=~/\/res\//) {
+		    $env{'request.state'}='published';
+		}
+
 		$resources_printed .= $urlp.':';
 		my $answer=&Apache::lonnet::ssi($urlp,%answerform);
 		if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
@@ -1198,6 +1201,8 @@
     my $start_page  = &Apache::loncommon::start_page('Preparing Printout',$js);
     my $msg = &mt('Please stand by while processing your print request, this may take some time ...');
 
+
+
     $r->print($start_page."\n<p>\n$msg\n</p>\n");
 
     # fetch the pagebreaks and store them in the course environment
@@ -1249,6 +1254,7 @@
     }
 
     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
+	
       #-- single document - problem, page, html, xml, ...
 	my ($currentURL,$cleanURL);
 
@@ -2156,7 +2162,7 @@
     if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {
         $helper->{VARS}->{'filename'} = "~$1/$2";
         $helper->{VARS}->{'construction'} = 1;
-    } else {
+    } elsif ($env{'form.postdata'}) {
         if ($env{'form.postdata'}) {
             $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
         }
@@ -2168,7 +2174,6 @@
         }
 
     }
-
     if ($env{'form.symb'}) {
         $helper->{VARS}->{'symb'} = $env{'form.symb'};
     }
@@ -2180,7 +2185,6 @@
 	&Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'});
     my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper);
     if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;}
-
     
     # Extract map
     my $symb = $helper->{VARS}->{'symb'};
@@ -2188,16 +2192,19 @@
     my $subdir;
 
     # Get the resource name from construction space
+
     if ($helper->{VARS}->{'construction'}) {
         $resourceTitle = substr($helper->{VARS}->{'filename'}, 
                                 rindex($helper->{VARS}->{'filename'}, '/')+1);
         $subdir = substr($helper->{VARS}->{'filename'},
                          0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
-    } else {
+    } elsif ($env{'form.postdata'} =~ /^\/res\//) { # Get resource name from res space.
+	$helper->{VARS}->{'postdata'} = $env{'form.postdata'};
+
+    } elsif (!$helper->{VARS}->{'postdata'}) {
         ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
         $helper->{VARS}->{'postdata'} = 
 	    &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
-
         if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
             my $postdata = $helper->{VARS}->{'postdata'};
             $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);