#------------------------------------------------------------
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package BookPub::Catalog::Command::ShowChapter;
use strict;
use warnings;

use lib '/app/tools/bookpub/lib';
use BookPub::Command;
use BookPub::Catalog::Book::FullDisplay;
use BookPub::Catalog::Chapter;
use BookPub::Catalog::ChapterProductList;

use base 'BookPub::Command';

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

sub cmd  { return 'show_chapter'; }
sub area { return 'catalog'; }

use constant kTemplate => "/app/tools/bookpub/templates/catalog/show_chapter.xsl";

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

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

    my $chapterID = $self->getParam("ChapterID");

    # We don't really need an overarching 'container' object - This is
    # not an editable form.  So just grab the XML elements we need for the template.
    #
    $self->{xml}{Chapter} = BookPub::Catalog::Chapter->new( chapterID => $chapterID );

    my $bookID = $self->{xml}{Chapter}->BookID();
    $self->{xml}{Book} = BookPub::Catalog::Book::FullDisplay->new( bookID => $bookID );

    $self->{xml}{ChapterProductList} = BookPub::Catalog::ChapterProductList->new( chapterID => $chapterID );

    #    RPS::CommandLog::Log($self, $albumID);

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

1;
