Convert Snippet to moose accessors.
This commit is contained in:
parent
675bc49f05
commit
41b741d41b
3 changed files with 55 additions and 60 deletions
|
|
@ -200,7 +200,7 @@ Indexing the content of the snippet. See WebGUI::Asset::indexContent() for addit
|
||||||
sub indexContent {
|
sub indexContent {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $indexer = $self->SUPER::indexContent;
|
my $indexer = $self->SUPER::indexContent;
|
||||||
$indexer->addKeywords($self->get("snippet"));
|
$indexer->addKeywords($self->snippet);
|
||||||
$indexer->setIsPublic(0);
|
$indexer->setIsPublic(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,8 +254,8 @@ sub view {
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session, 1);
|
my $versionTag = WebGUI::VersionTag->getWorking($session, 1);
|
||||||
my $noCache =
|
my $noCache =
|
||||||
$session->var->isAdminOn
|
$session->var->isAdminOn
|
||||||
|| $self->get("cacheTimeout") <= 10
|
|| $self->cacheTimeout <= 10
|
||||||
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
|
|| ($versionTag && $versionTag->getId eq $self->tagId);
|
||||||
unless ($noCache) {
|
unless ($noCache) {
|
||||||
my $out = eval{$session->cache->get("view_".$calledAsWebMethod."_".$self->getId)};
|
my $out = eval{$session->cache->get("view_".$calledAsWebMethod."_".$self->getId)};
|
||||||
return $out if $out;
|
return $out if $out;
|
||||||
|
|
@ -270,7 +270,7 @@ sub view {
|
||||||
}
|
}
|
||||||
WebGUI::Macro::process($session,\$output);
|
WebGUI::Macro::process($session,\$output);
|
||||||
unless ($noCache) {
|
unless ($noCache) {
|
||||||
eval{$session->cache->set("view_".$calledAsWebMethod."_".$self->getId, $output, $self->get("cacheTimeout"))};
|
eval{$session->cache->set("view_".$calledAsWebMethod."_".$self->getId, $output, $self->cacheTimeout)};
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,55 +23,50 @@ use WebGUI::International;
|
||||||
use WebGUI::Macro;
|
use WebGUI::Macro;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
use WebGUI::Definition::Asset (
|
use WebGUI::Definition::Asset;
|
||||||
properties => [
|
extends WebGUI::Asset;
|
||||||
description=>{
|
attribute tableName => 'wobject',
|
||||||
fieldType =>'HTMLArea',
|
attribute assetName => 'Wobject',
|
||||||
defaultValue =>undef,
|
property description => (
|
||||||
tab =>"properties",
|
fieldType => 'HTMLArea',
|
||||||
label =>[85,'Asset_Wobject'],
|
defaultValue => undef,
|
||||||
hoverHelp =>['85 description','Asset_Wobject'],
|
tab => "properties",
|
||||||
},
|
label => [85,'Asset_Wobject'],
|
||||||
displayTitle=>{
|
hoverHelp => ['85 description','Asset_Wobject'],
|
||||||
fieldType =>'yesNo',
|
);
|
||||||
defaultValue =>1,
|
property displayTitle => (
|
||||||
tab =>"display",
|
fieldType => 'yesNo',
|
||||||
label =>[174,'Asset_Wobject'],
|
defaultValue => 1,
|
||||||
hoverHelp =>['174 description','Asset_Wobject'],
|
tab => "display",
|
||||||
uiLevel =>5
|
label => [174,'Asset_Wobject'],
|
||||||
},
|
hoverHelp => ['174 description','Asset_Wobject'],
|
||||||
styleTemplateId=>{
|
uiLevel => 5
|
||||||
fieldType =>'template',
|
);
|
||||||
defaultValue =>'PBtmpl0000000000000060',
|
property styleTemplateId => (
|
||||||
tab =>"display",
|
|
||||||
label =>[1073,'Asset_Wobject'],
|
|
||||||
hoverHelp =>['1073 description','Asset_Wobject'],
|
|
||||||
namespace =>'style'
|
|
||||||
},
|
|
||||||
printableStyleTemplateId=>{
|
|
||||||
fieldType =>'template',
|
|
||||||
defaultValue =>'PBtmpl0000000000000060',
|
|
||||||
tab =>"display",
|
|
||||||
label =>[1079,'Asset_Wobject'],
|
|
||||||
hoverHelp =>['1079 description','Asset_Wobject'],
|
|
||||||
namespace =>'style'
|
|
||||||
},
|
|
||||||
mobileStyleTemplateId => {
|
|
||||||
fieldType => 'template',
|
fieldType => 'template',
|
||||||
noFormPost => sub { return !$_[0]->session->setting->get('useMobileStyle'); },
|
|
||||||
defaultValue => 'PBtmpl0000000000000060',
|
defaultValue => 'PBtmpl0000000000000060',
|
||||||
tab => 'display',
|
tab => "display",
|
||||||
label => ['mobileStyleTemplateId label','Asset_Wobject'],
|
label => [1073,'Asset_Wobject'],
|
||||||
hoverHelp => ['mobileStyleTemplateId description','Asset_Wobject'],
|
hoverHelp => ['1073 description','Asset_Wobject'],
|
||||||
namespace => 'style',
|
namespace => 'style'
|
||||||
},
|
);
|
||||||
],
|
property printableStyleTemplateId => (
|
||||||
tableName =>'wobject',
|
fieldType => 'template',
|
||||||
assetName => 'Wobject',
|
defaultValue => 'PBtmpl0000000000000060',
|
||||||
);
|
tab => "display",
|
||||||
|
label => [1079,'Asset_Wobject'],
|
||||||
|
hoverHelp => ['1079 description','Asset_Wobject'],
|
||||||
our @ISA = qw(WebGUI::Asset);
|
namespace => 'style'
|
||||||
|
);
|
||||||
|
property mobileStyleTemplateId => (
|
||||||
|
fieldType => 'template',
|
||||||
|
noFormPost => sub { return !$_[0]->session->setting->get('useMobileStyle'); },
|
||||||
|
defaultValue => 'PBtmpl0000000000000060',
|
||||||
|
tab => 'display',
|
||||||
|
label => ['mobileStyleTemplateId label','Asset_Wobject'],
|
||||||
|
hoverHelp => ['mobileStyleTemplateId description','Asset_Wobject'],
|
||||||
|
namespace => 'style',
|
||||||
|
);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,15 +73,15 @@ sub addChild {
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
|
|
||||||
# Check if it is possible to add a child to this asset. If not add it as a sibling of this asset.
|
# Check if it is possible to add a child to this asset. If not add it as a sibling of this asset.
|
||||||
if (length($self->get("lineage")) >= 252) {
|
if (length($self->lineage) >= 252) {
|
||||||
$session->errorHandler->warn('Tried to add child to asset "'.$self->getId.'" which is already on the deepest level. Adding it as a sibling instead.');
|
$session->errorHandler->warn('Tried to add child to asset "'.$self->getId.'" which is already on the deepest level. Adding it as a sibling instead.');
|
||||||
return $self->getParent->addChild($properties, $id, $now, $options);
|
return $self->getParent->addChild($properties, $id, $now, $options);
|
||||||
}
|
}
|
||||||
my $lineage = $self->get("lineage").$self->getNextChildRank;
|
my $lineage = $self->lineage.$self->getNextChildRank;
|
||||||
$self->{_hasChildren} = 1;
|
$self->{_hasChildren} = 1;
|
||||||
$session->db->beginTransaction;
|
$session->db->beginTransaction;
|
||||||
$session->db->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (?,?,?,?,?,?,'published')",
|
$session->db->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (?,?,?,?,?,?,'published')",
|
||||||
[$id,$self->getId,$lineage,$now,$session->user->userId,$properties->{className}]);
|
[$id, $self->getId, $lineage, $now, $session->user->userId, $properties->{className}]);
|
||||||
$session->db->commit;
|
$session->db->commit;
|
||||||
$properties->{assetId} = $id;
|
$properties->{assetId} = $id;
|
||||||
$properties->{parentId} = $self->getId;
|
$properties->{parentId} = $self->getId;
|
||||||
|
|
@ -874,10 +874,10 @@ sub setParent {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newParent = shift;
|
my $newParent = shift;
|
||||||
return 0 unless (defined $newParent); # can't move it if a parent object doesn't exist
|
return 0 unless (defined $newParent); # can't move it if a parent object doesn't exist
|
||||||
return 0 if ($newParent->getId eq $self->get("parentId")); # don't move it to where it already is
|
return 0 if ($newParent->getId eq $self->parentId); # don't move it to where it already is
|
||||||
return 0 if ($newParent->getId eq $self->getId); # don't move it to itself
|
return 0 if ($newParent->getId eq $self->getId); # don't move it to itself
|
||||||
my $oldLineage = $self->get("lineage");
|
my $oldLineage = $self->lineage;
|
||||||
my $lineage = $newParent->get("lineage").$newParent->getNextChildRank;
|
my $lineage = $newParent->lineage.$newParent->getNextChildRank;
|
||||||
return 0 if ($lineage =~ m/^$oldLineage/); # can't move it to its own child
|
return 0 if ($lineage =~ m/^$oldLineage/); # can't move it to its own child
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
$self->session->db->write("update asset set parentId=? where assetId=?",
|
$self->session->db->write("update asset set parentId=? where assetId=?",
|
||||||
|
|
@ -921,7 +921,7 @@ sub setRank {
|
||||||
my $siblings = $self->getLineage(["siblings"],{returnObjects=>1, invertTree=>$reverse});
|
my $siblings = $self->getLineage(["siblings"],{returnObjects=>1, invertTree=>$reverse});
|
||||||
|
|
||||||
my $temp = substr($self->session->id->generate(),0,6);
|
my $temp = substr($self->session->id->generate(),0,6);
|
||||||
my $previous = $self->get("lineage");
|
my $previous = $self->lineage;
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
$outputSub->('moving %s aside', $self->getTitle);
|
$outputSub->('moving %s aside', $self->getTitle);
|
||||||
$self->cascadeLineage($temp);
|
$self->cascadeLineage($temp);
|
||||||
|
|
@ -929,7 +929,7 @@ sub setRank {
|
||||||
if (isBetween($sibling->getRank, $newRank, $currentRank)) {
|
if (isBetween($sibling->getRank, $newRank, $currentRank)) {
|
||||||
$outputSub->('moving %s', $sibling->getTitle);
|
$outputSub->('moving %s', $sibling->getTitle);
|
||||||
$sibling->cascadeLineage($previous);
|
$sibling->cascadeLineage($previous);
|
||||||
$previous = $sibling->get("lineage");
|
$previous = $sibling->lineage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$outputSub->('moving %s back', $self->getTitle);
|
$outputSub->('moving %s back', $self->getTitle);
|
||||||
|
|
@ -957,7 +957,7 @@ no in the objects.
|
||||||
sub swapRank {
|
sub swapRank {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $second = shift;
|
my $second = shift;
|
||||||
my $first = shift || $self->get("lineage");
|
my $first = shift || $self->lineage;
|
||||||
my $outputSub = shift || sub {};
|
my $outputSub = shift || sub {};
|
||||||
my $temp = substr($self->session->id->generate(),0,6); # need a temp in order to do the swap
|
my $temp = substr($self->session->id->generate(),0,6); # need a temp in order to do the swap
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue