--- Toolkit.pm.old 2006-11-12 01:26:54.000000000 +0000 +++ Toolkit.pm 2006-11-12 01:26:50.000000000 +0000 @@ -3,7 +3,7 @@ use strict; use vars qw( $VERSION ); -$VERSION = '0.72'; +$VERSION = '0.73'; use Carp qw(croak carp); use Digest::MD5 "md5_hex"; @@ -421,6 +421,41 @@ $self->store->list_nodes_by_missing_metadata( @args ); } + +=item B + + # List every kind of category we know about. + my @categories = $wiki->list_metadata_by_type('category'); + + # And all locales too. + my @locales = $wiki->list_metadata_by_type('locale'); + +You I supply a type of metadata. Returns an arrayref. + +=cut + +sub list_metadata_by_type { + my ($self, $type) = @_; + + return 0 unless $type; + + my $sth = $self->store->dbh->prepare(' + SELECT DISTINCT metadata.metadata_value + FROM metadata + WHERE metadata.metadata_type = ? + ORDER BY metadata.metadata_value + '); + + $sth->execute($type); + + my @metadata; + while ( my ($metadatum) = $sth->fetchrow_array ) { + push @metadata, $metadatum; + } + + return \@metadata; +} + =item B # Nodes changed in last 7 days - each node listed only once.