Moose subclassing for Asset/File/*
This commit is contained in:
parent
c35f3b9ffb
commit
d3a3c4d37e
4 changed files with 36 additions and 36 deletions
|
|
@ -343,7 +343,7 @@ are authorized to see them.
|
|||
|
||||
=cut
|
||||
|
||||
sub getCurrentRevisionDate {
|
||||
override getCurrentRevisionDate => sub {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $assetId = shift;
|
||||
|
|
@ -366,9 +366,9 @@ sub getCurrentRevisionDate {
|
|||
return $revisionDate;
|
||||
}
|
||||
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
|
||||
|
||||
sub getParent {
|
||||
override getParent => sub {
|
||||
my $self = shift;
|
||||
if ( my $album = $self->SUPER::getParent ) {
|
||||
if ( my $album = super() ) {
|
||||
return $album;
|
||||
}
|
||||
# Only get the pending version if we're allowed to see this photo in its pending status
|
||||
|
|
@ -411,7 +411,7 @@ sub getParent {
|
|||
} )->[ 0 ];
|
||||
return $album;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -615,11 +615,11 @@ sub processCommentEditForm {
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
|
||||
my $form = $self->session->form;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
my $errors = super() || [];
|
||||
|
||||
# Make sure we have the disk space for this
|
||||
if ( !$self->getGallery->hasSpaceAvailable( $self->assetSize ) ) {
|
||||
|
|
@ -639,7 +639,7 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ C<options> is a hash reference of options and is currently not used.
|
|||
|
||||
=cut
|
||||
|
||||
sub applyConstraints {
|
||||
override applyConstraints => sub {
|
||||
my $self = shift;
|
||||
my $options = shift;
|
||||
my $gallery = $self->getGallery;
|
||||
|
|
@ -108,8 +108,8 @@ sub applyConstraints {
|
|||
$self->generateThumbnail;
|
||||
$self->setSize;
|
||||
$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
|
||||
|
||||
sub getTemplateVars {
|
||||
override getTemplateVars => sub {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->SUPER::getTemplateVars;
|
||||
my $var = super();
|
||||
|
||||
### Download resolutions
|
||||
for my $resolution ( @{ $self->getResolutions } ) {
|
||||
|
|
@ -275,7 +275,7 @@ sub getTemplateVars {
|
|||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -338,10 +338,10 @@ Make the default title into the file name minus the extention.
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
my $errors = super() || [];
|
||||
|
||||
# Return if errors
|
||||
return $errors if @$errors;
|
||||
|
|
@ -366,7 +366,7 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -376,11 +376,11 @@ Extend the superclass setFile to automatically generate thumbnails.
|
|||
|
||||
=cut
|
||||
|
||||
sub setFile {
|
||||
override setFile => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::setFile(@_);
|
||||
super();
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -89,10 +89,10 @@ An integer (in pixels) representing the longest edge a thumbnail may have.
|
|||
|
||||
=cut
|
||||
|
||||
sub applyConstraints {
|
||||
override applyConstraints => sub {
|
||||
my $self = shift;
|
||||
my $options = shift;
|
||||
$self->SUPER::applyConstraints($options);
|
||||
super();
|
||||
my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize");
|
||||
my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize");
|
||||
my $parameters = $self->parameters;
|
||||
|
|
@ -104,7 +104,7 @@ sub applyConstraints {
|
|||
$storage->adjustMaxImageSize($file, $maxImageSize);
|
||||
$self->generateThumbnail($thumbnailSize);
|
||||
$self->setSize;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
@ -138,9 +138,9 @@ Returns the TabForm object that will be used in generating the edit page for thi
|
|||
|
||||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $tabform = $self->SUPER::getEditForm();
|
||||
my $tabform = super();
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
$tabform->getTab("properties")->integer(
|
||||
-name=>"thumbnailSize",
|
||||
|
|
@ -167,7 +167,7 @@ sub getEditForm {
|
|||
);
|
||||
}
|
||||
return $tabform;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -190,11 +190,11 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
|
|||
|
||||
=cut
|
||||
|
||||
sub getToolbar {
|
||||
override getToolbar => sub {
|
||||
my $self = shift;
|
||||
return undef if ($self->getToolbarState);
|
||||
return $self->SUPER::getToolbar();
|
||||
}
|
||||
return super();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -246,11 +246,11 @@ Extend the superclass setFile to automatically generate thumbnails.
|
|||
|
||||
=cut
|
||||
|
||||
sub setFile {
|
||||
override setFile => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::setFile(@_);
|
||||
super();
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -142,10 +142,10 @@ this method to deflate the zip file into the proper folder
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
#File should be saved here by the superclass
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
super();
|
||||
my $storage = $self->getStorageLocation();
|
||||
|
||||
my $file = $self->filename;
|
||||
|
|
@ -169,7 +169,7 @@ sub processPropertiesFromFormPost {
|
|||
unless ($self->unzip($storage,$self->filename)) {
|
||||
$self->session->errorHandler->warn($i18n->get("unzip_error"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue