SUPER handling for most of Wobject/*.pm. There's a problem with Calendar, though.

This commit is contained in:
Colin Kuskie 2010-04-08 17:00:05 -07:00
parent fd736e7f67
commit f56bac9948
18 changed files with 95 additions and 123 deletions

View file

@ -163,12 +163,12 @@ See WebGUI::AssetPackage::exportAssetData() for details.
=cut
sub exportAssetData {
override exportAssetData => sub {
my $self = shift;
my $data = $self->SUPER::exportAssetData;
my $data = super();
push(@{$data->{storage}}, $self->storageId) if ($self->storageId ne "");
return $data;
}
};
#-------------------------------------------------------------------

View file

@ -450,7 +450,7 @@ the calendar, or the group that can edit events in the calendar).
=cut
sub canAddEvent {
override canAddEvent => sub {
my $self = shift;
my $userId = shift;
@ -461,9 +461,9 @@ sub canAddEvent {
return 1 if (
$user->isInGroup( $self->groupIdEventEdit )
|| $self->SUPER::canEdit( $userId )
|| super();
);
}
};
#----------------------------------------------------------------------------
@ -521,10 +521,10 @@ in other areas.
=cut
sub getEditForm {
override getEditForm => sub {
my $self = shift;
my $session = $self->session;
my $form = $self->SUPER::getEditForm;
my $form = super();
my $i18n = WebGUI::International->new($session,"Asset_Calendar");
my $tab = $form->addTab("feeds",$i18n->get("feeds"), 6);
@ -674,7 +674,7 @@ ENDHTML
$tab->raw("</td></tr>");
return $form;
}
};
#----------------------------------------------------------------------------
@ -995,11 +995,11 @@ Adds / removes feeds from the feed trough.
=cut
sub processPropertiesFromFormPost {
override processPropertiesFromFormPost => sub {
my $self = shift;
my $session = $self->session;
my $form = $self->session->form;
$self->SUPER::processPropertiesFromFormPost;
super();
unless ($self->groupIdSubscribed) {
$self->createSubscriptionGroup();
@ -1037,7 +1037,7 @@ sub processPropertiesFromFormPost {
}
return;
}
};
#----------------------------------------------------------------------------

View file

@ -52,9 +52,9 @@ This method is optional if you set autoGenerateForms=1 in the definition.
=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_Carousel");
$self->session->style->setScript($self->session->url->extras('yui/build/editor/editor-min.js'), {type =>
@ -126,7 +126,7 @@ onClick='javascript:deleteItem(this.id)'></input>\n"
$tabform->getTab("properties")->raw($tableRowEnd);
return $tabform;
}
};
#-------------------------------------------------------------------
@ -159,11 +159,11 @@ Used to process properties from the form posted.
=cut
sub processPropertiesFromFormPost {
override processPropertiesFromFormPost => sub {
my $self = shift;
my $form = $self->session->form;
my (@items,$items);
$self->SUPER::processPropertiesFromFormPost(@_);
super();
foreach my $param ($form->param) {
if ($param =~ m/^item_/){
@ -189,7 +189,7 @@ sub processPropertiesFromFormPost {
$items = JSON->new->encode({items => \@items});
$self->update({items => $items});
return undef;
}
};
#-------------------------------------------------------------------

View file

@ -94,12 +94,12 @@ Extends the base method to add custom template variables for the Newsletter.
=cut
sub getViewTemplateVars {
override getViewTemplateVars => sub {
my $self = shift;
my $var = $self->SUPER::getViewTemplateVars;
my $var = super();
$var->{mySubscriptionsUrl} = $self->getUrl("func=mySubscriptions");
return $var;
}
};

View file

@ -240,9 +240,9 @@ Extends the base method to handle assetsToHide.
=cut
sub processPropertiesFromFormPost {
override processPropertiesFromFormPost => sub {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
super();
if ($self->session->form->process("assetId") eq "new" && $self->session->form->process("class") eq 'WebGUI::Asset::Wobject::Dashboard') {
$self->initialize;
if (ref $self->getParent eq 'WebGUI::Asset::Wobject::Layout') {
@ -250,7 +250,7 @@ sub processPropertiesFromFormPost {
}
$self->update({styleTemplateId=>'PBtmplBlankStyle000001'});
}
}
};
#-------------------------------------------------------------------

View file

@ -417,13 +417,13 @@ an entry is being viewed, bypass caching altogether.
=cut
sub getContentLastModified {
override getContentLastModified => sub {
my $self = shift;
if ($self->currentView eq 'list' || $self->session->form->process('entryId')) {
return time;
}
return $self->SUPER::getContentLastModified;
}
return super();
};
#-------------------------------------------------------------------
@ -993,9 +993,9 @@ Extends the base class to handle form and list mode.
=cut
sub prepareView {
override prepareView => sub {
my $self = shift;
$self->SUPER::prepareView(@_);
super();
my $view = $self->currentView;
if ( $view eq 'form' ) {
$self->prepareViewForm(@_);
@ -1003,7 +1003,7 @@ sub prepareView {
else {
$self->prepareViewList(@_);
}
}
};
#-------------------------------------------------------------------
@ -1153,10 +1153,10 @@ or are part of the groupToViewEntries.
=cut
sub canView {
override canView => sub {
my $self = shift;
return 0
if !$self->SUPER::canView;
if !super();
if ($self->currentView eq 'list') {
return 1
if $self->canEdit;
@ -1165,7 +1165,7 @@ sub canView {
return 0;
}
return 1;
}
};
#-------------------------------------------------------------------

View file

@ -126,9 +126,9 @@ Add the data table to the edit form.
=cut
# TODO Get the DataSource's edit form
sub getEditForm {
override getEditForm => sub {
my $self = shift;
my $tabform = $self->SUPER::getEditForm(@_);
my $tabform = super();
$tabform->getTab("data")->raw(
WebGUI::Form::DataTable->new(
@ -142,7 +142,7 @@ sub getEditForm {
);
return $tabform;
} ## end sub getEditForm
}; ## end sub getEditForm
#----------------------------------------------------------------------------
@ -152,12 +152,12 @@ Add a tab for the data table.
=cut
sub getEditTabs {
override getEditTabs => sub {
my $self = shift;
my $i18n = WebGUI::International->new( $self->session, "Asset_DataTable" );
return ( $self->SUPER::getEditTabs, [ "data" => $i18n->get("tab label data") ], );
}
return ( super(), [ "data" => $i18n->get("tab label data") ], );
};
#----------------------------------------------------------------------------

View file

@ -119,9 +119,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_Folder");
if ($self->assetId eq "new") {
$tabform->getTab("properties")->whatNext(
@ -133,7 +133,7 @@ sub getEditForm {
);
}
return $tabform;
}
};
#----------------------------------------------------------------------------
@ -289,11 +289,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->SUPER::www_view(@_);
}
super();
};
1;

View file

@ -85,9 +85,9 @@ Extends the base method to handle the optional mobileTemplateId and assetsToHid
=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_Layout");
my ($templateId);
@ -158,7 +158,7 @@ sub getEditForm {
);
}
return $tabform;
}
};
#-------------------------------------------------------------------
@ -365,7 +365,7 @@ of the page, by lineage.
sub getContentLastModified {
# Buggo: this is a little too conservative. Children that are hidden maybe shouldn't count. Hm.
my $self = shift;
my $mtime = $self->SUPER::getContentLastModified;
my $mtime = super();
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1, excludeClasses=>['WebGUI::Asset::Wobject::Layout']})}) {
my $child_mtime = $child->getContentLastModified;
$mtime = $child_mtime if ($child_mtime > $mtime);
@ -381,7 +381,7 @@ Extend the base method to handle caching and ad rotation.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
my $session = $self->session;
# slashdot / burst protection hack
@ -417,8 +417,8 @@ sub www_view {
return "chunked";
}
$self->{_viewPrintOverride} = 1; # we do this to make it output each asset as it goes, rather than waiting until the end
return $self->SUPER::www_view;
}
return super();
};
1;

View file

@ -320,20 +320,6 @@ sub deleteAttribute {
#-------------------------------------------------------------------
=head2 duplicate ( )
duplicates a Matrix.
=cut
sub duplicate {
my $self = shift;
my $newAsset = $self->SUPER::duplicate(@_);
return $newAsset;
}
#-------------------------------------------------------------------
=head2 editAttributeSave ( attributeProperties )
Saves an attribute.
@ -547,20 +533,6 @@ assetData.revisionDate
#-------------------------------------------------------------------
=head2 getEditForm ( )
returns the tabform object that will be used in generating the edit page for Matrix.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
return $tabform;
}
#-------------------------------------------------------------------
=head2 prepareView ( )
See WebGUI::Asset::prepareView() for details.

View file

@ -166,11 +166,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->SUPER::www_view(@_);
}
super();
};
1;

View file

@ -125,10 +125,10 @@ See WebGUI::Asset::Wobject::www_view() for details.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->SUPER::www_view(@_);
}
super();
};
1;

View file

@ -94,9 +94,9 @@ Manually build the edit form due to javascript elements.
=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_Navigation");
$tabform->getTab("display")->template(
-value=>$self->templateId,
@ -293,7 +293,7 @@ sub getEditForm {
" />';
$tabform->{_submit} = $previewButton." ".$saveButton;
return $tabform;
}
};
@ -305,7 +305,7 @@ 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
unless $self->canEdit && $self->session->var->isAdminOn;
@ -341,8 +341,8 @@ sub getToolbar {
. $self->getUrl . '">' . $i18n->get("view") . '</a></li>'
. "</ul></div></div>$toolbar</div>";
}
return $self->SUPER::getToolbar;
}
return super();
};
@ -558,18 +558,18 @@ other types aside from text/html.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
my $mimeType = $self->mimeType || 'text/html';
if ($mimeType eq 'text/html') {
return $self->SUPER::www_view();
return super();
}
else {
$self->prepareView();
$self->session->http->setMimeType($mimeType || 'text/html');
$self->session->http->setMimeType($mimeType);
return $self->view();
}
}
};
1;

View file

@ -215,16 +215,16 @@ Extend the base method to handle copying Poll answer data.
=cut
sub duplicate {
override duplicate => sub {
my $self = shift;
my $newAsset = $self->SUPER::duplicate(@_);
my $newAsset = super();
my $sth = $self->session->db->read("select * from Poll_answer where assetId=?", [$self->getId]);
while (my $data = $sth->hashRef) {
$newAsset->setVote($data->{answer}, $data->{userId}, $data->{ipAddress});
}
$sth->finish;
return $newAsset;
}
};
#----------------------------------------------------------------------------
@ -254,9 +254,9 @@ Extend the base class to handle the answers and graphing plugins.
##TODO: Pull out all form elements which can come from the definition sub
##and only have hand code in here.
sub getEditForm {
override getEditForm => sub {
my $self = shift;
my $tabform = $self->SUPER::getEditForm;
my $tabform = super();
my $i18n = WebGUI::International->new($self->session,"Asset_Poll");
my ($i, $answers);
for ($i=1; $i<=20; $i++) {
@ -292,7 +292,7 @@ sub getEditForm {
}
return $tabform;
}
};
#----------------------------------------------------------------------------
@ -359,9 +359,9 @@ Extend the base method to handle the answers and the Graphing plugin.
=cut
sub processPropertiesFromFormPost {
override processPropertiesFromFormPost => sub {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
super();
my $property = {};
my $answers = $self->session->form->process("answers");
$answers =~ s{\r}{}xmsg;
@ -377,7 +377,7 @@ sub processPropertiesFromFormPost {
$self->update($property);
$self->session->db->write("delete from Poll_answer where assetId=".$self->session->db->quote($self->getId)) if ($self->session->form->process("resetVotes"));
}
};
#-------------------------------------------------------------------

View file

@ -288,9 +288,9 @@ Manually make the edit form due to javascript for adding more queries.
=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_SQLReport");
$tabform->getTab("display")->template(
-value=>$self->getValue('templateId'),
@ -461,7 +461,7 @@ sub getEditForm {
);
return $tabform;
}
};
#-------------------------------------------------------------------
@ -857,11 +857,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->SUPER::www_view(@_);
}
super();
};
1;

View file

@ -331,15 +331,15 @@ Override the superclass to add import and exprt items to the AdminConsole submen
=cut
sub www_edit {
override www_edit => sub {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, 'Asset_Shelf');
if ($self->getId ne "new") {
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=exportProducts'),$i18n->get("export"));
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=importProducts'),$i18n->get("import"));
}
return $self->SUPER::www_edit();
}
return super();
};
#-------------------------------------------------------------------

View file

@ -223,11 +223,11 @@ variables are set correctly in viewTemplateVars.
=cut
sub www_view {
override www_view => sub {
my $self = shift;
$self->{_standAlone} = 1;
return $self->SUPER::www_view;
}
return super();
};
#-------------------------------------------------------------------

View file

@ -263,10 +263,10 @@ Duplicates a Thingy, including the definitions of the Things in this Thingy and
=cut
sub duplicate {
override duplicate => sub {
my $self = shift;
my $options = shift;
my $newAsset = $self->SUPER::duplicate($options);
my $newAsset = super();
my $db = $self->session->db;
my $assetId = $self->getId;
my $fields;
@ -310,7 +310,7 @@ sub duplicate {
$otherThingFields->{$otherThingField}->{fieldInOtherThingId}, $newAsset->getId]);
}
return $newAsset;
}
};
#-------------------------------------------------------------------
@ -598,9 +598,9 @@ See WebGUI::AssetPackage::exportAssetData() for details.
=cut
sub exportAssetData {
override exportAssetData => sub {
my $self = shift;
my $data = $self->SUPER::exportAssetData;
my $data = super();
my $db = $self->session->db;
my $assetId = $self->getId;
@ -608,7 +608,7 @@ sub exportAssetData {
$data->{fields} = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId = ?',[$assetId]);
return $data;
}
};
#-------------------------------------------------------------------