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

foxr lon-capa-cvs-allow@mail.lon-capa.org
Fri, 20 Apr 2007 20:13:58 -0000


foxr		Fri Apr 20 16:13:58 2007 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  BZ 4711 - Make printing of LaTeX resources work if only a single resource
  is printed.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.497 loncom/interface/lonprintout.pm:1.498
--- loncom/interface/lonprintout.pm:1.497	Tue Apr 17 11:45:03 2007
+++ loncom/interface/lonprintout.pm	Fri Apr 20 16:13:58 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.497 2007/04/17 15:45:03 www Exp $
+# $Id: lonprintout.pm,v 1.498 2007/04/20 20:13:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,6 +48,34 @@
 my %parmhash;
 my $resources_printed;
 
+# Fetch the contents of a resource, uninterpreted.
+# This is used here to fetch a latex file to be included
+# verbatim into the printout<
+# NOTE: Ask Guy if there is a lonnet function similar to this?
+#
+# Parameters:
+#   URL of the file
+#
+sub fetch_raw_resource {
+    my ($url) = @_;
+
+    my $filename  = &Apache::lonnet::filelocation("", $url);
+    #
+    # fetch if needed:
+    #
+    if (! -e $filename) {
+	my $repcopy_result = &Apache::lonnet::repcopy($filename);
+
+	if ($repcopy_result ne 'ok') {
+	    return "File open failed for $filename";   # This will bomb the print.
+	}
+    }
+    my $contents = &Apache::lonnet::readfile($filename);
+
+    return $contents;
+    
+}
+
 #
 #   printf_style_subst  item format_string repl
 #  
@@ -1455,6 +1483,13 @@
 		$resources_printed .= $currentURL.':';
 		my $texversion=&Apache::lonnet::ssi($currentURL,%form);
 		$result .= $texversion;
+	} elsif ($cleanURL =~/.tex$/) {
+	    # For this sort of print of a single LaTeX file,
+	    # We can just print the LaTeX file as it is uninterpreted in any way:
+	    #
+
+	    $result = &fetch_raw_resource($currentURL);
+
 	} else {
 	    $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
 				  $helper->{'VARS'}->{'symb'});