package Wiki::Toolkit::Plugin::Summariser;
use strict;
use Wiki::Toolkit::Plugin;

use vars qw( $VERSION @ISA );
$VERSION = '0.01';
@ISA = qw( Wiki::Toolkit::Plugin );

=head1 NAME

Wiki::Toolkit::Plugin::Summariser - Category management for Wiki::Toolkit.

=head1 DESCRIPTION


=head1 SYNOPSIS

  use Wiki::Toolkit;
  use Wiki::Toolkit::Plugin::Summariser;

  my $summariser = Wiki::Toolkit::Plugin::Summariser->new;
  $wiki->register_plugin( plugin => $summariser );


=head1 METHODS

=over 4

=item B<new>

  my $summariser = Wiki::Toolkit::Plugin::Summariser->new;
  $wiki->register_plugin( plugin => $summariser );

=cut

sub new {
    my $class = shift;
    my $self = {};
    bless $self, $class;
    return $self;
}

=item B<metadata_list>

  my @list = $summariser->metadata_list( type => "Category" );


=cut

sub metadata_list {
    my ($self, %args) = @_;
    my $dbh = $self->datastore->dbh;
    my $sth;
    if ( $args{type} ) {
        $sth = $dbh->prepare( "
SELECT DISTINCT metadata.metadata_value FROM metadata WHERE metadata.metadata_type = ? ORDER BY metadata.metadata_value
    " );
        $sth->execute( $args{type} );
    } else {
        $sth = $dbh->prepare( "
SELECT DISTINCT metadata.metadata_value FROM metadata ORDER BY metadata.metadata_value
    " );
        $sth->execute( );
    }
    my @categories;
    while ( my ($cat) = $sth->fetchrow_array ) {
        push @categories, $cat;
    }
    return @categories;
}

=head1 SEE ALSO

=over 4

=item *

L<Wiki::Toolkit>

=item *

L<Wiki::Toolkit::Plugin>

=back

=head1 AUTHOR

Christopher Schmidt

=head1 COPYRIGHT

     Copyright (C) 2005 Christopher Schmidt.  All Rights Reserved.

This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;
