From 845d94d6a51495abfbc20955b7c1d16f33d32aa6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20R=C3=B8mcke?= <ar@ez.no>
Date: Mon, 7 Mar 2011 14:03:25 +0100
Subject: [PATCH] Fixed #017683: Geo map doesn't work with oracle

---
 .../content/datatype/edit/ezgmaplocation.tpl       |   11 +++++++----
 .../content/datatype/view/ezgmaplocation.tpl       |   11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/edit/ezgmaplocation.tpl packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/edit/ezgmaplocation.tpl
index cdf4158..c980ead 100644
--- packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/edit/ezgmaplocation.tpl
+++ packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/edit/ezgmaplocation.tpl
@@ -2,6 +2,9 @@
 {if is_set( $attribute_base )|not}
   {def $attribute_base = 'ContentObjectAttribute'}
 {/if}
+{* Make sure to normalize floats from db  *}
+{def $latitude  = $attribute.content.latitude|explode(',')|implode('.')
+     $longitude = $attribute.content.longitude|explode(',')|implode('.')}
 <div class="block">
 
 <div class="element">
@@ -143,20 +146,20 @@ else if ( window.attachEvent )
     <input class="button-disabled" type="button" id="ezgml-restore-button-{$attribute.id}" value="{'Restore'|i18n('extension/ezgmaplocation/datatype')}" onclick="javascript:void( null ); return false" disabled="disabled"  title="{'Restores location and address values to what it was on page load.'|i18n('extension/ezgmaplocation/datatype')}" />
 
     <input id="ezgml_hidden_address_{$attribute.id}" type="hidden" name="ezgml_hidden_address_{$attribute.id}" value="{$attribute.content.address}" disabled="disabled" />
-    <input id="ezgml_hidden_latitude_{$attribute.id}" type="hidden" name="ezgml_hidden_latitude_{$attribute.id}" value="{$attribute.content.latitude}" disabled="disabled" />
-    <input id="ezgml_hidden_longitude_{$attribute.id}" type="hidden" name="ezgml_hidden_longitude_{$attribute.id}" value="{$attribute.content.longitude}" disabled="disabled" />
+    <input id="ezgml_hidden_latitude_{$attribute.id}" type="hidden" name="ezgml_hidden_latitude_{$attribute.id}" value="{$latitude}" disabled="disabled" />
+    <input id="ezgml_hidden_longitude_{$attribute.id}" type="hidden" name="ezgml_hidden_longitude_{$attribute.id}" value="{$longitude}" disabled="disabled" />
     <div id="ezgml-map-{$attribute.id}" style="width: 500px; height: 280px; margin-top: 2px;"></div>
 </div>
 
 <div class="element">
   <div class="block">
     <label>{'Latitude'|i18n('extension/ezgmaplocation/datatype')}:</label>
-    <input id="ezcoa-{if ne( $attribute_base, 'ContentObjectAttribute' )}{$attribute_base}-{/if}{$attribute.contentclassattribute_id}_{$attribute.contentclass_attribute_identifier}_latitude" class="box ezcc-{$attribute.object.content_class.identifier} ezcca-{$attribute.object.content_class.identifier}_{$attribute.contentclass_attribute_identifier}" type="text" name="{$attribute_base}_data_gmaplocation_latitude_{$attribute.id}" value="{$attribute.content.latitude}" />
+    <input id="ezcoa-{if ne( $attribute_base, 'ContentObjectAttribute' )}{$attribute_base}-{/if}{$attribute.contentclassattribute_id}_{$attribute.contentclass_attribute_identifier}_latitude" class="box ezcc-{$attribute.object.content_class.identifier} ezcca-{$attribute.object.content_class.identifier}_{$attribute.contentclass_attribute_identifier}" type="text" name="{$attribute_base}_data_gmaplocation_latitude_{$attribute.id}" value="{$latitude}" />
   </div>
   
   <div class="block">
     <label>{'Longitude'|i18n('extension/ezgmaplocation/datatype')}:</label>
-    <input id="ezcoa-{if ne( $attribute_base, 'ContentObjectAttribute' )}{$attribute_base}-{/if}{$attribute.contentclassattribute_id}_{$attribute.contentclass_attribute_identifier}_longitude" class="box ezcc-{$attribute.object.content_class.identifier} ezcca-{$attribute.object.content_class.identifier}_{$attribute.contentclass_attribute_identifier}" type="text" name="{$attribute_base}_data_gmaplocation_longitude_{$attribute.id}" value="{$attribute.content.longitude}" />
+    <input id="ezcoa-{if ne( $attribute_base, 'ContentObjectAttribute' )}{$attribute_base}-{/if}{$attribute.contentclassattribute_id}_{$attribute.contentclass_attribute_identifier}_longitude" class="box ezcc-{$attribute.object.content_class.identifier} ezcca-{$attribute.object.content_class.identifier}_{$attribute.contentclass_attribute_identifier}" type="text" name="{$attribute_base}_data_gmaplocation_longitude_{$attribute.id}" value="{$longitude}" />
   </div>
 
   <div class="block">
diff --git packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/view/ezgmaplocation.tpl packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/view/ezgmaplocation.tpl
index 4788624..55c4c97 100644
--- packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/view/ezgmaplocation.tpl
+++ packages/ezgmaplocation_extension/ezextension/ezgmaplocation/design/standard/templates/content/datatype/view/ezgmaplocation.tpl
@@ -1,3 +1,6 @@
+{* Make sure to normalize floats from db  *}
+{def $latitude  = $attribute.content.latitude|explode(',')|implode('.')
+     $longitude = $attribute.content.longitude|explode(',')|implode('.')}
 {run-once}
 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={ezini('SiteSettings','GMapsKey')}" type="text/javascript"></script>
 <script type="text/javascript">
@@ -26,16 +29,16 @@ function eZGmapLocation_MapView( attributeId, latitude, longitude )
 <!--
 
 if ( window.addEventListener )
-    window.addEventListener('load', function(){ldelim} eZGmapLocation_MapView( {$attribute.id}, {first_set( $attribute.content.latitude, '0.0')}, {first_set( $attribute.content.longitude, '0.0')} ) {rdelim}, false);
+    window.addEventListener('load', function(){ldelim} eZGmapLocation_MapView( {$attribute.id}, {first_set( $latitude, '0.0')}, {first_set( $longitude, '0.0')} ) {rdelim}, false);
 else if ( window.attachEvent )
-    window.attachEvent('onload', function(){ldelim} eZGmapLocation_MapView( {$attribute.id}, {first_set( $attribute.content.latitude, '0.0')}, {first_set( $attribute.content.longitude, '0.0')} ) {rdelim} );
+    window.attachEvent('onload', function(){ldelim} eZGmapLocation_MapView( {$attribute.id}, {first_set( $latitude, '0.0')}, {first_set( $longitude, '0.0')} ) {rdelim} );
 
 -->
 </script>
 
 <div class="block">
-<label>{'Latitude'|i18n('extension/ezgmaplocation/datatype')}:</label> {$attribute.content.latitude}
-<label>{'Longitude'|i18n('extension/ezgmaplocation/datatype')}:</label> {$attribute.content.longitude}
+<label>{'Latitude'|i18n('extension/ezgmaplocation/datatype')}:</label> {$latitude}
+<label>{'Longitude'|i18n('extension/ezgmaplocation/datatype')}:</label> {$longitude}
   {if $attribute.content.address}
     <label>{'Address'|i18n('extension/ezgmaplocation/datatype')}:</label> {$attribute.content.address}
   {/if}
-- 
1.7.1

