removed last remnants of old definition

This commit is contained in:
JT Smith 2009-10-22 17:00:45 -05:00
parent 7b0fcd9009
commit 3938f9ff0d
11 changed files with 121 additions and 309 deletions

View file

@ -47,7 +47,6 @@ use WebGUI::Definition::Asset (
hoverHelp =>['99 description','Asset'],
fieldType =>'text',
defaultValue =>'Untitled',
filter =>'fixTitle',
},
menuTitle=>{
tab =>"properties",
@ -55,7 +54,6 @@ use WebGUI::Definition::Asset (
hoverHelp =>['411 description','Asset'],
uiLevel =>1,
fieldType =>'text',
filter =>'fixTitle',
defaultValue =>'Untitled',
},
url=>{
@ -64,8 +62,7 @@ use WebGUI::Definition::Asset (
hoverHelp =>['104 description','Asset'],
uiLevel =>3,
fieldType =>'text',
defaultValue =>'',
filter =>'fixUrl',
defaultValue => sub { return $_[0]->getId; },
},
isHidden=>{
tab =>"display",
@ -85,11 +82,7 @@ use WebGUI::Definition::Asset (
},
encryptPage=>{
fieldType => 'yesNo',
noFormPost =>
sub {
my $self = shift;
return $self->session->config->get("sslEnabled");
},
noFormPost => sub { return $_[0]->session->config->get("sslEnabled"); },
tab => "security",
label => ['encrypt page','Asset'],
hoverHelp => ['encrypt page description','Asset'],
@ -102,7 +95,6 @@ use WebGUI::Definition::Asset (
hoverHelp =>['108 description','Asset'],
uiLevel =>6,
fieldType =>'user',
filter =>'fixId',
defaultValue =>'3',
},
groupIdView=>{
@ -111,7 +103,6 @@ use WebGUI::Definition::Asset (
hoverHelp =>['872 description','Asset'],
uiLevel =>6,
fieldType =>'group',
filter =>'fixId',
defaultValue =>'7',
},
groupIdEdit=>{
@ -121,7 +112,6 @@ use WebGUI::Definition::Asset (
hoverHelp =>['871 description','Asset'],
uiLevel =>6,
fieldType =>'group',
filter =>'fixId',
defaultValue =>'4',
},
synopsis=>{
@ -502,58 +492,7 @@ sub DESTROY {
#-------------------------------------------------------------------
=head2 fixId ( id, fieldName )
Returns the default Id for a field if we get an invalid Id, otherwise returns the id passed in. An valid id either looks like a GUID or is an integer.
=head3 id
The id to check.
=head3 fieldName
The name of the property we're checking. This is used to retrieve whatever the default is set to in the definition.
=cut
sub fixId {
my $self = shift;
my $id = shift;
my $field = shift;
if ($id =~ m/\A \d{1,22} \z/xms || $id =~ m/\A [A-Za-z0-9\-\_]{22} \z/xms) {
return $id;
}
return $self->getValue($field);
}
#-------------------------------------------------------------------
=head2 fixTitle ( string )
Fixes a title by eliminating HTML from it.
=head3 string
Any text string. Most likely will have been the Asset's name or title. If
no string is supplied, then it will fetch the default title for the asset,
or the word Untitled.
=cut
sub fixTitle {
my $self = shift;
my $string = shift;
if (lc($string) eq "untitled" || $string eq "") {
$string = $self->getValue("title") || 'Untitled';
}
return WebGUI::HTML::filter($string, 'all');
}
#-------------------------------------------------------------------
=head2 fixUrl ( url )
=head2 fixUrl ( [value] )
Returns a URL, removing invalid characters and making it unique by
adding a digit to the end if necessary. URLs are not allowed to be
@ -567,7 +506,7 @@ Assets have a maximum length of 250 characters. Any URL longer than
URLs will be passed through $session->url->urlize to make them WebGUI compliant.
That includes any languages specific constraints set up in the default language pack.
=head3 url
=head3 value
Any text string. Most likely will have been the Asset's name or title. If the string is not passed
in, then a url will be constructed from
@ -580,14 +519,19 @@ sub fixUrl {
# build a URL from the parent
unless ($url) {
$url = $self->getParent->get("url");
$url = $self->getParent->url;
$url =~ s/(.*)\..*/$1/;
$url .= '/'.$self->getValue("menuTitle");
$url .= '/'.$self->menuTitle;
}
# if we're inheriting the URL from our parent, set that appropriately
if($self->get('inheritUrlFromParent')) {
$url = $self->fixUrlFromParent($url);
if ($self->inheritUrlFromParent) {
# if we're inheriting the URL from our parent, set that appropriately
my @parts = split(m{/}, $url);
# don't do anything unless we need to
if($url ne $self->getParent->get('url') . '/' . $parts[-1]) {
$url = $self->getParent->get('url') . '/' . $parts[-1];
}
}
$url = $self->session->url->urlize($url);
@ -650,35 +594,6 @@ sub fixUrl {
}
#-------------------------------------------------------------------
=head2 fixUrlFromParent ( url )
URLs will be passed through $session->url->urlize to make them WebGUI compliant.
That includes any languages specific constraints set up in the default language pack.
=head3 url
Any text string.
=cut
sub fixUrlFromParent {
my $self = shift;
my $url = shift;
# if we're inheriting the URL from our parent, set that appropriately
my @parts = split(m{/}, $url);
# don't do anything unless we need to
if($url ne $self->getParent->get('url') . '/' . $parts[-1]) {
$url = $self->getParent->get('url') . '/' . $parts[-1];
}
return $url;
}
#-------------------------------------------------------------------
=head2 getAdminConsole ( )
@ -1261,10 +1176,11 @@ Returns the title of this asset. If it's not specified or it's "Untitled" then t
sub getTitle {
my $self = shift;
if ($self->get("title") eq "" || lc($self->get("title")) eq "untitled") {
my $title = $self->title;
if ($title eq "" || lc($title) eq "untitled") {
return $self->getName;
}
return $self->get("title");
return $title;
}
@ -1431,9 +1347,9 @@ Name value pairs to add to the URL in the form of:
sub getUrl {
my $self = shift;
my $params = shift;
my $url = $self->get("url");
my $url = $self->url;
$url = $self->session->url->gateway($url,$params);
if ($self->get("encryptPage")) {
if ($self->encryptPage) {
$url = $self->session->url->getSiteURL().$url;
$url =~ s/http:/https:/;
}
@ -1526,6 +1442,29 @@ sub logView {
#-------------------------------------------------------------------
=head2 menuTitle ( [value] )
Returns the menuTitle of the asset, which is used in navigations.
=head3 value
If specified this value will be used to set the title after it goes through some validation checking.
=cut
sub menuTitle {
my ($self, $title) = @_;
if (defined $title) {
if ($title eq "") {
$title = $self->title;
}
$title = WebGUI::HTML::filter($title, 'all');
}
return $self->next::method($title);
}
#-------------------------------------------------------------------
=head2 new ( session, assetId [, className, revisionDate ] )
Constructor. This does not create an asset.
@ -2231,6 +2170,30 @@ sub setSize {
}
#-------------------------------------------------------------------
=head2 title ( [value] )
Returns the title of the asset.
=head3 value
If specified this value will be used to set the title after it goes through some validation checking.
=cut
sub title {
my ($self, $title) = @_;
if (defined $title) {
if ($title eq "") {
$title = 'Untitled';
}
$title = WebGUI::HTML::filter($title, 'all');
}
return $self->next::method($title);
}
#-------------------------------------------------------------------
=head2 toggleToolbar ( )
@ -2279,7 +2242,7 @@ sub update {
##If inheritUrlFromParent was sent, and it is true, then muck with the url
##The URL may have been sent too, so use it or the current Asset's URL.
if (exists $properties->{inheritUrlFromParent} and $properties->{inheritUrlFromParent}) {
$properties->{'url'} = $self->fixUrlFromParent($properties->{'url'} || $self->get('url'));
$properties->{'url'} = $self->url($properties->{'url'} || $self->url);
}
# check the definition of all properties against what was given to us
@ -2343,6 +2306,27 @@ sub update {
$self->purgeCache;
}
#-------------------------------------------------------------------
=head2 url ( [ value ] )
Returns the asset's url without any site specific prefixes. If you want a browser friendly url see the getUrl() method.
=head3 value
The new value to set the URL to.
=cut
sub url {
my ($self, $url) = @_;
if (defined $url) {
$url = $self->fixUrl($url);
}
return $self->next::method($url);
}
#-------------------------------------------------------------------

View file

@ -88,7 +88,6 @@ sub definition {
tab=>"display",
label=>$i18n->get(1073),
hoverHelp=>$i18n->get('1073 description'),
filter=>'fixId',
namespace=>'style'
},
printableStyleTemplateId=>{
@ -97,7 +96,6 @@ sub definition {
tab=>"display",
label=>$i18n->get(1079),
hoverHelp=>$i18n->get('1079 description'),
filter=>'fixId',
namespace=>'style'
},
mobileStyleTemplateId => {
@ -106,7 +104,6 @@ sub definition {
tab => 'display',
label => $i18n->get('mobileStyleTemplateId label'),
hoverHelp => $i18n->get('mobileStyleTemplateId description'),
filter => 'fixId',
namespace => 'style',
},
);

View file

@ -905,7 +905,6 @@ sub definition {
hoverHelp=>$i18n->get('group to edit hoverhelp'),
uiLevel=>6,
fieldType=>'group',
filter=>'fixId',
defaultValue=>$groupIdEdit, # groupToEditPost should default to groupIdEdit
},
postReceivedTemplateId =>{

View file

@ -59,7 +59,6 @@ sub definition {
fieldType => 'template',
label => $i18n->get('template'),
hoverHelp => $i18n->get('template help'),
filter => 'fixId',
namespace => 'StoryTopic',
defaultValue => 'A16v-YjWAShXWvSACsraeg',
},
@ -68,7 +67,6 @@ sub definition {
fieldType => 'template',
label => $i18n->get('story template'),
hoverHelp => $i18n->get('story template help'),
filter => 'fixId',
namespace => 'Story',
defaultValue => 'TbDcVLbbznPi0I0rxQf2CQ',
},

View file

@ -140,14 +140,14 @@ sub www_editBranch {
-name=>"displayTitle",
-label=>$i18n2->get(174),
-hoverHelp=>$i18n2->get('174 description'),
-value=>$self->getValue("displayTitle"),
-value=>$self->get("displayTitle"),
-uiLevel=>5,
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_displayTitle"})
);
$tabform->getTab("display")->template(
-name=>"styleTemplateId",
-label=>$i18n2->get(1073),
-value=>$self->getValue("styleTemplateId"),
-value=>$self->get("styleTemplateId"),
-hoverHelp=>$i18n2->get('1073 description'),
-namespace=>'style',
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_styleTemplateId"})
@ -156,7 +156,7 @@ sub www_editBranch {
-name=>"printableStyleTemplateId",
-label=>$i18n2->get(1079),
-hoverHelp=>$i18n2->get('1079 description'),
-value=>$self->getValue("printableStyleTemplateId"),
-value=>$self->get("printableStyleTemplateId"),
-namespace=>'style',
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_printableStyleTemplateId"})
);
@ -165,7 +165,7 @@ sub www_editBranch {
name => 'mobileStyleTemplateId',
label => $i18n2->get('mobileStyleTemplateId label'),
hoverHelp => $i18n2->get('mobileStyleTemplateId description'),
value => $self->getValue('mobileStyleTemplateId'),
value => $self->get('mobileStyleTemplateId'),
namespace => 'style',
subtext => '<br />' . $i18n->get('change') . q{ }
. WebGUI::Form::yesNo($self->session,{name=>"change_mobileStyleTemplateId"}),

View file

@ -284,7 +284,7 @@ sub www_deployPackage {
my $packageMasterAssetId = $self->session->form->param("assetId");
if (defined $packageMasterAssetId) {
my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($self->session, $packageMasterAssetId);
unless ($packageMasterAsset->getValue('isPackage')) { #only deploy packages
unless ($packageMasterAsset->get('isPackage')) { #only deploy packages
$self->session->errorHandler->security('deploy an asset as a package which was not set as a package.');
return undef;
}

View file

@ -197,8 +197,8 @@ sub purge {
$outputSub->($i18n->get('Clearing asset tables'));
$session->db->beginTransaction;
$session->db->write("delete from metaData_values where assetId = ?",[$self->getId]);
foreach my $definition (@{$self->definition($session)}) {
$session->db->write("delete from ".$definition->{tableName}." where assetId=?", [$self->getId]);
foreach my $table ($self->getTables) {
$session->db->write("delete from ".$table." where assetId=?", [$self->getId]);
}
$session->db->write("delete from asset where assetId=?", [$self->getId]);
$session->db->commit;

View file

@ -121,22 +121,19 @@ sub addRevision {
]);
my %defaults = ();
foreach my $definition (@{$self->definition($self->session)}) {
# get the default values of each property
foreach my $property ($self->getProperties) {
my $defintion = $self->getProperty($property);
$defaults{$property} = $definition->{defaultValue};
if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{serialize}) {
$defaults{$property} = $defaults{$property}->[0];
}
}
# get the default values of each property
foreach my $property (keys %{$definition->{properties}}) {
$defaults{$property} = $definition->{properties}{$property}{defaultValue};
if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{properties}{$property}{serialize}) {
$defaults{$property} = $defaults{$property}->[0];
}
}
# prime the tables
unless ($definition->{tableName} eq "assetData") {
$self->session->db->write(
"insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)",
[$self->getId, $now]
);
# prime the tables
foreach my $table ($self->getTables) {
unless ($table eq "assetData") {
$self->session->db->write( "insert into ".$table." (assetId,revisionDate) values (?,?)", [$self->getId, $now]);
}
}
$self->session->db->commit;
@ -356,18 +353,20 @@ Deletes a revision of an asset. If it's the last revision, it purges the asset a
sub purgeRevision {
my $self = shift;
if ($self->getRevisionCount > 1) {
$self->session->db->beginTransaction;
foreach my $definition (@{$self->definition($self->session)}) {
$self->session->db->write("delete from ".$definition->{tableName}." where assetId=? and revisionDate=?",[$self->getId, $self->get("revisionDate")]);
}
my ($count) = $self->session->db->quickArray("select count(*) from assetData where assetId=? and status='pending'",[$self->getId]);
my $db = $self->session->db;
$db->beginTransaction;
foreach my $table ($self->getTables) {
$db->write("delete from ".$table." where assetId=? and revisionDate=?",[$self->getId, $self->get("revisionDate")]);
}
my $count = $db->quickScalar("select count(*) from assetData where assetId=? and status='pending'",[$self->getId]);
if ($count < 1) {
$self->session->db->write("update asset set isLockedBy=null where assetId=?",[$self->getId]);
$db->write("update asset set isLockedBy=null where assetId=?",[$self->getId]);
}
$self->session->db->commit;
$db->commit;
$self->purgeCache;
$self->updateHistory("purged revision ".$self->get("revisionDate"));
} else {
}
else {
$self->purge;
}
}