--- loncom/xml/lonxml.pm 2001/05/04 21:17:24 1.72 +++ loncom/xml/lonxml.pm 2001/05/13 21:40:32 1.75 @@ -6,10 +6,11 @@ # 6/1/1 Gerd Kortemeyer # 2/21,3/13 Guy # 3/29,5/4 Gerd Kortemeyer +# 5/10 Scott Harrison package Apache::lonxml; use vars -qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate); +qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist); use strict; use HTML::TokeParser; use Safe; @@ -56,6 +57,8 @@ $metamode = 0; # turns on and of run::evaluate actually derefencing var refs $evaluate = 1; +# data structure for eidt mode, determines what tags can go into what other tags +%insertlist=(); sub xmlbegin { my $output=''; @@ -364,10 +367,11 @@ sub callsub { &Apache::lonxml::debug("nodefalt:$nodefault:"); if ($currentstring eq '' && $nodefault eq '') { if ($target eq 'edit') { + &Apache::lonxml::debug("doing default edit for $token->[1]"); if ($token->[0] eq 'S') { - $currentstring = &Apache::edit::tag_start($token,$target); + $currentstring = &Apache::edit::tag_start($target,$token); } elsif ($token->[0] eq 'E') { - $currentstring = &Apache::edit::tag_end($token,$target); + $currentstring = &Apache::edit::tag_end($target,$token); } } elsif ($target eq 'modified') { if ($token->[0] eq 'S') { @@ -611,7 +615,7 @@ sub debug { } sub error { - if ($Apache::lonxml::debug eq 1) { + if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) { print "ERROR:".$_[0]."
\n"; } else { print "An Error occured while processing this resource. The instructor has been notified.
"; @@ -625,19 +629,69 @@ sub error { &Apache::lonmsg::user_normal_msg($user,$domain,"Error in $ENV{'request.filename'}",$_[0]); } } - + #FIXME probably shouldn't have me get everything forever. &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",$_[0]); - #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]); + #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]); } } sub warning { - #if ($Apache::lonxml::debug eq 1) { + if ($ENV{'request.state'} eq 'construct') { print "WARNING:".$_[0]."
\n"; - # } + } +} + +#Should allow multiple definitions of the same tag name +sub register_insert2 { + my @data = split /\n/, &Apache::lonnet::getfile('/home/httpd/lonTabs/insertlist.tab'); + my $i; + my @order; + for ($i=0;$i < $#data; $i++) { + my $line = $data[$i]; + if ( $line =~ /^\#/ || $line =~ /^\s*\n/) { next; } + if ( $line =~ /TABLE/ ) { last; } + my ($tag,$descrip,$function,$show) = split(/,/, $line); + if ($show eq 'no') { next; } + $insertlist{"$i.tag"} = $tag; + $insertlist{"$i.description"} = $descrip; + $insertlist{"$i.function"} = $function; + } + for (;$i < $#data;$i++) { + my $line = $data[$i]; + my ($tag,@which) = split(/ +/,$line); + for (my $j=0;$j <$#which;$j++) { + if ( $which[$j] eq 'Y' ) { + push(@{ $insertlist{"$tag.which"} },$j); + } + } + } } +sub register_insert { + my @data = split /\n/, &Apache::lonnet::getfile('/home/httpd/lonTabs/insertlist.tab'); + my $i; + my @order; + for ($i=0;$i < $#data; $i++) { + my $line = $data[$i]; + if ( $line =~ /^\#/ || $line =~ /^\s*\n/) { next; } + if ( $line =~ /TABLE/ ) { last; } + my ($tag,$descrip,$function,$show) = split(/,/, $line); + if ($show eq 'no') { next; } + $insertlist{"$tag.description"} = $descrip; + $insertlist{"$tag.function"} = $function; + push (@order,$tag); + } + for (;$i < $#data;$i++) { + my $line = $data[$i]; + my ($tag,@which) = split(/ +/,$line); + for (my $j=0;$j <$#which;$j++) { + if ( $which[$j] eq 'Y' ) { + push(@{ $insertlist{"$tag.which"} },$order[$j]); + } + } + } +} 1; __END__