[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 06 Dec 2005 03:58:14 -0000
albertel Mon Dec 5 22:58:14 2005 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
- show zip files too
- order files by creation time from newest to oldest
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.399 loncom/interface/lonprintout.pm:1.400
--- loncom/interface/lonprintout.pm:1.399 Tue Nov 15 07:37:11 2005
+++ loncom/interface/lonprintout.pm Mon Dec 5 22:58:14 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.399 2005/11/15 12:37:11 albertel Exp $
+# $Id: lonprintout.pm,v 1.400 2005/12/06 03:58:14 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -908,28 +908,43 @@
#
# List of recently generated print files
#
-
sub recently_generated {
my $r=shift;
my $prtspool=$r->dir_config('lonPrtDir');
- my $result;
+ my $zip_result;
+ my $pdf_result;
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);
- $result.="<a href='/prtspool/$filename'>".
- &mt('Generated [_1] ([_2] bytes)',
- &Apache::lonlocal::locallocaltime($cctime),$csize).
- '</a><br />';
- }
- }
+
+ my @files =
+ grep(/^$env{'user.name'}_$env{'user.domain'}_printout_(\d+)_.*\.(pdf|zip)$/,readdir(DIR));
closedir(DIR);
- if ($result) {
- $r->print('<h4>'.&mt('Recently generated printouts').'</h4>'."\n".
- $result);
+
+ @files = sort {
+ my ($actime) = (stat($prtspool.'/'.$a))[10];
+ my ($bctime) = (stat($prtspool.'/'.$b))[10];
+ return $bctime <=> $actime;
+ } (@files);
+
+ foreach my $filename (@files) {
+ my ($ext) = ($filename =~ m/(pdf|zip)$/);
+ my ($cdev,$cino,$cmode,$cnlink,
+ $cuid,$cgid,$crdev,$csize,
+ $catime,$cmtime,$cctime,
+ $cblksize,$cblocks)=stat($prtspool.'/'.$filename);
+ my $result="<a href='/prtspool/$filename'>".
+ &mt('Generated [_1] ([_2] bytes)',
+ &Apache::lonlocal::locallocaltime($cctime),$csize).
+ '</a><br />';
+ if ($ext eq 'pdf') { $pdf_result .= $result; }
+ if ($ext eq 'zip') { $zip_result .= $result; }
+ }
+ if ($zip_result) {
+ $r->print('<h4>'.&mt('Recently generated printout zip files')."</h4>\n"
+ .$zip_result);
+ }
+ if ($pdf_result) {
+ $r->print('<h4>'.&mt('Recently generated printouts')."</h4>\n"
+ .$pdf_result);
}
}