#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package BookPub::Catalog::Chapter::Extended;

# JPK - 'Extended' is pretty vague... This class contains all the OTHER
# stuff we need to edit on the 'edit_chapter' page.

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpub/lib';
use BookPub::Catalog::ChapterContributorHash;
use Common::RSApp;
use Common::Util;
use Common::Assert;
use Common::FormObject;
use Common::DB::Item::Language;

use base 'BookPub::Catalog::Chapter';

sub _initProperties {
    my ( $self, $props ) = @_;

    $self->SUPER::_initProperties($props);

    $self->{ContributorHash} = BookPub::Catalog::ChapterContributorHash->new( chapterID => $props->{chapter_id} );

    $self->{LanguageName} = '';
    if ( $props->{language_code} ) {
        my $lang = Common::DB::Item::Language->Lookup( part1 => $props->{language_code} );
        $self->{LanguageName} = $lang->name();
    }
}

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

    my $dbObj = $self->SUPER::_saveChapter();

    $self->{ContributorHash}->save( chapterID => $self->ChapterID() );

    return $dbObj;
}

###
1;    #
###
