--- loncom/interface/lonprintout.pm 2005/09/06 09:54:21 1.391 +++ loncom/interface/lonprintout.pm 2005/10/30 02:24:34 1.395 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.391 2005/09/06 09:54:21 foxr Exp $ +# $Id: lonprintout.pm,v 1.395 2005/10/30 02:24:34 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,8 +42,6 @@ use Apache::lonratedt; use POSIX qw(strftime); use Apache::lonlocal; -my $resources_printed = ''; - # # Convert a numeric code to letters # @@ -823,6 +821,7 @@ sub print_latex_header { $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n". '\usepackage{longtable}\usepackage{textcomp}\usepackage{makeidx}'."\n". '\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n". + '\usepackage{wrapfig}'. '\usepackage{picins}\usepackage{calc}'."\n". '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}'."\n". '\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}'."\n". @@ -904,6 +903,29 @@ sub unsupported { # +# List of recently generated print files +# + +sub recently_generated { + my $r=shift; + my $prtspool=$r->dir_config('lonPrtDir'); + $r->print('

'.&mt('Recently generated printouts').'

'); + opendir(DIR,$prtspool); + while (my $filename=readdir(DIR)) { + if ($filename=~/^$env{'user.name'}\_$env{'user.domain'}\_printout\_(\d+)\_.*.pdf$/) { + my ($cdev,$cino,$cmode,$cnlink, + $cuid,$cgid,$crdev,$csize, + $catime,$cmtime,$cctime, + $cblksize,$cblocks)=stat($prtspool.'/'.$filename); + $r->print ("". + &mt('Generated').' '.&Apache::lonlocal::locallocaltime($cctime). + ' ('.$csize.' bytes)
'); + } + } + closedir(DIR); +} + +# # Retrieve the hash of page breaks. # # Inputs: @@ -927,6 +949,7 @@ sub get_page_breaks { sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; + my $resources_printed = ''; my $html=&Apache::lonxml::xmlbegin(); my $bodytag=&Apache::loncommon::bodytag('Preparing Printout'); $r->print(<declareVar("showallfoils"); # The page breaks can get loaded initially from the course environment: + # But we only do this in the initial state so that they are allowed to change. + # - if((!defined($env{"form.CURRENT_STATE"})) || - ($env{'form.CURRENT_STATE'} == "START")) { - $helper->{VARS}->{FINISHPAGE} = ""; # In case they did a back e.g. - } - - + $helper->{VARS}->{FINISHPAGE} = ''; &Apache::loncommon::restore_course_settings('print', {'pagebreaks' => 'scalar', 'lastprinttype' => 'scalar'}); - - if("$helper->{VARS}->{PRINT_TYPE}" eq "$env{'form.lastprinttype'}") { - $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; + + if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) { + if (!defined ($env{"form.CURRENT_STATE"})) { + + $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; + } else { + my $state = $env{"form.CURRENT_STATE"}; + if ($state eq "START") { + $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; + } + } + } @@ -1976,7 +2005,7 @@ sub printHelper { $helper->declareVar('SEQUENCE'); # Useful for debugging: Dump the help vars -# $r->print(Dumper($helper->{VARS})); +# $r->print(Dumper($helper->{VARS})); # $r->print($map); # If we're in a sequence... @@ -2456,7 +2485,6 @@ RNDSEED $helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'}; } - } @@ -2483,7 +2511,9 @@ RNDSEED } $r->print($helper->display()); - + if ($helper->{STATE} eq 'START') { + &recently_generated($r); + } &Apache::lonhelper::unregisterHelperTags(); return OK;