From 25ff0dae0eae2f31cb440ea0f27d6fa73c703cce Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Sun, 17 May 2009 22:44:27 +0000 Subject: [PATCH] Added: Google map asset. Added a way for authors to prevent debugging output on page requests --- .../home_map_map-templates(3).wgpkg | Bin 0 -> 2052 bytes docs/upgrades/upgrade_7.7.6-7.7.7.pl | 61 +++++++ etc/WebGUI.conf.original | 3 + lib/WebGUI/Asset/MapPoint.pm | 105 +++++++----- lib/WebGUI/Asset/Wobject/Map.pm | 95 ++++++----- lib/WebGUI/Session/ErrorHandler.pm | 19 +++ lib/WebGUI/i18n/English/Asset_Map.pm | 160 ++++++++++++++++++ lib/WebGUI/i18n/English/Asset_MapPoint.pm | 131 +++++++++++++- www/extras/{ => yui-webgui/build}/map/map.js | 37 ++-- 9 files changed, 513 insertions(+), 98 deletions(-) create mode 100644 docs/upgrades/packages-7.7.7/home_map_map-templates(3).wgpkg rename www/extras/{ => yui-webgui/build}/map/map.js (91%) diff --git a/docs/upgrades/packages-7.7.7/home_map_map-templates(3).wgpkg b/docs/upgrades/packages-7.7.7/home_map_map-templates(3).wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..5207f4b39283f88bf25fc1345de197a427de6015 GIT binary patch literal 2052 zcmV+f2>bURiwFP!000001MOOUZ`(E#_uu;zf`?%pu*7=tOYGzc;3Uo3K1u5?Y18(} z7SI-LvynxOq++`d_T6`+WRbEXB`NG+-69~itmD1#DBk_-D<3wEkY*vnv*ObMx1x)_;5RrmsW8|G$GxSmlB; zG{RM@WBu>9pVgy?(Fij^Fqco&FgY?nTs)selnLy26)B8^K(R>jfMEobgSlj?UeJ^G zM}Du{J^y%h;-8ZD5qD2U)oe6uJ)x9VqqrXsKE}Q#hIo2GLZ42RC|eWwJfsmPtIF|A zF!TZ={~V20sdO4*_Ksur(pM5aEiq<+dNigJT$`Xs{%r|7i2|^X*L*xgaUiy^PsEla zMU;d>vm?&2NTt#jWBc77-B%M znq|aj9KH0PgZ5>^7dEQrdp^0bxR?j{KbO@pCZnuNc}<)Uq~d$1wsyK912!EfrMPZ z+#A!dP;VrO1&qgNR^+lFniViThYd=CB0emM1)N}~phb*er=ZJ>HDPRu+|C(NDi%AZ z2HSF9?`9H?F(cv~3yv9`^bo@kN@TD!B0)exoQC77PR+JT(~AVHC935=9HVfQ1zsbz z4IpCk*JzT28`wF&ynET{bY;lubk5Tlr-jM*eoB2ZBoK?GS&r-N*bT_vbv-DJNbdp~!&rr_dl?uZ2H8RlEpS_>^WyyUWYvj;pU}beVl{FJlJL|o z%hNSiQPJA%R=eG3xyIxez9Af3b+kyEYH{jzvuUgVWEeEK&R!qwHa@1)m*Fu)_QXF% ziV5NU;1L=m9)-nHYgJPzC(G729I$yLdbfxcXtckmZy^=;+EZ-= z;b(IWX={1xywngwy^I~oBM1wxf-I^{-+NO@hkPBhCT8| zRSARs{O-?npsc^IjMeb6PUN4=`wsl?w%qy>{&!o=))W4JjJM{Y_}?cSQ1M(xQ6q{x z4E*0wNvL?JqQqKigA(*#UN)HEz93L!5wg6F&_R$x`SgYXwpR1&o*imZt_Uzfe@WdS za{|zI4M z7+(W@Ini7mG}B#LEgGPu8~|x=m4cfK+W(9PfO3v$Abp)J)4ec`1~L-6EWE?DloAkh z7qrRakOKLoNG1<~yjDZoRRTUtr>j@*-Wa1%ciV*+!w3P8*;Ub;zD2zQSy8GSlYO*y zw5=P36mpk!gJ_KUSOCThf}|;7?1_f~i!z9EJLp*QS`Kvd4%8ZEZc#U`c1^^f#~{(r znXKp+?_aTB9mn|^#G=%$_Wzu9q5#lQ*8lSwZgVOBL;uft%Kv}I{C`K*ei#H;bB-@h zwfbOV{AzV&n0~$nwI43 zMW9t-JZZj>p~a!G1*Ok6wD7i(KOy0p(CEw!D0FdXz-1ppwkycc==uTo0EM#RGdTLO z5H!4kUcn)hOVH6M=7hGIDjHY0p`(^k@@ma?W!j(Iv47Z&U_1#&TTC@D-5+)>XjLL; zWd?XCWT#TM8eu`eBH3S2-OF19I*nC+IrdT{QUXdN3&bb`xe{|JfQYOy!$at!et%iD zXgCPS;2M4St+QGPliik&JiE#0IN?tQ2T1l9S#S_d-}D07`?eMHdNNZmE7#w)gG= zS@-Q9?YK)`cwqZz)v|A;an$f!&p;e&X&lw^i?mUIR|d!)2JH&qTi!o8_*PH~eseve z0{rJaBL1t}wzGo&+^6&3$AEv8hxUK|?f5T}hZrR&FmB%rXP)=r=(-UgXY1`@zNl%47^22hqxMWSAH{8~g!wdE(NmFv5l&B?JQoG6C4V`v^&bJYI5ND`&sgjA#hsxObbkC zKke$tYvi}4<4vO%_zeJ4RXuD7odb->write("alter table Survey add column `testResultsTemplateId` char(22)"); print "Done\n" unless $quiet; +} +#---------------------------------------------------------------------------- +# Add the map asset +sub addMapAsset { + my $session = shift; + print "\tAdding Google Map asset..." unless $quiet; + + # Map asset + $session->db->write(<<'ENDSQL'); +CREATE TABLE IF NOT EXISTS Map ( + assetId CHAR(22) BINARY NOT NULL, + revisionDate BIGINT NOT NULL, + groupIdAddPoint CHAR(22) BINARY, + mapApiKey TEXT, + mapHeight CHAR(12), + mapWidth CHAR(12), + startLatitude FLOAT, + startLongitude FLOAT, + startZoom TINYINT UNSIGNED, + templateIdEditPoint CHAR(22) BINARY, + templateIdView CHAR(22) BINARY, + templateIdViewPoint CHAR(22) BINARY, + workflowIdPoint CHAR(22) BINARY, + PRIMARY KEY (assetId, revisionDate) +); +ENDSQL + + # MapPoint asset + $session->db->write(<<'ENDSQL'); +CREATE TABLE IF NOT EXISTS MapPoint ( + assetId CHAR(22) BINARY NOT NULL, + revisionDate BIGINT NOT NULL, + latitude FLOAT, + longitude FLOAT, + website VARCHAR(255), + address1 VARCHAR(255), + address2 VARCHAR(255), + city VARCHAR(255), + state VARCHAR(255), + zipCode VARCHAR(255), + country VARCHAR(255), + phone VARCHAR(255), + fax VARCHAR(255), + email VARCHAR(255), + storageIdPhoto CHAR(22) BINARY, + userDefined1 TEXT, + userDefined2 TEXT, + userDefined3 TEXT, + userDefined4 TEXT, + userDefined5 TEXT, + PRIMARY KEY (assetId, revisionDate) +); +ENDSQL + + # Add to assets + $session->config->addToHash( "assets", 'WebGUI::Asset::Wobject::Map', { + "category" => "basic", + }); + + print "Done!\n" unless $quiet; } # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 64e529421..7bbcdb2af 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -642,6 +642,9 @@ }, "WebGUI::Asset::Template" : { "category" : "utilities" + }, + 'WebGUI::Asset::Wobject::Map' : { + "category" : "basic" } }, diff --git a/lib/WebGUI/Asset/MapPoint.pm b/lib/WebGUI/Asset/MapPoint.pm index d8ccb8f33..320f282ad 100644 --- a/lib/WebGUI/Asset/MapPoint.pm +++ b/lib/WebGUI/Asset/MapPoint.pm @@ -16,7 +16,7 @@ package WebGUI::Asset::MapPoint; use strict; use Tie::IxHash; -use base 'WebGUI::AssetAspect::Installable','WebGUI::Asset'; +use base 'WebGUI::Asset'; use WebGUI::Utility; # To get an installer for your wobject, add the Installable AssetAspect @@ -63,86 +63,84 @@ sub definition { my $definition = shift; my $i18n = WebGUI::International->new( $session, "Asset_MapPoint" ); tie my %properties, 'Tie::IxHash', ( - latitude => { + latitude => { tab => "properties", fieldType => "float", - label => $i18n->echo("Latitude"), - hoverHelp => $i18n->echo("The latitude of the point"), - noFormPost => 1, + label => $i18n->get("latitude label"), + hoverHelp => $i18n->get("latitude description"), }, - longitude => { + longitude => { tab => "properties", fieldType => "float", - label => $i18n->echo("Longitude"), - hoverHelp => $i18n->echo("The longitude of the point"), - noFormPost => 1, + label => $i18n->get("longitude label"), + hoverHelp => $i18n->get("longitude description"), }, - website => { + website => { tab => "properties", fieldType => "text", - label => $i18n->echo("Website"), - hoverHelp => $i18n->echo("The URL to the location's website"), + label => $i18n->get("website label"), + hoverHelp => $i18n->get("website description"), }, - address1 => { + address1 => { tab => "properties", fieldType => "text", - label => $i18n->echo("Address 1"), - hoverHelp => $i18n->echo("The first line of the address"), + label => $i18n->get("address1 label"), + hoverHelp => $i18n->get("address1 description"), }, - address2 => { + address2 => { tab => "properties", fieldType => "text", - label => $i18n->echo("Address 2"), - hoverHelp => $i18n->echo("The second line of the address"), + label => $i18n->get("address2 label"), + hoverHelp => $i18n->get("address2 description"), }, - city => { + city => { tab => "properties", fieldType => "text", - label => $i18n->echo("City"), - hoverHelp => $i18n->echo("The city the point is located in"), + label => $i18n->get("city label"), + hoverHelp => $i18n->get("city description"), }, - state => { + state => { tab => "properties", fieldType => "text", - label => $i18n->echo("State/Province"), - hoverHelp => $i18n->echo("The state/provice the point is located in"), + label => $i18n->get("state label"), + hoverHelp => $i18n->get("state description"), }, - zipCode => { + zipCode => { tab => "properties", fieldType => "text", - label => $i18n->echo("Zip/Postal Code"), - hoverHelp => $i18n->echo("The zip/postal code the point is located in"), + label => $i18n->get("zipCode label"), + hoverHelp => $i18n->get("zipCode description"), }, - country => { + country => { tab => "properties", fieldType => "country", - label => $i18n->echo("Country"), - hoverHelp => $i18n->echo("The country the point is located in"), + label => $i18n->get("country label"), + hoverHelp => $i18n->get("country description"), }, - phone => { + phone => { tab => "properties", fieldType => "phone", - label => $i18n->echo("Phone"), - hoverHelp => $i18n->echo("The phone number of the location"), + label => $i18n->get("phone label"), + hoverHelp => $i18n->get("phone description"), }, - fax => { + fax => { tab => "properties", fieldType => "phone", - label => $i18n->echo("Fax"), - hoverHelp => $i18n->echo("The fax number of the location"), + label => $i18n->get("fax label"), + hoverHelp => $i18n->get("fax description"), }, - email => { + email => { tab => "properties", fieldType => "email", - label => $i18n->echo("E-mail"), - hoverHelp => $i18n->echo("The e-mail address of the location"), + label => $i18n->get("email label"), + hoverHelp => $i18n->get("email description"), }, - storageIdPhoto => { + storageIdPhoto => { tab => "properties", fieldType => "image", forceImageOnly => 1, - label => $i18n->echo("Photo"), - hoverHelp => $i18n->echo("A photo of the location"), + label => $i18n->get("storageIdPhoto label"), + hoverHelp => $i18n->get("storageIdPhoto description"), noFormPost => 1, }, userDefined1 => { @@ -190,6 +188,19 @@ sub canEdit { #------------------------------------------------------------------- +=head2 getAutoCommitWorkflowId ( ) + +Get the workflowId to commit this MapPoint + +=cut + +sub getAutoCommitWorkflowId { + my ( $self ) = @_; + return $self->getParent->get('workflowIdPoint'); +} + +#------------------------------------------------------------------- + =head2 getMapInfo ( ) Get a hash of info to be put into the parent Map. Must include @@ -274,6 +285,14 @@ sub getTemplateVarsEditForm { value => $self->getId, defaultValue => 'new', } ) + . WebGUI::Form::hidden( $session, { + name => 'latitude', + value => $self->get('latitude'), + } ) + . WebGUI::Form::hidden( $session, { + name => 'longitude', + value => $self->get('longitude'), + } ) ; $var->{ form_footer } = WebGUI::Form::formFooter( $session ); @@ -346,9 +365,7 @@ sub processAjaxEditForm { $self->update( $prop ); # Photo magic - $session->log->info("BEEP!"); if ( $form->get('storageIdPhoto') ) { - $session->log->info("BOOP!"); my $storage; if ( $self->get('storageIdPhoto') ) { $storage = WebGUI::Storage->get( $session, $self->get('storageIdPhoto') ); diff --git a/lib/WebGUI/Asset/Wobject/Map.pm b/lib/WebGUI/Asset/Wobject/Map.pm index f441fdc73..12a66e1aa 100644 --- a/lib/WebGUI/Asset/Wobject/Map.pm +++ b/lib/WebGUI/Asset/Wobject/Map.pm @@ -16,7 +16,7 @@ use strict; use Tie::IxHash; use WebGUI::International; use WebGUI::Utility; -use base 'WebGUI::AssetAspect::Installable','WebGUI::Asset::Wobject'; +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 @@ -36,47 +36,52 @@ sub definition { my $definition = shift; 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->echo("Group to Add Points"), - hoverHelp => $i18n->echo("Group that is allowed to add points to the map"), + label => $i18n->get("groupIdAddPoint label"), + hoverHelp => $i18n->get("groupIdAddPoint description"), + defaultValue=> '2', # Registered users }, mapApiKey => { tab => "properties", fieldType => "text", - label => $i18n->echo("Google Maps API Key"), - hoverHelp => $i18n->echo("The generated Google Maps API key for this site"), + label => $i18n->get("mapApiKey label"), + hoverHelp => $i18n->get("mapApiKey description"), defaultValue=> $class->getDefaultApiKey($session), - subtext => $i18n->echo(q{Get your Google Maps API key}), + subtext => sprintf($googleApiKeyLink, ($googleApiKeyUrl)x2, $i18n->get('mapApiKey link') ), }, mapHeight => { tab => "display", fieldType => "text", - label => $i18n->echo("Map Height"), - hoverHelp => $i18n->echo("The height of the generated map"), + label => $i18n->get("mapHeight label"), + hoverHelp => $i18n->get("mapHeight description"), defaultValue => '400px', }, mapWidth => { tab => "display", fieldType => "text", - label => $i18n->echo("Map Width"), - hoverHelp => $i18n->echo("The width of the generated map"), + label => $i18n->get("mapWidth label"), + hoverHelp => $i18n->get("mapWidth description"), defaultValue => '100%', }, startLatitude => { tab => "display", fieldType => "float", - label => $i18n->echo("Starting Latitude"), - hoverHelp => $i18n->echo("Latitude of the default starting point of the map"), + label => $i18n->get("startLatitude label"), + hoverHelp => $i18n->get("startLatitude description"), defaultValue => 43.074719, }, startLongitude => { tab => "display", fieldType => "float", - label => $i18n->echo("Starting Longitude"), - hoverHelp => $i18n->echo("Longitude of the default starting point of the map"), + label => $i18n->get("startLongitude label"), + hoverHelp => $i18n->get("startLongitude description"), defaultValue => -89.384251, }, startZoom => { @@ -84,35 +89,36 @@ sub definition { fieldType => "intSlider", minimum => 1, maximum => 19, - label => $i18n->echo("Starting Zoom Level"), - hoverHelp => $i18n->echo("Zoom level of the default starting point of the map"), + label => $i18n->get("startZoom label"), + hoverHelp => $i18n->get("startZoom description"), }, templateIdEditPoint => { tab => "display", fieldType => "template", namespace => "MapPoint/Edit", - label => $i18n->echo("Template to Edit Map Point"), - hoverHelp => $i18n->echo("Template to edit a map point."), + label => $i18n->get("templateIdEditPoint label"), + hoverHelp => $i18n->get("templateIdEditPoint description"), }, templateIdView => { tab => "display", fieldType => "template", namespace => "Map/View", - label => $i18n->echo("Template to View"), - hoverHelp => $i18n->echo("Template to view the map"), + label => $i18n->get("templateIdView label"), + hoverHelp => $i18n->get("templateIdView description"), }, templateIdViewPoint => { tab => "display", fieldType => "template", namespace => "MapPoint/View", - label => $i18n->echo("Template to View Map Point"), - hoverHelp => $i18n->echo("Template to view a map point. Will pop-up a box inside the map."), + label => $i18n->get("templateIdViewPoint label"), + hoverHelp => $i18n->get("templateIdViewPoint description"), }, workflowIdPoint => { tab => "security", fieldType => "workflow", - label => $i18n->echo("Workflow for Adding Points"), - hoverHelp => $i18n->echo("Commit workflow for adding points"), + label => $i18n->get("workflowIdPoint label"), + hoverHelp => $i18n->get("workflowIdPoint description"), + type => 'WebGUI::VersionTag', }, ); push @{$definition}, { @@ -211,8 +217,7 @@ sub getDefaultApiKey { my $session = shift; # Get the API key used in other Maps on the site - eval { - # Map may not exist yet! + eval { # Map may not exist yet! my $defaultApiKey = $session->db->quickScalar( "SELECT mapApiKey FROM Map LIMIT 1" ); @@ -313,7 +318,7 @@ ENDHTML $style->setScript($url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),{type=>'text/javascript'}); $style->setScript($url->extras('yui/build/connection/connection-min.js'),{type=>'text/javascript'}); $style->setScript($url->extras('yui/build/json/json-min.js'),{type=>'text/javascript'}); - $style->setScript($url->extras('map/map.js'),{type=>'text/javascript'}); + $style->setScript($url->extras('yui-webgui/build/map/map.js'),{type=>'text/javascript'}); return; } @@ -429,14 +434,14 @@ ENDHTML # Button to add a map point $var->{ button_addPoint } = WebGUI::Form::Button( $session, { - value => $i18n->echo("Add Point"), + value => $i18n->get("add point label"), id => sprintf( 'addPoint_%s', $self->getId ), } ); # Button to set the map's default view $var->{ button_setCenter } = WebGUI::Form::Button( $session, { - value => $i18n->echo("Set Default Viewing Area"), + value => $i18n->get("set default viewing area label"), id => sprintf( 'setCenter_%s', $self->getId ), } ); @@ -454,14 +459,15 @@ Immediately remove a point from the map. sub www_ajaxDeletePoint { my ( $self ) = @_; my $session = $self->session; - my $assetId = $self->session->form->get('assetId'); + my $i18n = WebGUI::International->new( $session, 'Asset_Map' ); + my $assetId = $session->form->get('assetId'); my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - $self->session->http->setMimeType('application/json'); - return JSON->new->encode({error => 'You are not allowed to remove this point'}) + $session->http->setMimeType('application/json'); + return JSON->new->encode({error => $i18n->get('error delete unauthorized')}) unless $asset && $asset->canEdit; $asset->purge; - return JSON->new->encode({message => 'Point deleted'}); + return JSON->new->encode({message => $i18n->get('message delete success')}); } #------------------------------------------------------------------- @@ -489,6 +495,7 @@ sub www_ajaxEditPoint { my $output = $self->getEditPointTemplate->process( $asset->getTemplateVarsEditForm ); WebGUI::Macro::process( $session, \$output ); + $session->log->preventDebugOutput; return $output; } @@ -504,13 +511,15 @@ sub www_ajaxEditPointSave { my $self = shift; my $session = $self->session; my $form = $self->session->form; + my $i18n = WebGUI::International->new( $session, 'Asset_Map' ); - $session->http->setMimeType("text/html"); + $session->http->setMimeType("text/html"); + $session->log->preventDebugOutput; my $assetId = $form->get('assetId'); my $asset; if ( $assetId eq "new" ) { - return JSON->new->encode({message => "Error"}) + return JSON->new->encode({message => $i18n->get("error add unauthorized")}) unless $self->canAddPoint; $asset = $self->addChild( { @@ -519,12 +528,18 @@ sub www_ajaxEditPointSave { } else { $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - return JSON->new->encode({message => "Error"}) + return JSON->new->encode({message => $i18n->get("error edit unauthorized")}) unless $asset && $asset->canEdit; + $asset = $asset->addRevision; } my $errors = $asset->processAjaxEditForm; + # Commit! + if ($asset->getAutoCommitWorkflowId && $self->hasBeenCommitted) { + $asset->requestAutoCommit; + } + return JSON->new->encode($asset->getMapInfo); } @@ -544,7 +559,7 @@ sub www_ajaxSetCenter { $session->http->setMimeType("application/json"); - return JSON->new->encode({message => $i18n->echo("No permissions")}) + return JSON->new->encode({message => $i18n->get("error set center unauthorized")}) unless $self->canEdit; $self->update({ @@ -553,7 +568,7 @@ sub www_ajaxSetCenter { startZoom => $form->get("startZoom"), }); - return JSON->new->encode({message => $i18n->echo("Success!")}); + return JSON->new->encode({message => $i18n->get("message set center success")}); } #------------------------------------------------------------------- @@ -574,12 +589,14 @@ sub www_ajaxSetPointLocation { my $assetId = $form->get('assetId'); my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + return JSON->new->encode({message => $i18n->get("error edit unauthorized")}) + unless $asset && $asset->canEdit; $asset->update( { latitude => $form->get('latitude'), longitude => $form->get('longitude'), } ); - return JSON->new->encode( {message => $i18n->echo("Success!")} ); + return JSON->new->encode( {message => $i18n->get("message set point location")} ); } 1; diff --git a/lib/WebGUI/Session/ErrorHandler.pm b/lib/WebGUI/Session/ErrorHandler.pm index f60a6bfb5..917fb6ebe 100644 --- a/lib/WebGUI/Session/ErrorHandler.pm +++ b/lib/WebGUI/Session/ErrorHandler.pm @@ -121,6 +121,9 @@ sub canShowDebug { ##This check prevents in infinite loop during startup. return 0 unless ($self->session->hasSettings); + # Allow programmers to stop debugging output for certain requests + return 0 if $self->{_preventDebugOutput}; + my $canShow = $self->session->setting->get("showDebug") && $self->canShowBasedOnIP('debugIp'); $self->{_canShowDebug} = $canShow; @@ -325,6 +328,22 @@ sub new { bless {_queryCount=>0, _logger=>$logger, _session=>$session}, $class; } +#---------------------------------------------------------------------------- + +=head2 preventDebugOutput ( ) + +Prevent this session from sending debugging output even if we're supposed to. + +Some times we need to use 'text/html' to send non-html content (these may be +browser limitations, but we need to work with them). + +=cut + +sub preventDebugOutput { + my ( $self ) = @_; + $self->{_preventDebugOutput} = 1; +} + #------------------------------------------------------------------- =head2 query ( sql ) diff --git a/lib/WebGUI/i18n/English/Asset_Map.pm b/lib/WebGUI/i18n/English/Asset_Map.pm index 4cd4de614..cf16d29f9 100644 --- a/lib/WebGUI/i18n/English/Asset_Map.pm +++ b/lib/WebGUI/i18n/English/Asset_Map.pm @@ -3,6 +3,166 @@ package WebGUI::i18n::English::Asset_Map; use strict; our $I18N = { + 'groupIdAddPoint label' => { + message => 'Group to Add Points', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'groupIdAddPoint description' => { + message => 'Group that is allowed to add points to the map', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'mapApiKey label' => { + message => "Google Maps API Key", + lastUpdated => 0, + context => 'Label for asset property', + }, + 'mapApiKey description' => { + message => 'The generated Google Maps API key for this site', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'mapApiKey link' => { + message => 'Get your Google Maps API key', + lastUpdated => 0, + context => 'Label for link to create a Google Maps API key', + }, + 'mapHeight label' => { + message => 'Map Height', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'mapHeight description' => { + message => 'The height of the generated map. Make sure to include the units (px = pixels or % = percent).', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'mapWidth label' => { + message => 'Map Width', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'mapWidth description' => { + message => 'The width of the generated map. Make sure to include the units (px = pixels or % = percent).', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'startLatitude label' => { + message => 'Starting Latitude', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'startLatitude description' => { + message => 'Latitude of the default starting point of the map.', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'startLongitude label' => { + message => 'Starting Longitude', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'startLongitude description' => { + message => 'Longitude of the default starting point of the map', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'startZoom label' => { + message => 'Starting Zoom Level', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'startZoom description' => { + message => 'Zoom level of the default starting point of the map', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'templateIdEditPoint label' => { + message => 'Template to Edit Point', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'templateIdEditPoint description' => { + message => 'Template to edit a map point. Will appear inside of the map.', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'templateIdView label' => { + message => 'Template to View Map', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'templateIdView description' => { + message => 'Template to view the map.', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'templateIdViewPoint label' => { + message => 'Template to View Point', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'templateIdViewPoint description' => { + message => 'Template to view a map point. Will appear inside the map.', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'workflowIdPoint label' => { + message => 'Workflow to Commit Map Points', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'workflowIdPoint description' => { + message => 'The workflow that will be run when a map point is added or edited.', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'add point label' => { + message => "Add Point", + lastUpdated => 0, + context => 'Label for button to add point', + }, + 'set default viewing area label' => { + message => 'Set Default Viewing Area', + lastUpdated => 0, + context => 'Label for button to set starting latitude, longitude, and zoom level', + }, + 'error delete unauthorized' => { + message => 'You are not allowed to remove this point', + lastUpdated => 0, + context => 'Error message for user not allowed to remove a point', + }, + 'message delete success' => { + message => 'Point deleted', + lastUpdated => 0, + context => 'Message when point deleted successfully', + }, + 'error add unauthorized' => { + message => 'You are not allowed to add points', + lastUpdated => 0, + context => 'Error for user not allowed to add a point', + }, + 'error edit unauthorized' => { + message => 'You are not allowed to edit this point', + lastUpdated => 0, + context => 'Error for user not allowed to edit a point', + }, + 'error set center unauthorized' => { + message => 'You are not allowed to set the default viewing area', + lastUpdated => 0, + context => 'Error message', + }, + 'message set center success' => { + message => 'Default viewing area set successfully', + lastUpdated => 0, + context => "Success message", + }, + 'message set point location' => { + message => 'Point location saved', + lastUpdated => 0, + context => 'Success message', + }, 'assetName' => { message => "Map", lastUpdated => 0, diff --git a/lib/WebGUI/i18n/English/Asset_MapPoint.pm b/lib/WebGUI/i18n/English/Asset_MapPoint.pm index 0a2bf30b7..2f995dd18 100644 --- a/lib/WebGUI/i18n/English/Asset_MapPoint.pm +++ b/lib/WebGUI/i18n/English/Asset_MapPoint.pm @@ -3,7 +3,136 @@ package WebGUI::i18n::English::Asset_MapPoint; use strict; our $I18N = { - + 'latitude label' => { + message => 'Latitude', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'latitude description' => { + message => 'The latitude of the point', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'longitude label' => { + message => 'Longitude', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'longitude description' => { + message => 'The longitude of the point', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'website label' => { + message => 'Website URL', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'website description' => { + message => 'A website URL', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'address1 label' => { + message => 'Address 1', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'address1 description' => { + message => 'The first line of the address', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'address2 label' => { + message => 'Address 2', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'address2 description' => { + message => 'The second line of the address', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'city label' => { + message => 'City', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'city description' => { + message => 'The city the point is in', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'state label' => { + message => 'State/Province', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'state description' => { + message => 'The state/province the point is in', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'zipCode label' => { + message => 'Zip/Postal Code', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'zipCode description' => { + message => 'The zip/postal code the point is in', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'country label' => { + message => 'Country', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'country description' => { + message => 'The country the point is in', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'phone label' => { + message => 'Phone', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'phone description' => { + message => 'The phone number of the location', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'fax label' => { + message => 'Fax', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'fax description' => { + message => 'The fax number of the location', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'email label' => { + message => 'E-mail', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'email description' => { + message => 'The e-mail address of the location', + lastUpdated => 0, + context => 'Description of asset property', + }, + 'storageIdPhoto label' => { + message => 'Photo', + lastUpdated => 0, + context => 'Label for asset property', + }, + 'storageIdPhoto description' => { + message => 'A photo of the location', + lastUpdated => 0, + context => 'Description of asset property', + }, 'assetName' => { message => "MapPoint", lastUpdated => 0, diff --git a/www/extras/map/map.js b/www/extras/yui-webgui/build/map/map.js similarity index 91% rename from www/extras/map/map.js rename to www/extras/yui-webgui/build/map/map.js index 28f43e4eb..f98561066 100644 --- a/www/extras/map/map.js +++ b/www/extras/yui-webgui/build/map/map.js @@ -1,4 +1,3 @@ - // Initialize namespace if (typeof WebGUI == "undefined") { var WebGUI = {}; @@ -53,6 +52,7 @@ WebGUI.Map.editPoint // Callback should open the window with the form var callback = function (text, code) { marker.openInfoWindowHtml( text ); + GEvent.addListener( marker, "infowindowbeforeclose", function () { WebGUI.Map.editPointSave( map, mgr, mapUrl, marker ); }); @@ -71,26 +71,40 @@ WebGUI.Map.editPointSave var iwin = map.getInfoWindow(); var form = iwin.getContentContainers()[0].getElementsByTagName('form')[0]; + // Add the lat/long to the form + var lat = marker.getLatLng().lat(); + var lng = marker.getLatLng().lng(); + form.elements['latitude'].value = lat; + form.elements['longitude'].value = lng; + // Make ajax request var callback = { upload: function (o) { // Update marker info - console.log(o.responseText); var point = YAHOO.lang.JSON.parse( o.responseText ); + marker.assetId = point.assetId; GEvent.clearListeners( marker, "click" ); GEvent.clearListeners( marker, "infowindowbeforeclose" ); + // Set the marker's title + marker.kh.title = point.title; + // I hate the google maps API. + var infoWin = document.createElement( "div" ); infoWin.innerHTML = point.content; marker.infoWin = infoWin; + if ( point.canEdit ) { + var divButton = document.createElement('div'); + infoWin.appendChild( divButton ); + var editButton = document.createElement("input"); editButton.type = "button"; editButton.value = "Edit"; GEvent.addDomListener( editButton, "click", function () { WebGUI.Map.editPoint( map, mgr, mapUrl, marker ); } ); - infoWin.appendChild( editButton ); + divButton.appendChild( editButton ); var deleteButton = document.createElement("input"); deleteButton.type = "button"; @@ -103,14 +117,9 @@ WebGUI.Map.editPointSave divButton.appendChild( deleteButton ); } marker.bindInfoWindow( infoWin ); - - // Make sure the point has a Lat/Lng in case the user doesn't - // move it after initially creating it. - if ( marker.assetId == "new" ) { - marker.assetId = point.assetId; - WebGUI.Map.setPointLocation( marker, marker.getLatLng(), mapUrl ); - } - marker.assetId = point.assetId; + GEvent.addListener( marker, "dragend", function (latlng) { + WebGUI.Map.setPointLocation( marker, latlng, mapUrl ); + } ); } }; // In case our form does not have a file upload in it @@ -127,10 +136,10 @@ WebGUI.Map.editPointSave WebGUI.Map.focusOn = function ( assetId ) { var marker = WebGUI.Map.markers[assetId]; - var map = marker.map; - var infoWin = marker.infoWin; + var map = marker.map; + var infoWin = marker.infoWin; if ( map.getZoom() < 5 ) { - map.setZoom(6); + map.setZoom(6); } map.panTo( marker.getLatLng() ); marker.openInfoWindow( marker.infoWin );