--- loncom/xml/lonxml.pm 2002/05/01 21:40:25 1.168 +++ loncom/xml/lonxml.pm 2002/06/03 21:07:20 1.176 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.168 2002/05/01 21:40:25 albertel Exp $ +# $Id: lonxml.pm,v 1.176 2002/06/03 21:07:20 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,7 +60,7 @@ package Apache::lonxml; use vars -qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace); +qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode); use strict; use HTML::LCParser(); use HTML::TreeBuilder(); @@ -129,9 +129,15 @@ $evaluate = 1; # stores the list of active tag namespaces @namespace=(); +# if 0 all high ASCII characters will be encoded into HTML Entities +$prevent_entity_encode=0; + # has the dynamic menu been updated to know about this resource $Apache::lonxml::registered=0; +# a pointer the the Apache request object +$Apache::lonxml::request=''; + sub xmlbegin { my $output=''; if ($ENV{'browser.mathml'}) { @@ -325,8 +331,9 @@ sub registerurl { my $forcereg=shift; my $target = shift; my $result = ''; - if (($ENV{'request.publicaccess'}) || - ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html')) { + if ((($ENV{'request.publicaccess'}) || + (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) && + (!$forcereg)) { return ''; } @@ -334,6 +341,7 @@ sub registerurl { $Apache::lonxml::registered=1; my $nothing=''; if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; } + my $timesync='menu.clock.setTime(1000*'.time.');'; if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) { my $hwkadd=''; if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { @@ -344,7 +352,7 @@ ENDSUBM } if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) { $hwkadd.=(< -1 ) { - if ($Apache::lonxml::redirection) { - $Apache::lonxml::outputstack['-1'] .= - &Apache::run::evaluate($result,$safeeval,$$parstack['-1']); - } else { - $finaloutput .= &Apache::run::evaluate($result,$safeeval, - $$parstack['-1']); - } + $result=&Apache::run::evaluate($result,$safeeval,$$parstack[-1]); } else { - $finaloutput .= &Apache::run::evaluate($result,$safeeval,''); + $result= &Apache::run::evaluate($result,$safeeval,''); } - $result = ''; } + # Encode any high ASCII characters + if (!$Apache::lonxml::prevent_entity_encode) { + $result=&HTML::Entities::encode($result,"\200-\377"); + } + if ($Apache::lonxml::redirection) { + $Apache::lonxml::outputstack['-1'] .= $result; + } else { + $finaloutput.=$result; + } + $result = ''; + if ($token->[0] eq 'E') { &end_tag($stack,$parstack,$token); } @@ -648,8 +665,7 @@ sub inner_xmlparse { # $finaloutput.=&endredirection; # } - # Encode any high ASCII characters - $finaloutput=&HTML::Entities::encode($finaloutput,"\200-\377"); + if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) { $finaloutput=&afterburn($finaloutput); } @@ -792,7 +808,8 @@ sub callsub { } sub setup_globals { - my ($target)=@_; + my ($request,$target)=@_; + $Apache::lonxml::request=$request; $Apache::lonxml::registered = 0; @Apache::lonxml::pwd=(); @Apache::lonxml::extlinks=(); @@ -1122,9 +1139,9 @@ BUTTONS
-$buttons +$buttons
-$buttons +
$buttons
ENDFOOTER @@ -1213,7 +1230,8 @@ ENDNOTFOUND } } if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) { - $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); + $result = &Apache::lonxml::xmlparse($request,$target,$filecontents, + '',%mystyle); } }