migrating asset.pm
This commit is contained in:
parent
6be6aee8c1
commit
f7db5d58aa
2 changed files with 10 additions and 81 deletions
|
|
@ -35,6 +35,8 @@ You must migrate your asset to use the new WebGUI::Definition::Asset class inste
|
||||||
|
|
||||||
7) The properties attribute must be an array reference of properties. No more Tie::IxHash.
|
7) The properties attribute must be an array reference of properties. No more Tie::IxHash.
|
||||||
|
|
||||||
|
8) The autoGenerateForms has been removed. All edit forms are autogenerated in WebGUI 8.
|
||||||
|
|
||||||
Here's an example.
|
Here's an example.
|
||||||
|
|
||||||
use WebGUI::Definition::Asset (
|
use WebGUI::Definition::Asset (
|
||||||
|
|
@ -69,4 +71,6 @@ assetDbProperties - Simply instantiate the asset if you want it's properties.
|
||||||
|
|
||||||
assetExists - Simply instantiate the asset if you want to know if it exists.
|
assetExists - Simply instantiate the asset if you want to know if it exists.
|
||||||
|
|
||||||
|
getValue - Use get() or the individual property accessors instead.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -678,38 +678,6 @@ sub fixUrlFromParent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 get ( [propertyName] )
|
|
||||||
|
|
||||||
Returns a reference to a list of properties (or specified property) of an Asset.
|
|
||||||
|
|
||||||
If C<propertyName> is omitted, it will return a safe copy of the entire property hash.
|
|
||||||
|
|
||||||
=head3 propertyName
|
|
||||||
|
|
||||||
Any of the values associated with the properties of an Asset. Default choices are "title", "menutTitle",
|
|
||||||
"synopsis", "url", "groupIdEdit", "groupIdView", "ownerUserId", "keywords", and "assetSize".
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub get {
|
|
||||||
my $self = shift;
|
|
||||||
my $propertyName = shift;
|
|
||||||
if (defined $propertyName) {
|
|
||||||
if ($propertyName eq "keywords") {
|
|
||||||
return WebGUI::Keyword->new($self->session)->getKeywordsForAsset({asset => $self});
|
|
||||||
}
|
|
||||||
return $self->{_properties}{$propertyName};
|
|
||||||
}
|
|
||||||
my %copyOfHashRef = %{$self->{_properties}};
|
|
||||||
my $keywords = WebGUI::Keyword->new($self->session)->getKeywordsForAsset({asset => $self});
|
|
||||||
if( $keywords ne '' ) { $copyOfHashRef{ keywords } = $keywords ; }
|
|
||||||
return \%copyOfHashRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getAdminConsole ( )
|
=head2 getAdminConsole ( )
|
||||||
|
|
@ -863,9 +831,7 @@ sub getEditForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
# build the definition to the generate form
|
# build the definition to the generate form
|
||||||
my @definitions = reverse @{$self->definition($session)};
|
my @properties = (
|
||||||
tie my %baseProperties, 'Tie::IxHash';
|
|
||||||
%baseProperties = (
|
|
||||||
assetId => {
|
assetId => {
|
||||||
fieldType => "guid",
|
fieldType => "guid",
|
||||||
label => $i18n->get("asset id"),
|
label => $i18n->get("asset id"),
|
||||||
|
|
@ -887,15 +853,12 @@ sub getEditForm {
|
||||||
value => $self->get('keywords'),
|
value => $self->get('keywords'),
|
||||||
fieldType => 'keywords',
|
fieldType => 'keywords',
|
||||||
tab => 'meta',
|
tab => 'meta',
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
unshift @definitions, {
|
foreach my $property ($self->getProperties) {
|
||||||
autoGenerateForms => 1,
|
push @properties, $property => $self->getProperty($property);
|
||||||
properties => \%baseProperties
|
}
|
||||||
};
|
|
||||||
|
|
||||||
# extend the definition with metadata
|
|
||||||
tie my %extendedProperties, 'Tie::IxHash';
|
|
||||||
if ($session->setting->get("metaDataEnabled")) {
|
if ($session->setting->get("metaDataEnabled")) {
|
||||||
my $meta = $self->getMetaDataFields();
|
my $meta = $self->getMetaDataFields();
|
||||||
foreach my $field (keys %$meta) {
|
foreach my $field (keys %$meta) {
|
||||||
|
|
@ -906,7 +869,7 @@ sub getEditForm {
|
||||||
if("\l$fieldType" eq "selectBox") {
|
if("\l$fieldType" eq "selectBox") {
|
||||||
$options = "|" . $i18n->get("Select") . "\n" . $options;
|
$options = "|" . $i18n->get("Select") . "\n" . $options;
|
||||||
}
|
}
|
||||||
$extendedProperties{"metadata_".$meta->{$field}{fieldId}} = {
|
push @properties, "metadata_".$meta->{$field}{fieldId} => {
|
||||||
tab => "meta",
|
tab => "meta",
|
||||||
label => $meta->{$field}{fieldName},
|
label => $meta->{$field}{fieldName},
|
||||||
uiLevel => 5,
|
uiLevel => 5,
|
||||||
|
|
@ -928,7 +891,6 @@ sub getEditForm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @definitions, {
|
push @definitions, {
|
||||||
autoGenerateForms => 1,
|
|
||||||
properties => \%extendedProperties
|
properties => \%extendedProperties
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -936,9 +898,6 @@ sub getEditForm {
|
||||||
foreach my $definition (@definitions) {
|
foreach my $definition (@definitions) {
|
||||||
my $properties = $definition->{properties};
|
my $properties = $definition->{properties};
|
||||||
|
|
||||||
# depricated...by WebGUI 8 they all must autogen forms
|
|
||||||
next unless ($definition->{autoGenerateForms});
|
|
||||||
|
|
||||||
foreach my $fieldName (keys %{$properties}) {
|
foreach my $fieldName (keys %{$properties}) {
|
||||||
my %fieldHash = %{$properties->{$fieldName}};
|
my %fieldHash = %{$properties->{$fieldName}};
|
||||||
my %params = (name => $fieldName, value => $self->getValue($fieldName));
|
my %params = (name => $fieldName, value => $self->getValue($fieldName));
|
||||||
|
|
@ -1516,40 +1475,6 @@ sub getContentLastModified {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 getValue ( key )
|
|
||||||
|
|
||||||
Tries to look up C<key> in the asset object's property cache. If it can't find it in there, then it
|
|
||||||
tries to look it up in the definition sub for the asset.
|
|
||||||
|
|
||||||
Unlike get, it will not return the whole property hash if you omit the key.
|
|
||||||
|
|
||||||
=head3 key
|
|
||||||
|
|
||||||
An asset property name, or a propertyDefinition.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub getValue {
|
|
||||||
my $self = shift;
|
|
||||||
my $key = shift;
|
|
||||||
if (defined $key) {
|
|
||||||
my $storedValue = $self->get($key);
|
|
||||||
return $storedValue if (defined $storedValue);
|
|
||||||
unless (exists $self->{_propertyDefinitions}) { # check to see if the definitions have been merged and cached
|
|
||||||
my %properties;
|
|
||||||
foreach my $definition (@{$self->definition($self->session)}) {
|
|
||||||
%properties = (%properties, %{$definition->{properties}});
|
|
||||||
}
|
|
||||||
$self->{_propertyDefinitions} = \%properties;
|
|
||||||
}
|
|
||||||
return $self->{_propertyDefinitions}{$key}{defaultValue};
|
|
||||||
}
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 indexContent ( )
|
=head2 indexContent ( )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue