[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm printout.pl /localize lonlocal.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 18 Feb 2004 23:33:17 -0000
albertel Wed Feb 18 18:33:17 2004 EDT
Modified files:
/loncom/localize lonlocal.pm
/loncom/interface loncommon.pm printout.pl
Log:
- &mt() would return an array into scalar context, needs to return a scalar in those cases
- printout.pl now has the headers, and set charset properly
- lonlocal works in a CGI context (but of course it will be slower since the language handle isn't persitent)
- loncommon::content_type works in a CGI context
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.30 loncom/localize/lonlocal.pm:1.31
--- loncom/localize/lonlocal.pm:1.30 Mon Dec 22 18:42:18 2003
+++ loncom/localize/lonlocal.pm Wed Feb 18 18:33:17 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Localization routines
#
-# $Id: lonlocal.pm,v 1.30 2003/12/22 23:42:18 www Exp $
+# $Id: lonlocal.pm,v 1.31 2004/02/18 23:33:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -185,7 +185,11 @@
if ($lh) {
return $lh->maketext(@_);
} else {
- return @_;
+ if (wantarray) {
+ return @_;
+ } else {
+ return $_[0];
+ }
}
}
@@ -236,12 +240,14 @@
sub get_language_handle {
my $r=shift;
- my $headers=$r->headers_in;
- $ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'};
+ if ($r) {
+ my $headers=$r->headers_in;
+ $ENV{'HTTP_ACCEPT_LANGUAGE'}=$headers->{'Accept-language'};
+ }
my @languages=&Apache::loncommon::preferred_languages;
$ENV{'HTTP_ACCEPT_LANGUAGE'}='';
$lh=Apache::localize->get_handle(@languages);
- if (&Apache::lonnet::mod_perl_version == 1) {
+ if ($r && &Apache::lonnet::mod_perl_version == 1) {
$r->content_languages([¤t_language()]);
}
### setlocale(LC_ALL,¤t_locale);
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.180 loncom/interface/loncommon.pm:1.181
--- loncom/interface/loncommon.pm:1.180 Wed Feb 18 10:40:23 2004
+++ loncom/interface/loncommon.pm Wed Feb 18 18:33:17 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.180 2004/02/18 15:40:23 matthew Exp $
+# $Id: loncommon.pm,v 1.181 2004/02/18 23:33:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2593,11 +2593,16 @@
}
sub content_type {
- my ($r,$type,$charset) = @_;
- unless ($charset) {
- $charset=&Apache::lonlocal::current_encoding;
- }
- $r->content_type($type.($charset?'; charset='.$charset:''));
+ my ($r,$type,$charset) = @_;
+ unless ($charset) {
+ $charset=&Apache::lonlocal::current_encoding;
+ }
+ if ($charset) { $type.='; charset='.$charset; }
+ if ($r) {
+ $r->content_type($type);
+ } else {
+ print("Content-type: $type\n\n");
+ }
}
=pod
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.50 loncom/interface/printout.pl:1.51
--- loncom/interface/printout.pl:1.50 Wed Feb 18 17:23:19 2004
+++ loncom/interface/printout.pl Wed Feb 18 18:33:17 2004
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
#
-# $Id: printout.pl,v 1.50 2004/02/18 22:23:19 albertel Exp $
+# $Id: printout.pl,v 1.51 2004/02/18 23:33:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,8 @@
use IO::File;
use Image::Magick;
use Apache::lonhtmlcommon;
+use Apache::loncommon;
+use Apache::lonlocal;
$|=1;
my %origENV=%ENV;
@@ -49,9 +51,10 @@
END
return;
}
-
- print "Content-type: text/html\n\n";
- print "<body bgcolor=\"#FFFFFF\">\n";
+ &Apache::lonlocal::get_language_handle();
+ &Apache::loncommon::content_type(undef,'text/html');
+ my $bodytag=&Apache::loncommon::bodytag('Creating PDF','','');
+ print $bodytag;
my $identifier = $ENV{'QUERY_STRING'};
my $texfile = $ENV{'cgi.'.$identifier.'.file'};