CatalystX-CMS
view release on metacpan or search on metacpan
lib/CatalystX/CMS/Page.pm view on Meta::CPAN
our $VERSION = '0.011';
__PACKAGE__->mk_accessors(qw( cms_root file copy url has_unsaved_changes ));
__PACKAGE__->delegate_class('CatalystX::CMS::File');
=head1 NAME
CatalystX::CMS::Page - content storage class
=head1 SYNOPSIS
my $page = $c->model('CMS')->fetch(file => 'foo/bar');
# $page isa CatalystX::CMS::Page
=head1 DESCRIPTION
CatalystX::CMS::Page is a subclass of CatalystX::CRUD::Object.
=head1 METHODS
Only new or overridden method are documented here.
=cut
=head2 new( file => I<path/to/file> )
Returns new CatalystX::CMS::Page object.
=cut
sub new {
my $class = shift;
my $self = $class->next::method(@_);
my $file = $self->{file} or $self->throw_error("file param required");
$self->{delegate} ||= $self->delegate_class->new( path => $file );
return $self;
}
=head2 create
Calls create() on the delegate(), passing all params.
=cut
sub create { shift->{delegate}->create(@_) }
=head2 read
Calls read() on the delegate(), passing all params.
=cut
sub read { shift->{delegate}->read(@_) }
=head2 update
Calls update() on the delegate(), passing all params.
=cut
sub update { shift->{delegate}->update(@_) }
=head2 delete
Calls delete() on the delegate(), passing all params.
=cut
sub delete { shift->{delegate}->delete(@_) }
=head2 url
Returns file() stringified.
=cut
=head2 calc_url
Determines the url value based on file(), type()
and flavour(). Sets the url() value and returns the value.
=cut
sub calc_url {
my $self = shift;
my $file = $self->file;
my $type = $self->type;
my $flav = $self->flavour;
my $ext = $self->delegate->ext;
$file =~ s!^$type[\/\\]!!;
$file =~ s!^$flav[\/\\]!!;
$file =~ s!\Q$ext\E$!!;
$self->url($file);
return $file;
}
=head2 title
Returns the C<title> from attrs().
=cut
sub title {
shift->attrs->{title};
}
=head2 type
Returns the C<type> from attrs() or the local type if overriden in the I<page>.
=cut
sub type {
$_[0]->attrs->{type} || $_[0]->{type};
}
=head2 flavour
Returns the C<flavour> from attrs() or the local flavour if overriden in the I<page>.
=cut
( run in 0.463 second using v1.01-cache-2.11-cpan-39bf76dae61 )