--- rat/lonpage.pm 2000/10/02 21:33:40 1.10 +++ rat/lonpage.pm 2000/10/16 09:46:23 1.12 @@ -5,7 +5,7 @@ # # 05/29/00,05/30 Gerd Kortemeyer) # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, -# 10/02 Gerd Kortemeyer +# 10/02,10/10,10/14,10/16 Gerd Kortemeyer package Apache::lonpage; @@ -74,10 +74,28 @@ sub tracetable { } if (defined($hash{'to_'.$rid})) { + my $mincond=1; + my $next=''; map { - my $now=&tracetable($sofar,$hash{'goesto_'.$_},$beenhere); - if ($now>$further) { $further=$now; } + my $thiscond= + &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); + if ($thiscond>=$mincond) { + if ($next) { + $next.=','.$_.':'.$thiscond; + } else { + $next=$_.':'.$thiscond; + } + if ($thiscond>$mincond) { $mincond=$thiscond; } + } } split(/\,/,$hash{'to_'.$rid}); + map { + my ($linkid,$condval)=split(/\:/,$_); + if ($condval>=$mincond) { + my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); + if ($now>$further) { $further=$now; } + } + } split(/\,/,$next); + } } return $further; @@ -187,8 +205,10 @@ sub handler { my $output=Apache::lonnet::ssi($src,%posthash); my $parser=HTML::TokeParser->new(\$output); my $token; + my $thisdir=$src; my $bodydef=0; my $thisxml=0; + my @rlinks=(); if ($output=~/\?xml/) { $isxml=1; $thisxml=1; @@ -196,9 +216,22 @@ sub handler { /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\]*\>/si; $xmlheader=$1; } - while (($bodydef==0) && - ($token=$parser->get_token)) { - if ($token->[1] eq 'body') { + while ($token=$parser->get_token) { + if ($token->[0] eq 'S') { + if ($token->[1] eq 'a') { + if ($token->[2]->{'href'}) { + $rlinks[$#rlinks+1]= + $token->[2]->{'href'}; + } + } elsif ($token->[1] eq 'img') { + $rlinks[$#rlinks+1]= + $token->[2]->{'src'}; + } elsif ($token->[1] eq 'embed') { + $rlinks[$#rlinks+1]= + $token->[2]->{'src'}; + } elsif ($token->[1] eq 'base') { + $thisdir=$token->[2]->{'href'}; + } elsif ($token->[1] eq 'body') { $bodydef=1; $ssibgcolor{$_}=$token->[2]->{'bgcolor'}; $ssitext{$_}=$token->[2]->{'text'}; @@ -208,15 +241,15 @@ sub handler { if ($thisxml) { $xmlbody=$token->[4]; } - } - if ($token->[1] eq 'meta') { + } elsif ($token->[1] eq 'meta') { $allmeta.="\n".$token->[4].''; - } - if ($token->[1] eq 'script') { + } elsif (($token->[1] eq 'script') && + ($bodydef==0)) { $allscript.="\n\n" .$parser->get_text('/script'); } - } + } + } if ($output=~/\]*\>(.*)/si) { $output=$1; } @@ -226,6 +259,16 @@ sub handler { $output=~s/\]*\>//gsi; $output=~s/\<\/form[^\>]*\>//gsi; } + $thisdir=~s/\/[^\/]*$//; + map { + unless (($_=~/^http:\/\//i) || + ($_=~/^\//)) { + my $newlocation= + &Apache::lonnet::hreflocation($thisdir,$_); + $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/; + } + } @rlinks; + $output=~s/\<\s*applet/\