From c40e27ce70ae0cd0470a15cdab347838d6c58945 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Fri, 21 Jun 2013 14:45:18 +0000
Subject: [PATCH] Lieu: google maps, prise en compte latitude longitude

---
 .../admin/controllers/LieuController.php      |  2 +-
 library/ZendAfi/View/Helper/MapForLieu.php    |  3 +++
 .../AbonneControllerFormationsTest.php        | 22 ++++++++++---------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/application/modules/admin/controllers/LieuController.php b/application/modules/admin/controllers/LieuController.php
index f732d8ed1f5..e8354ff697f 100644
--- a/application/modules/admin/controllers/LieuController.php
+++ b/application/modules/admin/controllers/LieuController.php
@@ -89,7 +89,7 @@ class Admin_LieuController extends Zend_Controller_Action {
 																			 'allowEmpty' => false ])
 
 			->addElement('url', 'url', ['label' => 'Site web',
-																	'size'	=> 100,
+																	'size'	=> 50,
 																	'maxlength' => 255])
 
 			->addElement('text', 'telephone', ['label' => 'Téléphone',
diff --git a/library/ZendAfi/View/Helper/MapForLieu.php b/library/ZendAfi/View/Helper/MapForLieu.php
index d5bfc0baa0b..cf3709b40e6 100644
--- a/library/ZendAfi/View/Helper/MapForLieu.php
+++ b/library/ZendAfi/View/Helper/MapForLieu.php
@@ -27,6 +27,9 @@ class ZendAfi_View_Helper_MapForLieu extends Zend_View_Helper_HtmlElement {
 																	$lieu->getVille(),
 																	$lieu->getPays()));
 
+		if (($latitude = $lieu->getLatitude()) && ($longitude = $lieu->getLongitude()))
+			$full_adresse = $latitude.','.$longitude.','.$full_adresse;
+
 		$params = array('sensor' => 'false',
 										'zoom' => 15,
 										'size' => '200x200',
diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php
index eae90106e4f..9298ddd9f1f 100644
--- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php
+++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php
@@ -50,19 +50,21 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro
 			->setValeur('1');
 
 		$this->_gallice_cafe = Class_Lieu::getLoader()
-													->newInstanceWithId(98)
-													->setLibelle('Gallice');
+			->newInstanceWithId(98)
+			->setLibelle('Gallice');
 
 		$this->_bib_romains = Class_Lieu::getLoader()
-													->newInstanceWithId(99)
-													->setLibelle('Bibliothèque des romains');
+			->newInstanceWithId(99)
+			->setLibelle('Bibliothèque des romains');
 
 		$this->_bonlieu = Class_Lieu::getLoader()
-													->newInstanceWithId(100)
-													->setLibelle('Bonlieu')
-													->setAdresse("1, rue Jean-Jaures\nBP 294")
-													->setCodePostal(74007)
-													->setVille('Annecy');
+			->newInstanceWithId(100)
+			->setLibelle('Bonlieu')
+			->setAdresse("1, rue Jean-Jaures\nBP 294")
+			->setCodePostal(74007)
+			->setVille('Annecy')
+			->setLatitude('45.902179')
+			->setLongitude('6.128715');
 
 		Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')
 			->whenCalled('save')->answers(true);
@@ -576,7 +578,7 @@ class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneCon
 
 	/** @test */
 	function ddShouldContainsGoogleMap() {
-		$this->assertXPath('//dd//img[@src="http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=15&size=300x300&center=1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE&markers=1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE"]',
+		$this->assertXPath('//dd//img[@src="http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=15&size=300x300&center=45.902179%2C6.128715%2C1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE&markers=45.902179%2C6.128715%2C1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE"]',
 											 $this->_response->getBody());
 	}
 
-- 
GitLab