[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonprintout.pm
raeburn
raeburn at source.lon-capa.org
Mon Jan 12 21:33:37 EST 2026
raeburn Tue Jan 13 02:33:37 2026 EDT
Modified files:
/loncom/interface lonprintout.pm loncommon.pm
Log:
- Move &recently_generated() routine from lonprintout.pm to loncommon.pm
to facilitate reuse.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.708 loncom/interface/lonprintout.pm:1.709
--- loncom/interface/lonprintout.pm:1.708 Mon Jan 12 01:48:23 2026
+++ loncom/interface/lonprintout.pm Tue Jan 13 02:33:37 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.708 2026/01/12 01:48:23 raeburn Exp $
+# $Id: lonprintout.pm,v 1.709 2026/01/13 02:33:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4996,7 +4996,7 @@
'<h2>'.&mt('Unable to determine print context').'</h2>'.
'<p>'.&mt('Please display a resource, and then click the "Print" button/icon').'</p>');
my $prtspool=$r->dir_config('lonPrtDir');
- my $footer = &recently_generated($prtspool);
+ my $footer = &Apache::loncommon::recently_generated($prtspool);
$r->print($footer.&Apache::loncommon::end_page());
return OK;
}
@@ -5298,7 +5298,7 @@
my $footer;
if ($helper->{STATE} eq 'START') {
my $prtspool=$r->dir_config('lonPrtDir');
- $footer = &recently_generated($prtspool);
+ $footer = &Apache::loncommon::recently_generated($prtspool);
}
$r->print($helper->display($footer));
&Apache::lonhelper::unregisterHelperTags();
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1497 loncom/interface/loncommon.pm:1.1498
--- loncom/interface/loncommon.pm:1.1497 Fri Jan 9 02:22:38 2026
+++ loncom/interface/loncommon.pm Tue Jan 13 02:33:37 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1497 2026/01/09 02:22:38 raeburn Exp $
+# $Id: loncommon.pm,v 1.1498 2026/01/13 02:33:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -20796,6 +20796,74 @@
return %menu;
}
+#
+# Recently generated files in /home/httpd/prtspool or /home/httpd/axespool
+#
+#
+# List of recently generated print files
+#
+sub recently_generated {
+ my ($prtspool) = @_;
+ my $output;
+ my $zip_result;
+ my $pdf_result;
+ opendir(DIR,$prtspool);
+
+ my @files =
+ grep(/^$env{'user.name'}_$env{'user.domain'}_printout_(\d+)_.*\.(pdf|zip)$/,readdir(DIR));
+ closedir(DIR);
+
+ @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 $ext_text = ($ext eq 'pdf') ? &mt('PDF File'):&mt('Zip File');
+ my $result=&start_data_table_row()
+ .'<td>'
+ .'<a href="/prtspool/'.$filename.'">'.$ext_text.'</a>'
+ .'</td>'
+ .'<td>'.&Apache::lonlocal::locallocaltime($cctime).'</td>'
+ .'<td align="right">'.$csize.'</td>'
+ .&end_data_table_row();
+ if ($ext eq 'pdf') { $pdf_result .= $result; }
+ if ($ext eq 'zip') { $zip_result .= $result; }
+ }
+ if ($zip_result || $pdf_result) {
+ $output ='<hr />';
+ }
+ if ($zip_result) {
+ $output .='<h3>'.&mt('Recently generated printout zip files')."</h3>\n"
+ .&start_data_table()
+ .&start_data_table_header_row()
+ .'<th>'.&mt('Download').'</th>'
+ .'<th>'.&mt('Creation Date').'</th>'
+ .'<th>'.&mt('File Size (Bytes)').'</th>'
+ .&end_data_table_header_row()
+ .$zip_result
+ .&end_data_table();
+ }
+ if ($pdf_result) {
+ $output .='<h3>'.&mt('Recently generated printouts')."</h3>\n"
+ .&start_data_table()
+ .&start_data_table_header_row()
+ .'<th>'.&mt('Download').'</th>'
+ .'<th>'.&mt('Creation Date').'</th>'
+ .'<th>'.&mt('File Size (Bytes)').'</th>'
+ .&end_data_table_header_row()
+ .$pdf_result
+ .&end_data_table();
+ }
+ return $output;
+}
+
1;
__END__;
More information about the LON-CAPA-cvs
mailing list