--- loncom/interface/lonprintout.pm 2003/05/06 20:50:04 1.155 +++ loncom/interface/lonprintout.pm 2003/05/07 19:00:56 1.156 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.155 2003/05/06 20:50:04 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.156 2003/05/07 19:00:56 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1689,14 +1689,28 @@ sub printHelper { my $helper = Apache::lonhelper::helper->new("Printing Wizard"); $helper->declareVar('symb'); - $helper->declareVar('postdata'); + $helper->declareVar('postdata'); + $helper->declareVar('filename'); + $helper->declareVar('construction'); # This will persistently load in the data we want from the # very first screen. - if ($ENV{'form.postdata'}) { - if ($ENV{'form.postdata'}!~/\/res\//) {$helper->{VARS}->{'construction'} = $ENV{'form.postdata'};} - $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'}); - } + # Detect whether we're coming from construction space + if ($ENV{'form.postdata'} =~ /http:\/\// ) { + $ENV{'form.postdata'} =~ /http:\/\/[a-zA-Z.]+\/~([a-zA-Z0-9]+)\/(.*)/; + $helper->{VARS}->{'filename'} = "/home/$1/public_html/$2"; + $helper->{VARS}->{'construction'} = 1; + } else { + if ($ENV{'form.postdata'}) { + $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'}); + } + if ($ENV{'form.symb'}) { + $helper->{VARS}->{'symb'} = $ENV{'form.symb'}; + } + if ($ENV{'form.url'}) { + $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); + } + if ($ENV{'form.symb'}) { $helper->{VARS}->{'symb'} = $ENV{'form.symb'}; } @@ -1704,25 +1718,35 @@ sub printHelper { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); } - my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu; $helper->{VARS}->{'assignment'} = $sequenceTitle; + # Extract map my $symb = $helper->{VARS}->{'symb'}; - my ($map, $id, $url) = split(/___/, $symb); - $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url); + my ($map, $id, $url); + 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 { + ($map, $id, $url) = split(/___/, $symb); + $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url); - if (!$resourceTitle) { # if the resource doesn't have a title, use the filename - my $url = $helper->{VARS}->{'postdata'}; - $resourceTitle = substr($url, rindex($url, '/') + 1); + if (!$resourceTitle) { # if the resource doesn't have a title, use the filename + my $url = $helper->{VARS}->{'postdata'}; + $resourceTitle = substr($url, rindex($url, '/') + 1); + } + $subdir = &Apache::lonnet::filelocation("", $url); } Apache::lonhelper::registerHelperTags(); - my $subdir = &Apache::lonnet::filelocation("", $url); - # "Delete everything after the last slash." $subdir =~ s|/[^/]+$||; if (not defined $helper->{VARS}->{'construction'}) { @@ -1750,12 +1774,15 @@ sub printHelper { # the helper by hand. my $printChoices = []; my $paramHash; - # We can always print the current screen. - push @{$printChoices}, ["Current resource $resourceTitle (prints what you just saw on the screen)", 'current_document', 'PAGESIZE']; + if ($resourceTitle) { + push @{$printChoices}, ["$resourceTitle (prints what you just saw on the screen)", 'current_document', 'PAGESIZE']; + } + + $r->print($helper->{VARS}->{'postdata'}); # If we're in a sequence... - if (not defined $helper->{'VARS'}->{'construction'}) { + if (!defined($helper->{'VARS'}->{'construction'})) { # Allow problems from sequence push @{$printChoices}, ["Problem(s) from $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS']; # Allow all resources from sequence