Moose subclassing for Asset/File/*

This commit is contained in:
Colin Kuskie 2010-04-09 10:36:16 -07:00
parent c35f3b9ffb
commit d3a3c4d37e
4 changed files with 36 additions and 36 deletions

View file

@ -343,7 +343,7 @@ are authorized to see them.
=cut =cut
sub getCurrentRevisionDate { override getCurrentRevisionDate => sub {
my $class = shift; my $class = shift;
my $session = shift; my $session = shift;
my $assetId = shift; my $assetId = shift;
@ -366,9 +366,9 @@ sub getCurrentRevisionDate {
return $revisionDate; return $revisionDate;
} }
else { else {
return $class->SUPER::getCurrentRevisionDate( $session, $assetId ); return super();
} }
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -395,9 +395,9 @@ Get the parent GalleryAlbum. If the only revision of the GalleryAlbum is
=cut =cut
sub getParent { override getParent => sub {
my $self = shift; my $self = shift;
if ( my $album = $self->SUPER::getParent ) { if ( my $album = super() ) {
return $album; return $album;
} }
# Only get the pending version if we're allowed to see this photo in its pending status # Only get the pending version if we're allowed to see this photo in its pending status
@ -411,7 +411,7 @@ sub getParent {
} )->[ 0 ]; } )->[ 0 ];
return $album; return $album;
} }
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -615,11 +615,11 @@ sub processCommentEditForm {
=cut =cut
sub processPropertiesFromFormPost { override processPropertiesFromFormPost => sub {
my $self = shift; my $self = shift;
my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' ); my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
my $form = $self->session->form; my $form = $self->session->form;
my $errors = $self->SUPER::processPropertiesFromFormPost || []; my $errors = super() || [];
# Make sure we have the disk space for this # Make sure we have the disk space for this
if ( !$self->getGallery->hasSpaceAvailable( $self->assetSize ) ) { if ( !$self->getGallery->hasSpaceAvailable( $self->assetSize ) ) {
@ -639,7 +639,7 @@ sub processPropertiesFromFormPost {
} }
return; return;
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View file

@ -85,7 +85,7 @@ C<options> is a hash reference of options and is currently not used.
=cut =cut
sub applyConstraints { override applyConstraints => sub {
my $self = shift; my $self = shift;
my $options = shift; my $options = shift;
my $gallery = $self->getGallery; my $gallery = $self->getGallery;
@ -108,8 +108,8 @@ sub applyConstraints {
$self->generateThumbnail; $self->generateThumbnail;
$self->setSize; $self->setSize;
$self->updateExifDataFromFile; $self->updateExifDataFromFile;
$self->SUPER::applyConstraints( $options ); super();
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -247,10 +247,10 @@ Get a hash reference of template variables shared by all views of this asset.
=cut =cut
sub getTemplateVars { override getTemplateVars => sub {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $var = $self->SUPER::getTemplateVars; my $var = super();
### Download resolutions ### Download resolutions
for my $resolution ( @{ $self->getResolutions } ) { for my $resolution ( @{ $self->getResolutions } ) {
@ -275,7 +275,7 @@ sub getTemplateVars {
} }
return $var; return $var;
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -338,10 +338,10 @@ Make the default title into the file name minus the extention.
=cut =cut
sub processPropertiesFromFormPost { override processPropertiesFromFormPost => sub {
my $self = shift; my $self = shift;
my $form = $self->session->form; my $form = $self->session->form;
my $errors = $self->SUPER::processPropertiesFromFormPost || []; my $errors = super() || [];
# Return if errors # Return if errors
return $errors if @$errors; return $errors if @$errors;
@ -366,7 +366,7 @@ sub processPropertiesFromFormPost {
} }
return undef; return undef;
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -376,11 +376,11 @@ Extend the superclass setFile to automatically generate thumbnails.
=cut =cut
sub setFile { override setFile => sub {
my $self = shift; my $self = shift;
$self->SUPER::setFile(@_); super();
$self->generateThumbnail; $self->generateThumbnail;
} };
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View file

@ -89,10 +89,10 @@ An integer (in pixels) representing the longest edge a thumbnail may have.
=cut =cut
sub applyConstraints { override applyConstraints => sub {
my $self = shift; my $self = shift;
my $options = shift; my $options = shift;
$self->SUPER::applyConstraints($options); super();
my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize"); my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize");
my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize"); my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize");
my $parameters = $self->parameters; my $parameters = $self->parameters;
@ -104,7 +104,7 @@ sub applyConstraints {
$storage->adjustMaxImageSize($file, $maxImageSize); $storage->adjustMaxImageSize($file, $maxImageSize);
$self->generateThumbnail($thumbnailSize); $self->generateThumbnail($thumbnailSize);
$self->setSize; $self->setSize;
} };
@ -138,9 +138,9 @@ Returns the TabForm object that will be used in generating the edit page for thi
=cut =cut
sub getEditForm { override getEditForm => sub {
my $self = shift; my $self = shift;
my $tabform = $self->SUPER::getEditForm(); my $tabform = super();
my $i18n = WebGUI::International->new($self->session,"Asset_Image"); my $i18n = WebGUI::International->new($self->session,"Asset_Image");
$tabform->getTab("properties")->integer( $tabform->getTab("properties")->integer(
-name=>"thumbnailSize", -name=>"thumbnailSize",
@ -167,7 +167,7 @@ sub getEditForm {
); );
} }
return $tabform; return $tabform;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -190,11 +190,11 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
=cut =cut
sub getToolbar { override getToolbar => sub {
my $self = shift; my $self = shift;
return undef if ($self->getToolbarState); return undef if ($self->getToolbarState);
return $self->SUPER::getToolbar(); return super();
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -246,11 +246,11 @@ Extend the superclass setFile to automatically generate thumbnails.
=cut =cut
sub setFile { override setFile => sub {
my $self = shift; my $self = shift;
$self->SUPER::setFile(@_); super();
$self->generateThumbnail; $self->generateThumbnail;
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -142,10 +142,10 @@ this method to deflate the zip file into the proper folder
=cut =cut
sub processPropertiesFromFormPost { override processPropertiesFromFormPost => sub {
my $self = shift; my $self = shift;
#File should be saved here by the superclass #File should be saved here by the superclass
$self->SUPER::processPropertiesFromFormPost; super();
my $storage = $self->getStorageLocation(); my $storage = $self->getStorageLocation();
my $file = $self->filename; my $file = $self->filename;
@ -169,7 +169,7 @@ sub processPropertiesFromFormPost {
unless ($self->unzip($storage,$self->filename)) { unless ($self->unzip($storage,$self->filename)) {
$self->session->errorHandler->warn($i18n->get("unzip_error")); $self->session->errorHandler->warn($i18n->get("unzip_error"));
} }
} };
#------------------------------------------------------------------- #-------------------------------------------------------------------