diff --git a/lib/WebGUI/Asset/MapPoint.pm b/lib/WebGUI/Asset/MapPoint.pm
index 55e105148..99fc4ead6 100644
--- a/lib/WebGUI/Asset/MapPoint.pm
+++ b/lib/WebGUI/Asset/MapPoint.pm
@@ -16,12 +16,113 @@ package WebGUI::Asset::MapPoint;
use strict;
use Tie::IxHash;
-use base 'WebGUI::Asset';
-use WebGUI::Utility;
+use WebGUI::Definition::Asset;
+extends 'WebGUI::Asset';
+aspect assetName => ['assetName', 'Asset_MapPoint'];
+aspect icon => 'MapPoint.gif';
+aspect tableName => 'MapPoint';
+property latitude => (
+ tab => "properties",
+ fieldType => "float",
+ label => ["latitude label", 'Asset_MapPoint'],
+ hoverHelp => ["latitude description", 'Asset_MapPoint'],
+ );
+property longitude => (
+ tab => "properties",
+ fieldType => "float",
+ label => ["longitude label", 'Asset_MapPoint'],
+ hoverHelp => ["longitude description", 'Asset_MapPoint'],
+ );
+property website => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["website label", 'Asset_MapPoint'],
+ hoverHelp => ["website description", 'Asset_MapPoint'],
+ );
+property address1 => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["address1 label", 'Asset_MapPoint'],
+ hoverHelp => ["address1 description", 'Asset_MapPoint'],
+ );
+property address2 => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["address2 label", 'Asset_MapPoint'],
+ hoverHelp => ["address2 description", 'Asset_MapPoint'],
+ );
+property city => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["city label", 'Asset_MapPoint'],
+ hoverHelp => ["city description", 'Asset_MapPoint'],
+ );
+property state => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["state label", 'Asset_MapPoint'],
+ hoverHelp => ["state description", 'Asset_MapPoint'],
+ );
+property zipCode => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["zipCode label", 'Asset_MapPoint'],
+ hoverHelp => ["zipCode description", 'Asset_MapPoint'],
+ );
+property country => (
+ tab => "properties",
+ fieldType => "country",
+ label => ["country label", 'Asset_MapPoint'],
+ hoverHelp => ["country description", 'Asset_MapPoint'],
+ );
+property phone => (
+ tab => "properties",
+ fieldType => "phone",
+ label => ["phone label", 'Asset_MapPoint'],
+ hoverHelp => ["phone description", 'Asset_MapPoint'],
+ );
+property fax => (
+ tab => "properties",
+ fieldType => "phone",
+ label => ["fax label", 'Asset_MapPoint'],
+ hoverHelp => ["fax description", 'Asset_MapPoint'],
+ );
+property email => (
+ tab => "properties",
+ fieldType => "email",
+ label => ["email label", 'Asset_MapPoint'],
+ hoverHelp => ["email description", 'Asset_MapPoint'],
+ );
+property storageIdPhoto => (
+ tab => "properties",
+ fieldType => "image",
+ forceImageOnly => 1,
+ label => ["storageIdPhoto label", 'Asset_MapPoint'],
+ hoverHelp => ["storageIdPhoto description", 'Asset_MapPoint'],
+ noFormPost => 1,
+ );
+property userDefined1 => (
+ fieldType => "hidden",
+ noFormPost => 1,
+ );
+property userDefined2 => (
+ fieldType => "hidden",
+ noFormPost => 1,
+ );
+property userDefined3 => (
+ fieldType => "hidden",
+ noFormPost => 1,
+ );
+property userDefined4 => (
+ fieldType => "hidden",
+ noFormPost => 1,
+ );
+property userDefined5 => (
+ fieldType => "hidden",
+ noFormPost => 1,
+ );
-# To get an installer for your wobject, add the Installable AssetAspect
-# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more
-# details
+use WebGUI::Utility;
=head1 NAME
@@ -63,107 +164,8 @@ sub definition {
my $definition = shift;
my $i18n = WebGUI::International->new( $session, "Asset_MapPoint" );
tie my %properties, 'Tie::IxHash', (
- latitude => {
- tab => "properties",
- fieldType => "float",
- label => $i18n->get("latitude label"),
- hoverHelp => $i18n->get("latitude description"),
- },
- longitude => {
- tab => "properties",
- fieldType => "float",
- label => $i18n->get("longitude label"),
- hoverHelp => $i18n->get("longitude description"),
- },
- website => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("website label"),
- hoverHelp => $i18n->get("website description"),
- },
- address1 => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("address1 label"),
- hoverHelp => $i18n->get("address1 description"),
- },
- address2 => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("address2 label"),
- hoverHelp => $i18n->get("address2 description"),
- },
- city => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("city label"),
- hoverHelp => $i18n->get("city description"),
- },
- state => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("state label"),
- hoverHelp => $i18n->get("state description"),
- },
- zipCode => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("zipCode label"),
- hoverHelp => $i18n->get("zipCode description"),
- },
- country => {
- tab => "properties",
- fieldType => "country",
- label => $i18n->get("country label"),
- hoverHelp => $i18n->get("country description"),
- },
- phone => {
- tab => "properties",
- fieldType => "phone",
- label => $i18n->get("phone label"),
- hoverHelp => $i18n->get("phone description"),
- },
- fax => {
- tab => "properties",
- fieldType => "phone",
- label => $i18n->get("fax label"),
- hoverHelp => $i18n->get("fax description"),
- },
- email => {
- tab => "properties",
- fieldType => "email",
- label => $i18n->get("email label"),
- hoverHelp => $i18n->get("email description"),
- },
- storageIdPhoto => {
- tab => "properties",
- fieldType => "image",
- forceImageOnly => 1,
- label => $i18n->get("storageIdPhoto label"),
- hoverHelp => $i18n->get("storageIdPhoto description"),
- noFormPost => 1,
- },
- userDefined1 => {
- fieldType => "hidden",
- },
- userDefined2 => {
- fieldType => "hidden",
- },
- userDefined3 => {
- fieldType => "hidden",
- },
- userDefined4 => {
- fieldType => "hidden",
- },
- userDefined5 => {
- fieldType => "hidden",
- },
);
push @{$definition}, {
- assetName => $i18n->get('assetName'),
- icon => 'MapPoint.gif',
- autoGenerateForms => 1,
- tableName => 'MapPoint',
className => 'WebGUI::Asset::MapPoint',
properties => \%properties,
};
@@ -182,7 +184,7 @@ group to edit the parent Map are allowed to edit MapPoint.
sub canEdit {
my $self = shift;
my $userId = shift || $self->session->user->userId;
- return 1 if $userId eq $self->get('ownerUserId');
+ return 1 if $userId eq $self->ownerUserId;
return $self->SUPER::canEdit( $userId );
}
@@ -196,7 +198,7 @@ Get the workflowId to commit this MapPoint
sub getAutoCommitWorkflowId {
my ( $self ) = @_;
- return $self->getParent->get('workflowIdPoint');
+ return $self->getParent->workflowIdPoint;
}
#-------------------------------------------------------------------
@@ -229,7 +231,7 @@ sub getMapInfo {
$var->{ assetId } = $self->getId;
my @keys = qw( latitude longitude title );
for my $key ( @keys ) {
- $var->{ $key } = $self->get( $key );
+ $var->{ $key } = $self->$key;
}
# Get permissions
@@ -287,11 +289,11 @@ sub getTemplateVarsEditForm {
} )
. WebGUI::Form::hidden( $session, {
name => 'latitude',
- value => $self->get('latitude'),
+ value => $self->latitude,
} )
. WebGUI::Form::hidden( $session, {
name => 'longitude',
- value => $self->get('longitude'),
+ value => $self->longitude,
} )
;
$var->{ form_footer } = WebGUI::Form::formFooter( $session );
@@ -314,20 +316,20 @@ sub getTemplateVarsEditForm {
$var->{ "form_title" }
= WebGUI::Form::text( $session, {
name => "title",
- value => $self->get("title"),
+ value => $self->title,
} );
$var->{ "form_synopsis" }
= WebGUI::Form::textarea( $session, {
name => "synopsis",
- value => $self->get("synopsis"),
+ value => $self->synopsis,
resizable => 0,
} );
# Fix storageIdPhoto because scripts do not get executed in ajax requests
$var->{ "form_storageIdPhoto" }
= '';
- if ( $self->get('storageIdPhoto') ) {
- my $storage = WebGUI::Storage->get( $self->session, $self->get('storageIdPhoto') );
+ if ( $self->storageIdPhoto ) {
+ my $storage = WebGUI::Storage->get( $self->session, $self->storageIdPhoto );
$var->{ "currentPhoto" }
= sprintf '
', $storage->getUrl($storage->getFiles->[0]);
}
@@ -371,8 +373,8 @@ sub processAjaxEditForm {
# Photo magic
if ( $form->get('storageIdPhoto') ) {
my $storage;
- if ( $self->get('storageIdPhoto') ) {
- $storage = WebGUI::Storage->get( $session, $self->get('storageIdPhoto') );
+ if ( $self->storageIdPhoto ) {
+ $storage = WebGUI::Storage->get( $session, $self->storageIdPhoto );
$storage->deleteFile( $storage->getFiles->[0] );
}
else {
diff --git a/lib/WebGUI/Asset/Wobject/Map.pm b/lib/WebGUI/Asset/Wobject/Map.pm
index b8f0c273d..ca9a93f03 100644
--- a/lib/WebGUI/Asset/Wobject/Map.pm
+++ b/lib/WebGUI/Asset/Wobject/Map.pm
@@ -17,121 +17,104 @@ use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
use HTML::Entities qw(encode_entities);
-use base 'WebGUI::Asset::Wobject';
-
-# To get an installer for your wobject, add the Installable AssetAspect
-# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more
-# details
-
-#-------------------------------------------------------------------
-
-=head2 definition ( )
-
-Define asset properties
-
-=cut
-
-sub definition {
- my $class = shift;
- my $session = shift;
- my $definition = shift;
- my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
-
+use WebGUI::Definition::Asset;
+extends 'WebGUI::Asset::Wobject';
+aspect assetName => ['assetName', 'Asset_Map'];
+aspect icon => 'maps.png';
+aspect tableName => 'Map';
+property groupIdAddPoint => (
+ tab => "security",
+ fieldType => "group",
+ label => ["groupIdAddPoint label", 'Asset_Map'],
+ hoverHelp => ["groupIdAddPoint description", 'Asset_Map'],
+ default => '2', # Registered users
+ );
+property mapApiKey => (
+ tab => "properties",
+ fieldType => "text",
+ label => ["mapApiKey label", 'Asset_Map'],
+ hoverHelp => ["mapApiKey description", 'Asset_Map'],
+ builder => '_mapApiKey_builder',
+ lazy => 1,
+ subtext =>
+ );
+sub _mapApiKey_builder {
+ my $self = shift;
+ return $self->getDefaultApiKey($self->session);
+}
+sub _mapApiKey_subtext {
+ my $self = shift;
+ my $session = $self->session;
+ my $i18n = WebGUI::International->new($session, 'Asset_Map');
my $googleApiKeyUrl = 'http://code.google.com/apis/maps/signup.html';
my $googleApiKeyLink
= q{%s};
-
- tie my %properties, 'Tie::IxHash', (
- groupIdAddPoint => {
- tab => "security",
- fieldType => "group",
- label => $i18n->get("groupIdAddPoint label"),
- hoverHelp => $i18n->get("groupIdAddPoint description"),
- defaultValue=> '2', # Registered users
- },
- mapApiKey => {
- tab => "properties",
- fieldType => "text",
- label => $i18n->get("mapApiKey label"),
- hoverHelp => $i18n->get("mapApiKey description"),
- defaultValue=> $class->getDefaultApiKey($session),
- subtext => sprintf($googleApiKeyLink, ($googleApiKeyUrl)x2, $i18n->get('mapApiKey link') ),
- },
- mapHeight => {
+ return sprintf($googleApiKeyLink, ($googleApiKeyUrl)x2, $i18n->get('mapApiKey link') );
+}
+property mapHeight => (
tab => "display",
fieldType => "text",
- label => $i18n->get("mapHeight label"),
- hoverHelp => $i18n->get("mapHeight description"),
- defaultValue => '400px',
- },
- mapWidth => {
+ label => ["mapHeight label", 'Asset_Map'],
+ hoverHelp => ["mapHeight description", 'Asset_Map'],
+ default => '400px',
+ );
+property mapWidth => (
tab => "display",
fieldType => "text",
- label => $i18n->get("mapWidth label"),
- hoverHelp => $i18n->get("mapWidth description"),
- defaultValue => '100%',
- },
- startLatitude => {
+ label => ["mapWidth label", 'Asset_Map'],
+ hoverHelp => ["mapWidth description", 'Asset_Map'],
+ default => '100%',
+ );
+property startLatitude => (
tab => "display",
fieldType => "float",
- label => $i18n->get("startLatitude label"),
- hoverHelp => $i18n->get("startLatitude description"),
- defaultValue => 43.074719,
- },
- startLongitude => {
+ label => ["startLatitude label", 'Asset_Map'],
+ hoverHelp => ["startLatitude description", 'Asset_Map'],
+ default => 43.074719,
+ );
+property startLongitude => (
tab => "display",
fieldType => "float",
- label => $i18n->get("startLongitude label"),
- hoverHelp => $i18n->get("startLongitude description"),
- defaultValue => -89.384251,
- },
- startZoom => {
+ label => ["startLongitude label", 'Asset_Map'],
+ hoverHelp => ["startLongitude description", 'Asset_Map'],
+ default => -89.384251,
+ );
+property startZoom => (
tab => "display",
fieldType => "intSlider",
minimum => 1,
maximum => 19,
- label => $i18n->get("startZoom label"),
- hoverHelp => $i18n->get("startZoom description"),
- },
- templateIdEditPoint => {
+ label => ["startZoom label", 'Asset_Map'],
+ hoverHelp => ["startZoom description", 'Asset_Map'],
+ );
+property templateIdEditPoint => (
tab => "display",
fieldType => "template",
namespace => "MapPoint/Edit",
- label => $i18n->get("templateIdEditPoint label"),
- hoverHelp => $i18n->get("templateIdEditPoint description"),
- },
- templateIdView => {
+ label => ["templateIdEditPoint label", 'Asset_Map'],
+ hoverHelp => ["templateIdEditPoint description", 'Asset_Map'],
+ );
+property templateIdView => (
tab => "display",
fieldType => "template",
namespace => "Map/View",
- label => $i18n->get("templateIdView label"),
- hoverHelp => $i18n->get("templateIdView description"),
- },
- templateIdViewPoint => {
+ label => ["templateIdView label", 'Asset_Map'],
+ hoverHelp => ["templateIdView description", 'Asset_Map'],
+ );
+property templateIdViewPoint => (
tab => "display",
fieldType => "template",
namespace => "MapPoint/View",
- label => $i18n->get("templateIdViewPoint label"),
- hoverHelp => $i18n->get("templateIdViewPoint description"),
- },
- workflowIdPoint => {
+ label => ["templateIdViewPoint label", 'Asset_Map'],
+ hoverHelp => ["templateIdViewPoint description", 'Asset_Map'],
+ );
+property workflowIdPoint => (
tab => "security",
fieldType => "workflow",
- label => $i18n->get("workflowIdPoint label"),
- hoverHelp => $i18n->get("workflowIdPoint description"),
+ label => ["workflowIdPoint label", 'Asset_Map'],
+ hoverHelp => ["workflowIdPoint description", 'Asset_Map'],
type => 'WebGUI::VersionTag',
- },
- );
- push @{$definition}, {
- assetName => $i18n->get('assetName'),
- icon => 'maps.png',
- autoGenerateForms => 1,
- tableName => 'Map',
- className => 'WebGUI::Asset::Wobject::Map',
- properties => \%properties
- };
- return $class->SUPER::definition( $session, $definition );
-} ## end sub definition
+ );
#-------------------------------------------------------------------
@@ -150,7 +133,7 @@ sub canAddPoint {
: $self->session->user
;
- return $user->isInGroup( $self->get("groupIdAddPoint") );
+ return $user->isInGroup( $self->groupIdAddPoint );
}
#----------------------------------------------------------------------------
@@ -185,7 +168,7 @@ sub canEdit {
: $self->session->user
;
- return $user->isInGroup( $self->get("groupIdEdit") );
+ return $user->isInGroup( $self->groupIdEdit );
}
}
@@ -240,7 +223,7 @@ sub getEditPointTemplate {
my $self = shift;
if ( !$self->{_editPointTemplate} ) {
- my $templateId = $self->get('templateIdEditPoint');
+ my $templateId = $self->templateIdEditPoint;
my $template
= WebGUI::Asset::Template->new( $self->session, $templateId );
$template->prepare;
@@ -263,7 +246,7 @@ sub getViewPointTemplate {
my $self = shift;
if ( !$self->{_viewPointTemplate} ) {
- my $templateId = $self->get('templateIdViewPoint');
+ my $templateId = $self->templateIdViewPoint;
my $template
= WebGUI::Asset::Template->new( $self->session, $templateId );
$self->{_viewPointTemplate} = $template;
@@ -309,7 +292,7 @@ sub loadMapApiTags {
my $style = $self->session->style;
my $url = $self->session->url;
- $style->setScript("http://www.google.com/jsapi?key=" . $self->get('mapApiKey'),{type=>"text/javascript"});
+ $style->setScript("http://www.google.com/jsapi?key=" . $self->mapApiKey,{type=>"text/javascript"});
$style->setRawHeadTags(<<'ENDHTML');