[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Sat, 07 Apr 2007 00:04:40 -0000


albertel		Fri Apr  6 20:04:40 2007 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - xml mode of insertlist was not respecting the <show> setting
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.441 loncom/xml/lonxml.pm:1.442
--- loncom/xml/lonxml.pm:1.441	Fri Apr  6 20:02:31 2007
+++ loncom/xml/lonxml.pm	Fri Apr  6 20:04:40 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.441 2007/04/07 00:02:31 albertel Exp $
+# $Id: lonxml.pm,v 1.442 2007/04/07 00:04:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1742,6 +1742,7 @@
     my $parser = HTML::LCParser->new($Apache::lonnet::perlvar{'lonTabDir'}
 				     .'/insertlist.xml');
     my ($tagnum,$in_help)=(0,0);
+    my @alltags;
     my $tag;
     while (my $token = $parser->get_token()) {
 	if ($token->[0] eq 'S') {
@@ -1750,6 +1751,7 @@
 		$tag = $token->[2]{'name'};
 		$insertlist{"$tagnum.tag"} = $tag;
 		$insertlist{"$tag.num"}   = $tagnum;
+		push(@alltags,$tag);
 	    } elsif ($in_help && $token->[1] eq 'file') {
 		$key = $tag.'.helpfile';
 	    } elsif ($in_help && $token->[1] eq 'description') {
@@ -1763,11 +1765,7 @@
 	    } elsif ($token->[1] eq 'help') {
 		$in_help=1;
 	    } elsif ($token->[1] eq 'allow') {
-		my $allow = $parser->get_text();
-		foreach my $element (split(',',$allow)) {
-		    $element =~ s/(^\s*|\s*$ )//gx;
-		    push(@{ $insertlist{$tag.'.which'} },$element);
-		}
+		$key = $tag.'.allow';
 	    }
 	    if (defined($key)) {
 		$insertlist{$key} = $parser->get_text();
@@ -1782,6 +1780,17 @@
 	    }
 	}
     }
+    
+    # parse the allows and ignore tags set to <show>no</show>
+    foreach my $tag (@alltags) {	
+	my $allow =  $insertlist{"$tag.allow"};
+       	foreach my $element (split(',',$allow)) {
+	    $element =~ s/(^\s*|\s*$ )//gx;
+	    if ($insertlist{"$element.show"} ne 'no') {
+		push(@{ $insertlist{$tag.'.which'} },$element);
+	    }
+	}
+    }
 }
 
 sub register_insert {