--- loncom/xml/lonxml.pm 2007/01/08 18:44:01 1.436 +++ loncom/xml/lonxml.pm 2007/01/29 23:51:04 1.437 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.436 2007/01/08 18:44:01 albertel Exp $ +# $Id: lonxml.pm,v 1.437 2007/01/29 23:51:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1706,13 +1706,13 @@ sub register_insert { my ($tag,$descrip,$color,$function,$show,$helpfile,$helpdesc) = split(/,/, $line); if ($tag) { $insertlist{"$tagnum.tag"} = $tag; - $insertlist{"$tagnum.description"} = $descrip; - $insertlist{"$tagnum.color"} = $color; - $insertlist{"$tagnum.function"} = $function; + $insertlist{"$tag.description"} = $descrip; + $insertlist{"$tag.color"} = $color; + $insertlist{"$tag.function"} = $function; if (!defined($show)) { $show='yes'; } - $insertlist{"$tagnum.show"}= $show; - $insertlist{"$tagnum.helpfile"} = $helpfile; - $insertlist{"$tagnum.helpdesc"} = $helpdesc; + $insertlist{"$tag.show"}= $show; + $insertlist{"$tag.helpfile"} = $helpfile; + $insertlist{"$tag.helpdesc"} = $helpdesc; $insertlist{"$tag.num"}=$tagnum; $tagnum++; } @@ -1726,7 +1726,7 @@ sub register_insert { for (my $j=0;$j <=$#which;$j++) { if ( $which[$j] eq 'Y' ) { if ($insertlist{"$j.show"} ne 'no') { - push(@{ $insertlist{"$tag.which"} },$j); + push(@{ $insertlist{"$tag.which"} },$insertlist{"$j.tag"}); } } } @@ -1735,30 +1735,31 @@ sub register_insert { } sub description { - my ($token)=@_; - my $tagnum; - my $tag=$token->[1]; - foreach my $namespace (reverse @Apache::lonxml::namespace) { - my $testtag=$namespace.'::'.$tag; - $tagnum=$insertlist{"$testtag.num"}; - if (defined($tagnum)) { last; } - } - if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; } - return $insertlist{$tagnum.'.description'}; + my ($token)=@_; + my $tag = &get_tag($token); + return $insertlist{$tag.'.description'}; } # Returns a list containing the help file, and the description sub helpinfo { - my ($token)=@_; - my $tagnum; - my $tag=$token->[1]; - foreach my $namespace (reverse @Apache::lonxml::namespace) { - my $testtag=$namespace.'::'.$tag; - $tagnum=$insertlist{"$testtag.num"}; - if (defined($tagnum)) { last; } - } - if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; } - return ($insertlist{$tagnum.'.helpfile'}, $insertlist{$tagnum.'.helpdesc'}); + my ($token)=@_; + my $tag = &get_tag($token); + return ($insertlist{$tag.'.helpfile'}, $insertlist{$tag.'.helpdesc'}); +} + +sub get_tag { + my ($token)=@_; + my $tagnum; + my $tag=$token->[1]; + foreach my $namespace (reverse(@Apache::lonxml::namespace)) { + my $testtag = $namespace.'::'.$tag; + $tagnum = $insertlist{"$testtag.num"}; + last if (defined($tagnum)); + } + if (!defined($tagnum)) { + $tagnum = $Apache::lonxml::insertlist{"$tag.num"}; + } + return $insertlist{"$tagnum.tag"}; } 1;