Moose subclassing for Asset/*.pm.
This commit is contained in:
parent
0c003083a0
commit
c35f3b9ffb
6 changed files with 65 additions and 73 deletions
|
|
@ -355,13 +355,14 @@ The url of the post
|
|||
|
||||
=cut
|
||||
|
||||
sub fixUrl {
|
||||
my $self = shift;
|
||||
my $url = shift;
|
||||
$url =~ s/\./_/g;
|
||||
around fixUrl => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
my $url = shift;
|
||||
$url =~ s/\./_/g;
|
||||
|
||||
$self->SUPER::fixUrl($url);
|
||||
}
|
||||
$self->$orig($url);
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1035,9 +1036,9 @@ non-sticky, locking and unlocking posts. Calls postProcess when it is done.
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
super();
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
|
@ -1067,7 +1068,7 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
delete $self->{_storageLocation};
|
||||
$self->postProcess;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1115,15 +1116,6 @@ sub postProcess {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
#sub publish {
|
||||
# my $self = shift;
|
||||
# $self->SUPER::publish(@_);
|
||||
#
|
||||
# $self->getThread->sumReplies;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
Extend the base method to handle cleaning up storage locations.
|
||||
|
|
@ -1223,12 +1215,12 @@ the thread rating.
|
|||
|
||||
=cut
|
||||
|
||||
sub restore {
|
||||
override restore => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::restore(@_);
|
||||
super();
|
||||
$self->getThread->sumReplies;
|
||||
$self->getThread->updateThreadRating;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1262,12 +1254,12 @@ An asset object to make the parent of this asset.
|
|||
|
||||
=cut
|
||||
|
||||
sub setParent {
|
||||
override setParent => sub {
|
||||
my $self = shift;
|
||||
my $newParent = shift;
|
||||
return 0 unless ($newParent->isa('WebGUI::Asset::Post'));
|
||||
return $self->SUPER::setParent($newParent);
|
||||
}
|
||||
return super();
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1307,9 +1299,9 @@ Moves post to the trash, updates reply counter on thread and recalculates the th
|
|||
|
||||
=cut
|
||||
|
||||
sub trash {
|
||||
override trash => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::trash;
|
||||
super();
|
||||
$self->getThread->sumReplies if ($self->isReply);
|
||||
$self->getThread->updateThreadRating;
|
||||
if ($self->getThread->lastPostId eq $self->getId) {
|
||||
|
|
@ -1326,7 +1318,7 @@ sub trash {
|
|||
order by creationDate desc",[$forumLineage.'%', $self->getId]);
|
||||
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1691,7 +1683,7 @@ We're extending www_editSave() here to deal with editing a post that has been de
|
|||
|
||||
=cut
|
||||
|
||||
sub www_editSave {
|
||||
override www_editSave => sub {
|
||||
my $self = shift;
|
||||
my $assetId = $self->session->form->param("assetId");
|
||||
if($assetId eq "new" && $self->getThread->getParent->useCaptcha) {
|
||||
|
|
@ -1715,12 +1707,12 @@ sub www_editSave {
|
|||
}
|
||||
}
|
||||
}
|
||||
my $output = $self->SUPER::www_editSave();
|
||||
my $output = super();
|
||||
if ($currentTag) { # Go back to our original tag
|
||||
$currentTag->setWorking;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -204,9 +204,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_RichEdit');
|
||||
my %buttons;
|
||||
tie %buttons, "Tie::IxHash";
|
||||
|
|
@ -441,7 +441,7 @@ sub getEditForm {
|
|||
name => "allowMedia",
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
@ -477,11 +477,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();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -242,9 +242,9 @@ Extend the base method to duplicate shortcut overrides.
|
|||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
override duplicate => sub {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate(@_);
|
||||
my $newAsset = super();
|
||||
$self->session->db->write(<<'END_SQL', [$newAsset->getId, $self->getId]);
|
||||
INSERT INTO Shortcut_overrides (assetId, fieldName, newValue)
|
||||
SELECT ?, fieldName, newValue
|
||||
|
|
@ -252,7 +252,7 @@ FROM Shortcut_overrides
|
|||
WHERE assetId = ?
|
||||
END_SQL
|
||||
return $newAsset;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -278,9 +278,9 @@ Extend the base class to handle hand drawing the query build and other pieces.
|
|||
|
||||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $tabform = $self->SUPER::getEditForm();
|
||||
my $tabform = super();
|
||||
my $originalTemplate;
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Shortcut");
|
||||
my $shortcut = $self->getShortcut;
|
||||
|
|
@ -355,7 +355,7 @@ sub getEditForm {
|
|||
);
|
||||
}
|
||||
return $tabform;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -814,13 +814,13 @@ the scratch variables, and to uncache the overrides.
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
super();
|
||||
my $scratchId = "Shortcut_" . $self->getId;
|
||||
$self->session->scratch->delete($scratchId);
|
||||
$self->uncacheOverrides;
|
||||
}
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -190,11 +190,11 @@ Extends the base class to add Tax information for the Sku, in a new tab.
|
|||
|
||||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $tabform = $self->SUPER::getEditForm;
|
||||
my $tabform = super();
|
||||
|
||||
my $taxDriver = WebGUI::Shop::Tax->getDriver( $session );
|
||||
my $definition = $taxDriver->skuFormDefinition;
|
||||
|
|
@ -210,7 +210,7 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
return $tabform;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -220,11 +220,11 @@ Not to be modified, just defines a new tab.
|
|||
|
||||
=cut
|
||||
|
||||
sub getEditTabs {
|
||||
override getEditTabs => sub {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Sku");
|
||||
return ($self->SUPER::getEditTabs(), ['shop', $i18n->get('shop'), 9]);
|
||||
}
|
||||
return (super(), ['shop', $i18n->get('shop'), 9]);
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -571,10 +571,10 @@ Extends the base class to process the tax data.
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
|
||||
my $output = $self->SUPER::processPropertiesFromFormPost( @_ );
|
||||
my $output = super();
|
||||
|
||||
my $taxDriver = WebGUI::Shop::Tax->new( $self->session )->getDriver;
|
||||
$self->session->log->fatal( 'Could not instanciate tax driver.' ) unless $taxDriver;
|
||||
|
|
@ -582,7 +582,7 @@ sub processPropertiesFromFormPost {
|
|||
$self->setTaxConfiguration( $taxDriver->className, $taxDriver->processSkuFormPost );
|
||||
|
||||
return $output;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -172,11 +172,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 '<p>'.$self->SUPER::getToolbar().'</p>';
|
||||
}
|
||||
return '<p>'.super().'</p>';
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -174,14 +174,14 @@ Extra Head Tags.
|
|||
|
||||
=cut
|
||||
|
||||
sub drawExtraHeadTags {
|
||||
my ($self, $params) = @_;
|
||||
override drawExtraHeadTags => sub {
|
||||
my ($self) = @_;
|
||||
if ($self->namespace eq 'style') {
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
return $i18n->get(881);
|
||||
}
|
||||
return $self->SUPER::drawExtraHeadTags($params);
|
||||
}
|
||||
return super();
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -208,12 +208,12 @@ Override to add attachments to package data
|
|||
|
||||
=cut
|
||||
|
||||
sub exportAssetData {
|
||||
override exportAssetData => sub {
|
||||
my ( $self ) = @_;
|
||||
my $data = $self->SUPER::exportAssetData;
|
||||
my $data = super();
|
||||
$data->{template_attachments} = $self->getAttachments;
|
||||
return $data;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -262,9 +262,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_Template');
|
||||
$tabform->hidden({
|
||||
name=>"returnUrl",
|
||||
|
|
@ -392,7 +392,7 @@ sub getEditForm {
|
|||
$properties->raw("<tr><td>$label</td><td>$table</td></tr>");
|
||||
|
||||
return $tabform;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -481,12 +481,12 @@ Override to import attachments
|
|||
|
||||
=cut
|
||||
|
||||
sub importAssetCollateralData {
|
||||
override importAssetCollateralData => sub {
|
||||
my ( $self, $data, @args ) = @_;
|
||||
$self->removeAttachments;
|
||||
$self->addAttachments( $data->{template_attachments} );
|
||||
return $self->SUPER::importAssetCollateralData( $data, @args );
|
||||
}
|
||||
return super();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -620,9 +620,9 @@ Extends the master class to handle template parsers, namespaces and template att
|
|||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
super();
|
||||
# TODO: Perhaps add a way to check template syntax before it blows stuff up?
|
||||
my %data;
|
||||
my $needsUpdate = 0;
|
||||
|
|
@ -668,7 +668,7 @@ sub processPropertiesFromFormPost {
|
|||
$self->addAttachments(\@add);
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue