--- loncom/xml/lonxml.pm 2001/03/27 18:19:29 1.65 +++ loncom/xml/lonxml.pm 2001/03/30 01:42:23 1.67 @@ -5,6 +5,7 @@ # 11/6 Gerd Kortemeyer # 6/1/1 Gerd Kortemeyer # 2/21,3/13 Guy +# 3/29 Gerd Kortemeyer package Apache::lonxml; use vars @@ -170,9 +171,15 @@ sub xmlparse { # if ($target eq 'meta') { # $finaloutput.=&endredirection; # } + + if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) { + $finaloutput=&afterburn($finaloutput); + } + return $finaloutput; } + sub recurse { my @innerstack = (); @@ -407,6 +414,52 @@ sub writeallows { &Apache::lonnet::appenv(%httpref); } +# +# Afterburner handles anchors, highlights and links +# + +sub afterburn { + my $result=shift; + map { + my ($name, $value) = split(/=/,$_); + $value =~ tr/+/ /; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; + if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) { + unless ($ENV{'form.'.$name}) { + $ENV{'form.'.$name}=$value; + } + } + } (split(/&/,$ENV{'QUERY_STRING'})); + if ($ENV{'form.highlight'}) { + map { + my $anchorname=$_; + my $matchthis=$anchorname; + $matchthis=~s/\_+/\\s\+/g; + $result=~s/($matchthis)/\$1\<\/font\>/gs; + } split(/\,/,$ENV{'form.highlight'}); + } + if ($ENV{'form.link'}) { + map { + my ($anchorname,$linkurl)=split(/\>/,$_); + my $matchthis=$anchorname; + $matchthis=~s/\_+/\\s\+/g; + $result=~s/($matchthis)/\$1\<\/a\>/gs; + } split(/\,/,$ENV{'form.link'}); + } + if ($ENV{'form.anchor'}) { + my $anchorname=$ENV{'form.anchor'}; + my $matchthis=$anchorname; + $matchthis=~s/\_+/\\s\+/g; + $result=~s/($matchthis)/\$1\<\/a\>/s; + $result.=(<<"ENDSCRIPT"); + +ENDSCRIPT + } + return $result; +} + sub handler { my $request=shift; @@ -445,8 +498,6 @@ sub handler { } else { $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); } - $request->print($result); - if ($target eq 'tex') { # $request->print('\end{document}'."\n"); @@ -455,6 +506,8 @@ sub handler { $request->print(&Apache::lontexconvert::footer()); } + $request->print($result); + writeallows($request->uri); return OK; }