--- loncom/xml/lonxml.pm 2006/10/04 19:50:43 1.415.2.1
+++ loncom/xml/lonxml.pm 2006/11/10 19:41:34 1.425
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.415.2.1 2006/10/04 19:50:43 albertel Exp $
+# $Id: lonxml.pm,v 1.425 2006/11/10 19:41:34 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -251,7 +251,7 @@ sub printtokenheader {
my ($target,$token,$tsymb,$tcrsid,$tudom,$tuname)=@_;
unless ($token) { return ''; }
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser();
unless ($tsymb) {
$tsymb=$symb;
}
@@ -342,6 +342,11 @@ sub xmlparse {
my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
$safeeval,\%style_for_target,1);
+ if (@stack) {
+ &warning("At end of file some tags were still left unclosed, ".
+ '<'.join('>, <',reverse(@stack)).
+ '>');
+ }
if ($env{'request.uri'}) {
&writeallows($env{'request.uri'});
}
@@ -772,8 +777,11 @@ sub init_safespace {
$safehole->wrap(\&Math::Random::random_set_seed,$safeeval,'&random_set_seed');
$safehole->wrap(\&Apache::lonxml::error,$safeeval,'&LONCAPA_INTERNAL_ERROR');
$safehole->wrap(\&Apache::lonxml::debug,$safeeval,'&LONCAPA_INTERNAL_DEBUG');
+ $safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&LONCAPA_INTERNAL_LOGTHIS');
+ $safehole->wrap(\&Apache::inputtags::finalizeawards,$safeeval,'&LONCAPA_INTERNAL_FINALIZEAWARDS');
$safehole->wrap(\&Apache::caparesponse::get_sigrange,$safeeval,'&LONCAPA_INTERNAL_get_sigrange');
-
+ use Data::Dumper;
+ $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
#need to inspect this class of ops
# $safeeval->deny(":base_orig");
$safeeval->permit("require");
@@ -813,7 +821,7 @@ sub delete_package_recurse {
sub initialize_rndseed {
my ($safeeval)=@_;
my $rndseed;
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser();
$rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name);
my $safeinit = '$external::randomseed="'.$rndseed.'";';
&Apache::lonxml::debug("Setting rndseed to $rndseed");
@@ -1149,19 +1157,23 @@ sub newparser {
}
sub parstring {
- my ($token) = @_;
- my $temp='';
- foreach (@{$token->[3]}) {
- unless ($_=~/\W/) {
- my $val=$token->[2]->{$_};
- $val =~ s/([\%\@\\\"\'])/\\$1/g;
- $val =~ s/(\$[^{a-zA-Z_])/\\$1/g;
- $val =~ s/(\$)$/\\$1/;
- #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
- $temp .= "my \$$_=\"$val\";";
- }
- }
- return $temp;
+ my ($token) = @_;
+ my (@vars,@values);
+ foreach my $attr (@{$token->[3]}) {
+ if ($attr!~/\W/) {
+ my $val=$token->[2]->{$attr};
+ $val =~ s/([\%\@\\\"\'])/\\$1/g;
+ $val =~ s/(\$[^\{a-zA-Z_])/\\$1/g;
+ $val =~ s/(\$)$/\\$1/;
+ #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
+ push(@vars,"\$$attr");
+ push(@values,"\"$val\"");
+ }
+ }
+ my $var_init =
+ (@vars) ? 'my ('.join(',',@vars).') = ('.join(',',@values).');'
+ : '';
+ return $var_init;
}
sub extlink {
@@ -1540,7 +1552,7 @@ sub error {
$errormsg=&mt("An error occured while processing this resource. The author has been notified.");
}
my $host=$Apache::lonnet::perlvar{'lonHostID'};
- my $msg = join('
',(@_,"The occured on host $host"));
+ my $msg = join('
',(@_,"The error occurred on host $host"));
#notify author
&Apache::lonmsg::author_res_msg($env{'request.filename'},$msg);
#notify course
@@ -1623,14 +1635,14 @@ sub get_param {
}
if ( ! $args ) { return undef; }
if ( $case_insensitive ) {
- if ($args =~ s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei) {
+ if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {
return &Apache::run::run("{$args;".'return $'.$param.'}',
$safeeval); #'
} else {
return undef;
}
} else {
- if ( $args =~ /my \$\Q$param\E=\"/ ) {
+ if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) {
return &Apache::run::run("{$args;".'return $'.$param.'}',
$safeeval); #'
} else {
@@ -1649,10 +1661,10 @@ sub get_param_var {
}
&Apache::lonxml::debug("Args are $args param is $param");
if ($case_insensitive) {
- if (! ($args=~s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei)) {
+ if (! ($args=~s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei)) {
return undef;
}
- } elsif ( $args !~ /my \$\Q$param\E=\"/ ) { return undef; }
+ } elsif ( $args !~ /my .*\$\Q$param\E[,\)]/ ) { return undef; }
my $value=&Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
&Apache::lonxml::debug("first run is $value");
if ($value =~ /^[\$\@\%][a-zA-Z_]\w*$/) {
@@ -1735,48 +1747,6 @@ sub helpinfo {
return ($insertlist{$tagnum.'.helpfile'}, $insertlist{$tagnum.'.helpdesc'});
}
-# ----------------------------------------------------------------- whichuser
-# returns a list of $symb, $courseid, $domain, $name that is correct for
-# calls to lonnet functions for this setup.
-# - looks for form.grade_ parameters
-sub whichuser {
- my ($passedsymb)=@_;
- my ($symb,$courseid,$domain,$name,$publicuser);
- if (defined($env{'form.grade_symb'})) {
- my ($tmp_courseid)=
- &Apache::loncommon::get_env_multiple('form.grade_courseid');
- my $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid);
- if (!$allowed &&
- exists($env{'request.course.sec'}) &&
- $env{'request.course.sec'} !~ /^\s*$/) {
- $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid.
- '/'.$env{'request.course.sec'});
- }
- if ($allowed) {
- ($symb)=&Apache::loncommon::get_env_multiple('form.grade_symb');
- $courseid=$tmp_courseid;
- ($domain)=&Apache::loncommon::get_env_multiple('form.grade_domain');
- ($name)=&Apache::loncommon::get_env_multiple('form.grade_username');
- return ($symb,$courseid,$domain,$name,$publicuser);
- }
- }
- if (!$passedsymb) {
- $symb=&Apache::lonnet::symbread();
- } else {
- $symb=$passedsymb;
- }
- $courseid=$env{'request.course.id'};
- $domain=$env{'user.domain'};
- $name=$env{'user.name'};
- if ($name eq 'public' && $domain eq 'public') {
- if (!defined($env{'form.username'})) {
- $env{'form.username'}.=time.rand(10000000);
- }
- $name.=$env{'form.username'};
- }
- return ($symb,$courseid,$domain,$name,$publicuser);
-}
-
1;
__END__