diff --git a/application/controllers/GeolocalisationController.php b/application/controllers/GeolocalisationController.php
deleted file mode 100644
index 690ccd5b4..000000000
--- a/application/controllers/GeolocalisationController.php
+++ /dev/null
@@ -1,176 +0,0 @@
-view->headScript()
- ->appendFile('/themes/default/scripts/geolocalisation.js', 'text/javascript');
- $this->view->headLink()
- ->appendStylesheet('/themes/default/styles/geolocalisation.css', 'all');
- }
-
- /**********************************************************************************/
- /* Liste des établissements */
- /**********************************************************************************/
-
- /**
- * Genere une sorte d'iframe pour la page liste des etablissements.
- */
- public function iframeAction()
- {
- $listeEtablissement = $this->getRequest()->getParam('listeEtablissement');
-
- $this->view->assign('listeEtablissement', $listeEtablissement);
- }
-
- /**
- * Fonction complémentaire de iframe.
- */
- public function geolistejavascriptAction()
- {
- $valeur = array();
- $listeEtablissement = $this->getRequest()->getParam('listeEtablissement');
- $geoLocalisation = new geoLocalisationLib($listeEtablissement, $valeur);
- $this->view->assign('geoInformations', $valeur);
- }
-
- /**********************************************************************************/
- /* Photo sur fiche identité */
- /**********************************************************************************/
-
- /**
- * Netoye l'adresse des espace et des arrondissement pour paris etc... exemple "PARIS 16" devient "Paris"
- * @param unknown_type $ville
- */
- private function cleanAdress($ville)
- {
- $ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' ';
- $ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => '')));
- return (ucwords(strtolower($ville)));
- }
-
- /**
- * Affiche la bonne photo celon si deisponnible chez Mappy sinon ont interoge google.
- */
- public function geophotoAction()
- {
- $user = new Utilisateur();
- if ($user->checkPref('mappy'))
- {
- self::initMappy();
- $infos = $this->getRequest()->getParam('infos');
- $ville = self::cleanAdress($infos->Ville);
-
- if (in_array($ville, $this->mappyVille)) {
- $source = 'mappy';
- $token = self::mappyPhoto();
- $this->view->assign('token', $token);
- $this->view->assign('AdresseNum',$infos->AdresseNum);
- $this->view->assign('AdresseRue', $infos->AdresseRue);
- $this->view->assign('AdresseVille', $infos->Ville);
- }
- else {
- $source = 'google';
- self::googlePhoto();
- }
- $this->view->assign('source', $source);
- } else {
- $this->view->assign('disable', true);
- }
- }
-
- /**********************************************************************************/
- /* Mappy sur fiche identité */
- /**********************************************************************************/
- public function setMappyLogin($login)
- {
- $this->mappyLogin['login'] = $login;
- }
-
- public function setMappyPassword($password)
- {
- $this->mappyLogin['password'] = $password;
- }
-
- /**
- * Initialisation des villes disponnible chez mappy
- */
- private function initMappy()
- {
- self::setMappyLogin('scoresdecisions');
- self::setMappyPassword('g1nq3iKv');
-
- $this->mappyVille = array(
- 'Bordeaux', 'Caen' , 'Cannes',
- 'Grenoble', 'La Baule', 'Lille',
- 'Lyon', 'Marseille', 'Montpellier',
- 'Nancy', 'Nantes', 'Nice',
- 'Rennes', 'Strasbourg', 'Toulouse',
- 'Asnières-sur-Seine', 'Boulogne-Billancourt', 'Courbevoie',
- 'Issy-les-Moulineaux', 'Levallois-Perret',
- 'Montrouge', 'Nanterre', 'Neuilly-sur-Seine',
- 'Rueil-Malmaison', 'Sèvres', 'Versailles',
- 'Paris'
- );
- }
-
- /**
- * Génère le toker pour mappy.
- */
- private function getToken()
- {
- $ACCESSOR_URL = 'http://axe.mappy.com/1v1/';
- $timestamp = time();
- $hash = md5($this->mappyLogin['login']."@".$this->mappyLogin['password']."@".$timestamp);
- $preToken = $this->mappyLogin['login']."@".$timestamp."@".$hash;
- $urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]);
- $fh = @fopen($urlGetToken, 'rb');
-
- if ($fh == false) return false;
- $token = '';
- while (!feof($fh))$token .= fread($fh, 8192);
- fclose($fh);
- return ($token);
- }
-
- /**
- * Apelle le token
- */
- public function mappyPhoto()
- {
- if(!($token = self::getToken())) {
- echo 'Impossible de recuperer le Token !';
- }
- return($token);
- }
-
- /**********************************************************************************/
- /* Google sur fiche identité */
- /**********************************************************************************/
-
- /**
- * Genere le code pour l'image google.
- */
- public function googlePhoto()
- {
- $googleKey = geoLocalisationLib::getGoogleKey($_SERVER['SERVER_NAME']);
- $adress = array();
- $request = $this->getRequest();
- $info = $request->getParam('infos');
- $google_map = 'http://maps.google.fr/maps?f=q&hl=fr&geocode=&q='.
- $info->AdresseNum.',+'.
- urlencode($info->AdresseVoie).'+'.
- urlencode(htmlspecialchars_decode($info->AdresseRue, ENT_QUOTES)).
- ',+'.$info->CP.'+'.
- urlencode($info->Ville);
-
- $this->view->assign('infos', $info);
- $this->view->assign('google_map_link', $google_map);
- $this->view->assign('googleKey', $googleKey);
- }
-}
\ No newline at end of file
diff --git a/application/controllers/IdentiteController.php b/application/controllers/IdentiteController.php
index 73ec941a5..04f836822 100644
--- a/application/controllers/IdentiteController.php
+++ b/application/controllers/IdentiteController.php
@@ -736,6 +736,59 @@ class IdentiteController extends Zend_Controller_Action
} else {
echo $iris->erreur();
}
- }
+ }
+
+ public function geoAction()
+ {
+ $this->view->headScript()->appendFile('/themes/default/scripts/geolocalisation.js', 'text/javascript');
+ $this->view->headLink()->appendStylesheet('/themes/default/styles/geolocalisation.css', 'all');
+
+ $infos = $this->getRequest()->getParam('infos');
+
+ $user = new Utilisateur();
+ $this->view->assign('facadeDisable', $user->checkPref('mappy'));
+
+ require_once 'Scores/Google.php';
+ $google = new Google();
+ $decLat = $google->dec2dms($infos->GeoLat);
+ $decLon = $google->dec2dms($infos->GeoLon);
+ $mapsHref = $google->getGoogleMapLink(urlencode(
+ $infos->AdresseNum.', '.$infos->AdresseVoie.' '.
+ htmlspecialchars_decode($infos->AdresseRue, ENT_QUOTES).
+ ', '.$infos->CP.' '.$infos->Ville));
+
+ $this->view->assign('mapsHref', $mapsHref);
+ $this->view->assign('decLat', $decLat);
+ $this->view->assign('decLon', $decLon);
+ $this->view->assign('infos', $infos);
+ }
+
+ public function facadeAction()
+ {
+ require_once 'Scores/Mappy.php';
+ $infos = $this->getRequest()->getParam('infos');
+ $mappy = new Mappy();
+ if ($mappy->villeCouverte($infos->Ville))
+ {
+ $this->view->assign('source', 'mappy');
+ $this->view->assign('lienJs',$mappy->getJs());
+ $this->view->assign('AdresseNum',$infos->AdresseNum);
+ $this->view->assign('AdresseRue', $infos->AdresseRue);
+ $this->view->assign('AdresseVille', $infos->Ville);
+
+ }
+ else
+ {
+ require_once 'Scores/Google.php';
+ $google = new Google();
+ $googleKey = $google->getGoogleKey($_SERVER['SERVER_NAME']);
+ $this->view->assign('googleKey', $googleKey);
+ $this->view->assign('source', 'google');
+ $this->view->assign('AdresseNum',$infos->AdresseNum);
+ $this->view->assign('AdresseRue', $infos->AdresseRue);
+ $this->view->assign('AdresseVille', $infos->Ville);
+ $this->view->assign('infos', $infos);
+ }
+ }
}
\ No newline at end of file
diff --git a/application/views/default/scripts/geolocalisation/geolistejavascript.phtml b/application/views/default/scripts/geolocalisation/geolistejavascript.phtml
deleted file mode 100644
index 4dfbc0afe..000000000
--- a/application/views/default/scripts/geolocalisation/geolistejavascript.phtml
+++ /dev/null
@@ -1,42 +0,0 @@
-geoInformations[0][0];?>
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/views/default/scripts/geolocalisation/geophoto.phtml b/application/views/default/scripts/geolocalisation/geophoto.phtml
deleted file mode 100644
index 172dd300d..000000000
--- a/application/views/default/scripts/geolocalisation/geophoto.phtml
+++ /dev/null
@@ -1,127 +0,0 @@
-Localisation géographique
-
-
-
-
- Information géographique :
- Latitude : infos->GeoLat)?> (infos->GeoLat;?>)
- Longitude : infos->GeoLon)?> (infos->GeoLon;?>)
-
-
- Afficher l'adresse sur Google Map ©
-
-
Code commune / Rivoli :
- infos->Dept.' '.$this->infos->codeCommune.' / '.$this->infos->Rivoli; ?>
- infos->InfosIris)>0){
- $InfosIris = $this->infos->InfosIris;
- $codComIris = str_replace($InfosIris->codIris, '', $InfosIris->codComIris);
- ?>
-
Iris :
- codIris*1 == 0){
- ?>
-
Commune non découpée en Iris
-
-
Code : =$codComIris?> =$InfosIris->codIris?>
-
Libellé :
=$InfosIris->libIris?>
-
-
-
-
-
-disable):?>
-source == 'google'):?>
-
-
- Cliché à l'approche de l'adresse postale.
-
-
-
-
-
-
-
-source == 'mappy'):?>
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/views/default/scripts/geolocalisation/iframe.phtml b/application/views/default/scripts/geolocalisation/iframe.phtml
deleted file mode 100644
index f116267ce..000000000
--- a/application/views/default/scripts/geolocalisation/iframe.phtml
+++ /dev/null
@@ -1 +0,0 @@
-action('geolistejavascript', 'geolocalisation', null, array('listeEtablissement' => $this->listeEtablissement));?>
\ No newline at end of file
diff --git a/application/views/default/scripts/identite/facade.phtml b/application/views/default/scripts/identite/facade.phtml
new file mode 100644
index 000000000..673a60daf
--- /dev/null
+++ b/application/views/default/scripts/identite/facade.phtml
@@ -0,0 +1,80 @@
+source == 'google'):?>
+
+
+ Cliché à l'approche de l'adresse postale.
+
+
+
+
+
+
+
+source == 'mappy'):?>
+
+
+
+
\ No newline at end of file
diff --git a/application/views/default/scripts/identite/fiche.phtml b/application/views/default/scripts/identite/fiche.phtml
index 0a05afbcb..88c1055fe 100644
--- a/application/views/default/scripts/identite/fiche.phtml
+++ b/application/views/default/scripts/identite/fiche.phtml
@@ -82,7 +82,7 @@ echo $this->partial('identite/fiche-item.phtml', $this->dBlock['EffectifEtab']);
AutrePage)):?>
-=$this->action('geophoto', 'geolocalisation', null, array('infos' => $this->infos));?>
+=$this->action('geo', 'identite', null, array('infos' => $this->infos));?>
=$this->action('news', 'identite');?>
diff --git a/application/views/default/scripts/identite/geo.phtml b/application/views/default/scripts/identite/geo.phtml
new file mode 100644
index 000000000..e539ed50d
--- /dev/null
+++ b/application/views/default/scripts/identite/geo.phtml
@@ -0,0 +1,37 @@
+Localisation géographique
+
+
+
+
+ Information géographique :
+ Latitude : =$this->decLat?> (=$this->infos->GeoLat?>)
+ Longitude : =$this->decLon?> (=$this->infos->GeoLon?>)
+
+
+ Afficher l'adresse sur Google Map ©
+
+
Code commune / Rivoli :
+ infos->Dept.' '.$this->infos->codeCommune.' / '.$this->infos->Rivoli; ?>
+ infos->InfosIris)>0){
+ $InfosIris = $this->infos->InfosIris;
+ $codComIris = str_replace($InfosIris->codIris, '', $InfosIris->codComIris);
+ ?>
+
Iris :
+ codIris*1 == 0){
+ ?>
+
Commune non découpée en Iris
+
+
Code : =$codComIris?> =$InfosIris->codIris?>
+
Libellé :
=$InfosIris->libIris?>
+
+
+
+
+
+facadeDisable):?>
+=$this->action('facade', 'identite', null, array('infos' => $this->infos));?>
+
+
+
\ No newline at end of file
diff --git a/library/Scores/Google.php b/library/Scores/Google.php
new file mode 100644
index 000000000..a2524b9b5
--- /dev/null
+++ b/library/Scores/Google.php
@@ -0,0 +1,49 @@
+0 )
+ return floor($dec);
+ else
+ return ceil($dec);
+ }
+
+ public function dec2dms($dec)
+ {
+ $d = $this->supprDecimales($dec);
+ $m = $this->supprDecimales(($dec - $d) * 60);
+ $s = abs(round(((($dec - $d) * 60) - $m) * 60));
+ $m = abs($m);
+ return $d.'°'.$m."'".$s.'"';
+ }
+
+ public function getGoogleMapLink($q)
+ {
+ return $this->url.$q;
+ }
+}
\ No newline at end of file
diff --git a/library/Scores/Mappy.php b/library/Scores/Mappy.php
new file mode 100644
index 000000000..ac515ca74
--- /dev/null
+++ b/library/Scores/Mappy.php
@@ -0,0 +1,76 @@
+login."@".$this->password."@".$timestamp);
+ $preToken = $this->login."@".$timestamp."@".$hash;
+ $urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]);
+ $fh = @fopen($urlGetToken, 'rb');
+
+ if ($fh == false) return false;
+ $token = '';
+ while (!feof($fh))$token .= fread($fh, 8192);
+ fclose($fh);
+ return ($token);
+ }
+
+ protected function cleanAdress($ville)
+ {
+ $ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' ';
+ $ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => '')));
+ return (ucwords(strtolower($ville)));
+ }
+
+ public function villeCouverte($ville)
+ {
+ $ville = $this->cleanAdress($ville);
+ if (in_array(strtoupper($ville),$this->villes)){
+ return true;
+ }
+ return false;
+ }
+
+ public function getJs()
+ {
+ $token = $this->getToken();
+ $href = 'http://axe.mappy.com/1v1/init/get.aspx?auth='.$token.'&version=2.01&solution=ajax';
+ return $href;
+ }
+
+}
\ No newline at end of file
diff --git a/library/geoLocalisation/geoLocalisation.lib.php b/library/geoLocalisation/geoLocalisation.lib.php
deleted file mode 100644
index aa243f6b4..000000000
--- a/library/geoLocalisation/geoLocalisation.lib.php
+++ /dev/null
@@ -1,126 +0,0 @@
-googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTTQao-JYbZvohjws19Eq-s8HocrxTKnnmfOnWxcHe01UHRIkRkZ1f17Q');
- case 'extranet.sd.lan':
- return ($this->googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRSKTEtsiH12Xc5SNL4Zmo_wRXVkrxR4jPIy3GOKGzZxBEOkvOsLG2CJ3w');
- case 'extranet-2.0.sd.lan':
- return ($this->googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTy4fRlC-SwcCZRiggZoieobzFAiRR6bORav5_Dl3324CqVALrh-ciGFQ');
- default:
- return (false);
-
- }
- return ($this->googleKey);
- }
-
- /**
- * Execute une requete cURL pour recuperer les infos XML
- * Traitement XML avec SimpleXml.
- *
- * @param marqueur bien formaté $marqueur
- */
- public function getCoordinates($marqueur)
- {
- // Pour les appelles statics. version dev pour la clef.
- (isset($this->googleKey))?$googleKey = $this->googleKey:$googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTTQao-JYbZvohjws19Eq-s8HocrxTKnnmfOnWxcHe01UHRIkRkZ1f17Q';
- (isset($this->googleUrl))?$googleUrl = $this->googleUrl:$googleUrl = 'http://maps.google.com/maps/geo?q=';
-
- $sep = ',';
- $cURL = curl_init();
- $user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
-
- $Url = $googleUrl . urlencode(
- $marqueur['adresse'].$sep.$marqueur['cp'].
- $sep.$marqueur['ville'].$sep.$marqueur['pays']).'&output=xml&key='.$googleKey;
-
- curl_setopt($cURL, CURLOPT_URL, $Url);
- curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, FALSE);
- //curl_setopt($cURL, CURLOPT_USERAGENT, $user_agent);
-
- $data = curl_exec($cURL);
-
- curl_close($cURL);
-
- if (isset($data) and !empty($data)) {
- $xml = new SimpleXMLElement($data);
- $result = simplexml_load_string($data);
- $explode = explode(',' ,$result->Response->Placemark->Point->coordinates);
- if (count($explode) == 3)
- $coordinates = $explode;
- else
- $coordinates = false;
- } else
- $coordinates = false;
- return ($coordinates);
- }
-
- public function getImage($coordonnees)
- {
- $image = 'http://cbk0.google.com/cbk?output=thumbnail&w=300&h=234&ll=';
-
- return ($image.$coordonnees[1].','.$coordonnees[0]);
- }
-
- public function supprDecimales($dec)
- {
- if ($dec>0 )
- return floor($dec);
- else
- return ceil($dec);
- }
-
- public function dec2dms($dec)
- {
- $d = self::supprDecimales($dec);
- $m = self::supprDecimales(($dec - $d) * 60);
- $s = abs(round(((($dec - $d) * 60) - $m) * 60));
- $m = abs($m);
- return $d.'°'.$m."'".$s.'"';
- }
-
- /**en cours **/
- protected function createListeOfAdress($listeEtablissement)
- {
- $coordonnes = array();
- $i = 0;
- $image = 'http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll=';
-
- foreach ($listeEtablissement->result->item as $etablissement)
- {
- $search = array();
- $search['adresse'] = str_replace(' ', '+', $etablissement->Adresse);
- $search['cp'] = str_replace(' ', '+', $etablissement->CP);
- $search['ville'] = str_replace(' ', '+', $etablissement->Ville);
- $search['pays'] = 'France';
- $valeur = self::getCoordinates($search);
- if ($valeur!=false) {
- $coordonnes[$i]['coordonnees'] = $valeur;
- $coordonnes[$i]['title'] = $etablissement->Enseigne;
- $coordonnes[$i]['content'] = 'Etablissement : '.$etablissement->Nic.'
'.
- $etablissement->Adresse.'
'.
- ''.$etablissement->CP.' '.$etablissement->Ville.'
'.
- $etablissement->Pays.'
'.''.'
'.
- $etablissement->NafEtab.' : '.$etablissement->NafEtabLib;
-
- }
- $i++;
- }
-
- return ($coordonnes);
- }
-}
\ No newline at end of file
diff --git a/public/themes/default/styles/geolocalisation.css b/public/themes/default/styles/geolocalisation.css
index 4b9da977c..bac8db377 100644
--- a/public/themes/default/styles/geolocalisation.css
+++ b/public/themes/default/styles/geolocalisation.css
@@ -1,7 +1,7 @@
#infogeo_txt {
float:left;
width:250px;
- padding:20px 0 0 20px;
+ padding:10px 0;
}
#infogeo_photo {