[cgi-wiki-dev] [earle@downlode.org: Wiki::Toolkit metadata patch]

Dominic Hargreaves dom at earth.li
Sat Nov 18 11:23:22 GMT 2006


On Sat, Nov 18, 2006 at 11:22:28AM +0000, Dominic Hargreaves wrote:
> Nick,
> 
> You're probably more familiar with Wiki::Toolkit than me at this point..
> does this look sane?

Oops, here is the patch.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)
-------------- next part --------------
--- 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_metadata_by_type>
+
+  # 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<must> 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<list_recent_changes>
 
   # Nodes changed in last 7 days - each node listed only once.


More information about the CGI-Wiki-dev mailing list