--- rat/lonpage.pm 2000/08/30 11:10:23 1.1 +++ rat/lonpage.pm 2000/08/31 10:14:08 1.2 @@ -4,7 +4,7 @@ # (TeX Content Handler # # 05/29/00,05/30 Gerd Kortemeyer) -# 08/30 Gerd Kortemeyer +# 08/30,08/31 Gerd Kortemeyer package Apache::lonpage; @@ -13,6 +13,51 @@ use Apache::Constants qw(:common :http); use Apache::lonnet(); use GDBM_File; +# -------------------------------------------------------------- Module Globals +my %hash; +my @rows; + +# ------------------------------------------------------------ Build page table + +sub tracetable { + my ($sofar,$rid,$beenhere)=@_; + my $further=$sofar; + unless ($beenhere=~/\&$rid\&/) { + $beenhere.=$rid.'&'; + + if (defined($hash{'is_map_'.$rid})) { + if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && + (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) { + $sofar= + &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}}, + '&'.$hash{'map_finish_'.$hash{'src_'.$rid}}.'&'); + $sofar++; + if (defined($rows[$sofar])) { + $rows[$sofar].='&'.$hash{'map_finish_'.$hash{'src_'.$rid}}; + } else { + $rows[$sofar]=$hash{'map_finish_'.$hash{'src_'.$rid}}; + } + } + } else { + $sofar++; + if (defined($rows[$sofar])) { + $rows[$sofar].='&'.$rid; + } else { + $rows[$sofar]=$rid; + } + } + + if (defined($hash{'to_'.$rid})) { + map { + my $now=&tracetable($sofar,$hash{'goesto_'.$_},$beenhere); + if ($now>$further) { $further=$now; } + } split(/\,/,$hash{'to_'.$rid}); + } + } + return $further; +} + + # ================================================================ Main Handler sub handler { @@ -34,7 +79,6 @@ sub handler { if ($ENV{'request.course.fn'}) { my $fn=$ENV{'request.course.fn'}; if (-e "$fn.db") { - my %hash; if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) { # ------------------------------------------------------------------- Hash tied my $firstres=$hash{'map_start_'.$requrl}; @@ -44,6 +88,15 @@ sub handler { $r->print("

All is cool.

"); + @rows=(); + &tracetable(0,$firstres,'&'.$lastres.'&'); + $rows[$#rows+1]=''.$lastres; + + my $i; + for ($i=0;$i<=$#rows;$i++) { + $r->print($i.' - '.$rows[$i].'
'); + } + # ------------------------------------------------------------- End render page } else { $r->print("

Page undefined.

");