#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package BookPub::Admin::Command::ListContributors;
use strict;
use warnings;

use lib '/app/tools/bookpub/lib';
use BookPub::Catalog::ContributorList::WithBookCount;

use BookPub::Command;
use base 'BookPub::Command';

use lib '/app/tools/common/lib';
use RSApache::Response::XSLT;

sub cmd      { return 'list_contributors'; }
sub area     { return 'admin'; }
sub pageName { return 'Contributors'; }

use constant kTemplate => "/app/tools/bookpub/templates/admin/list_contributors.xsl";

sub execute {
    my ($self) = @_;

    my $response = $self->SUPER::execute();
    return $response if $response;

    my $page = $self->getParam("page");
    $page = 1 unless defined $page;

    my $list = BookPub::Catalog::ContributorList::WithBookCount->new( currentPage => $page );

    $self->{xml}{ContributorList} = $list;

    $response = RSApache::Response::XSLT->new( $self->{xml}, kTemplate );
    return $response;
}

1;
