--- loncom/lonnet/perl/lonnet.pm 2000/11/27 20:44:04 1.71 +++ loncom/lonnet/perl/lonnet.pm 2000/11/28 02:48:25 1.73 @@ -61,6 +61,8 @@ # an array of IDs # idrget(domain,array): returns hash with IDs for usernames (name=>id,...) for # an array of names +# metadata(file,entry): returns the metadata entry for a file. entry='keys' +# returns a comma separated list of keys # # 6/1/99,6/2,6/10,6/11,6/12,6/14,6/26,6/28,6/29,6/30, # 7/1,7/2,7/9,7/10,7/12,7/14,7/15,7/19, @@ -1475,19 +1477,21 @@ sub EXT { sub metadata { my ($uri,$what)=@_; $uri=&declutter($uri); - unless ($uri=~/\.meta$/) { $uri.='.meta'; } + my $filename=$uri; + $uri=~s/\.meta$//; unless ($metacache{$uri.':keys'}) { - my $metastring=&getfile($perlvar{'lonDocRoot'}.'/res/'.$uri); + unless ($filename=~/\.meta$/) { $filename.='.meta'; } + my $metastring=&getfile($perlvar{'lonDocRoot'}.'/res/'.$filename); my $parser=HTML::TokeParser->new(\$metastring); my $token; while ($token=$parser->get_token) { if ($token->[0] eq 'S') { my $entry=$token->[1]; my $unikey=$entry; - if ($token->[2]->{'part'}) { + if (defined($token->[2]->{'part'})) { $unikey.='_'.$token->[2]->{'part'}; } - if ($token->[2]->{'name'}) { + if (defined($token->[2]->{'name'})) { $unikey.='_'.$token->[2]->{'name'}; } if ($metacache{$uri.':keys'}) { @@ -1497,7 +1501,7 @@ sub metadata { } map { $metacache{$uri.':'.$unikey.'.'.$_}=$token->[2]->{$_}; - } $token->[3]; + } @{$token->[3]}; $metacache{$uri.':'.$unikey}=$parser->get_text('/'.$entry); } }