diff --git a/VERSIONS_HOTLINE/79363 b/VERSIONS_HOTLINE/79363 new file mode 100644 index 0000000000000000000000000000000000000000..72b7d0ef97bcc008b5fc66186fdd9efe848c1eaa --- /dev/null +++ b/VERSIONS_HOTLINE/79363 @@ -0,0 +1 @@ + - ticket #79363 : Cartes : Abandon de l'API Google, fourniture d'un service AFI pour génération des cartes statiques basées sur OpenStreetMap \ No newline at end of file diff --git a/application/modules/opac/views/scripts/index/planaccess.phtml b/application/modules/opac/views/scripts/index/planaccess.phtml deleted file mode 100644 index d62458f8e95620291f6cfe5039ae8ff22683ff5f..0000000000000000000000000000000000000000 --- a/application/modules/opac/views/scripts/index/planaccess.phtml +++ /dev/null @@ -1,52 +0,0 @@ -<script src="<?php echo URL_JS?>plan_acces.js"> </script> -<?php echo $this->mapEvents(); ?> -<script - src="https://maps.google.com/maps?file=api&v=2&key=<?php echo $this->googleKey?>" - type="text/javascript"></script> - -<link rel="stylesheet" - type="text/css" media="screen" - href="<?php echo URL_ADMIN_CSS;?>map.css" /> - -<script type="text/javascript"> -function initOCouches() -{ -<?php echo $this->oCouches; ?> -return oCouches; -} - -function initHIcone() -{ -<?php echo $this->hIcone; ?> -return hIcone; -} - -</script> -<div> -<span id="abonne_erreur" class="abonne"><?php echo $this->traduire($this->message); ?></span> - -<?php $this->openBoite("Plan d'accès")?> -<table class="map"> - <tr> - <td> - <ul class="map"> - - <?php for($couche=1; $couche<=count($this->map["couches"]); $couche++) - { - echo ('<a href="javascript:afficher_couche('.$couche.')"><li>'.stripslashes($this->map["couches"][$couche]["titre"]).'</li></a>'); - } ?> - - </ul> - </td> - </tr> - - <tr> - <td> - <div id="map" style="width: 630px; height: 570px"></div> - </td> - </tr> - -</table> -</div> - -<?php $this->closeBoite(); ?> diff --git a/cosmogramme/sql/patch/patch_355.php b/cosmogramme/sql/patch/patch_355.php new file mode 100644 index 0000000000000000000000000000000000000000..4ca530e9da3e4bf7bbd8a0c6830ce52b986295d6 --- /dev/null +++ b/cosmogramme/sql/patch/patch_355.php @@ -0,0 +1,3 @@ +<?php +Zend_Db_Table_Abstract::getDefaultAdapter() + ->query('update bib_admin_var set valeur="https://smap.afi-sa.net/staticmap.php" where clef="STATIC_MAP"'); diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 5398847ea2e615bc18efdadf5ddd6d817d3b4552..4388b4bd5cc6a62317f0a105b9cc79143eef1c84 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -309,7 +309,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader { . $this->_('De plus, à la connexion, l\'enregistrement des mots de passes des abonnés est désactivé.'))->bePrivate(), 'OAUTH_ACCEPT_HTTP' => Class_AdminVar_Meta::newOnOff($this->_('Autoriser l\'accès aux API OAUTH via HTTP (non sécurisé - déconseillé)'), ['value' => 0]), 'NB_AFFICH_AVIS_PAR_AUTEUR' => Class_AdminVar_Meta::newDefault($this->_('Nombre d\'avis maximum à afficher par utilisateur.')), - 'CLEF_GOOGLE_MAP' => Class_AdminVar_Meta::newDefault($this->_('Clef d\'activation pour le plan d\'accès google map. <a target="_blank" href="http://code.google.com/apis/maps/signup.html">Obtenir la clé google map</a>')), 'REGISTER_OK' => Class_AdminVar_Meta::newEncodedData($this->_('Texte visible par l\'internaute après son inscription.')), 'RESA_CONDITION' => Class_AdminVar_Meta::newEncodedData($this->_('Texte visible après l\'envoi d\'e-mail de demande de réservation.')), 'SITE_OK' => Class_AdminVar_Meta::newOnOff($this->_('Désactiver pour passer le site en maintenance')), @@ -449,10 +448,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { protected function _getStaticMapVars() { - return ['STATIC_MAP' => Class_AdminVar_Meta::newCombo($this->_('API utilisée pour les cartes statiques'), - ['options' => ['selectOptions' => ['label' => $this->_('API'), - 'value' => Class_Map::GOOGLE_API, - 'multioptions' => (new Class_Map())->getAPIs()]]])->bePrivate()]; + return ['STATIC_MAP' => Class_AdminVar_Meta::newDefault($this->_('URL utilisée pour les cartes statiques, doit être compatible avec https://github.com/dfacts/staticmaplite'), + ['value' => 'https://smap.afi-sa.net/staticmap.php'])->bePrivate()]; } @@ -569,13 +566,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader { } - public function getStaticMapApi() { - return ($api = static::get('STATIC_MAP')) - ? $api - : Class_Map::GOOGLE_API; - } - - /** * @return bool */ diff --git a/library/Class/Map.php b/library/Class/Map.php index 7aad6b65e7a7f12be49bc8d0ba1c135d77bfb77f..47395d0dbedfcf64b5f48f8b2f830786cf378706 100644 --- a/library/Class/Map.php +++ b/library/Class/Map.php @@ -21,46 +21,28 @@ class Class_Map extends Class_Entity { - const - ZOOM = 15, - GOOGLE_API = 'maps.googleapis.com', - OSM_API = 'staticmap.openstreetmap.de'; - - - public static function getAPIs() { - $apis = [static::GOOGLE_API, - static::OSM_API]; - return array_combine($apis, $apis); - } - + const ZOOM = 15; public static function newWith($location) { - $class = Class_AdminVar::getStaticMapApi() == static::GOOGLE_API - ? 'Class_Map_Google' - : 'Class_Map_OSM'; - - return (new $class()) - ->setLocation($location); + return (new static())->setLocation($location); } -} - -class Class_Map_OSM extends Class_Map { public function __construct() { $this->setLabel('osm'); } public function getStaticMapUrl($params) { - if(!$full_adress = $this->getFullAdress()) + if (!$full_adress = $this->getFullAdress()) return ''; $params = array_merge(['center' => $full_adress, 'markers' => $full_adress], $params); - return sprintf('http://staticmap.openstreetmap.de/staticmap.php?%s', http_build_query($params)); + + return Class_AdminVar::getValueOrDefault('STATIC_MAP') . '?' . http_build_query($params); } @@ -88,43 +70,3 @@ class Class_Map_OSM extends Class_Map { return sprintf('https://openstreetmap.org/?%s', http_build_query($params)); } } - - - -class Class_Map_Google extends Class_Map { - public function __construct() { - $this->setLabel('google'); - } - - - public function getStaticMapUrl($params) { - if(!$full_adress = $this->getFullAdress()) - return ''; - - $params = array_merge(['sensor' => 'false', - 'center' => $full_adress, - 'markers' => $full_adress], - $params); - - return sprintf('https://maps.googleapis.com/maps/api/staticmap?%s', http_build_query($params)); - } - - - public function getFullAdress() { - if(!$location = $this->getLocation()) - return ''; - - if (($latitude = $location->getLatitude()) && ($longitude = $location->getLongitude())) - return $latitude . ',' . $longitude; - - return implode(',', [$location->getAdresse(), - $location->getCodePostal(), - $location->getVille(), - $location->getPays()]); - } - - - public function getFullMapUrl() { - return sprintf('https://maps.google.com/maps?%s', http_build_query(['q' => $this->getFullAdress()])); - } -} \ No newline at end of file diff --git a/library/ZendAfi/Acl/AdminControllerRoles.php b/library/ZendAfi/Acl/AdminControllerRoles.php index d95fe0bcf58a2b5abbede66c11c31337003532b3..1f58989f51d3c0065eef955c5f5fd9790a615d57 100644 --- a/library/ZendAfi/Acl/AdminControllerRoles.php +++ b/library/ZendAfi/Acl/AdminControllerRoles.php @@ -57,7 +57,6 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl { $this->add(new Zend_Acl_Resource('modo')); $this->add(new Zend_Acl_Resource('nouveaute')); $this->add(new Zend_Acl_Resource('panier')); - $this->add(new Zend_Acl_Resource('planaccess')); $this->add(new Zend_Acl_Resource('rss')); $this->add(new Zend_Acl_Resource('sito')); $this->add(new Zend_Acl_Resource('menus')); diff --git a/tests/application/modules/admin/controllers/LieuControllerTest.php b/tests/application/modules/admin/controllers/LieuControllerTest.php index eb86104220b8794b1530990ff62400ee057ce60b..638832ff8c484024858aa5d4241edf7cc20706e3 100644 --- a/tests/application/modules/admin/controllers/LieuControllerTest.php +++ b/tests/application/modules/admin/controllers/LieuControllerTest.php @@ -25,6 +25,7 @@ abstract class LieuControllerTestCase extends AbstractControllerTestCase { parent::setUp(); Class_AdminVar::set('ACTIVITY', 0); + $this->afi_annecy = $this->fixture('Class_Lieu', ['id' => 3, 'libelle' => 'AFI Annecy', @@ -43,12 +44,6 @@ abstract class LieuControllerTestCase extends AbstractControllerTestCase { 'latitude' => '48,825853', 'longitude' => '2,630163']); } - - - public function tearDown() { - Class_AdminVar::set('STATIC_MAP', Class_Map::GOOGLE_API); - parent::tearDown(); - } } @@ -287,12 +282,6 @@ class LieuControllerEditAnnecyTest extends LieuControllerTestCase { public function villeShouldContainsAnnecy() { $this->assertXPath('//input[@name="ville"][@value="Annecy"]'); } - - - /** @test */ - public function pageShouldContainsStaticGoogleImage() { - $this->assertXPath('//img[@src="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er=11%2C+boulevard+du+fier%2C74000%2CAnnecy%2CFrance&markers=11%2C+boulevard+du+fier%2C74000%2CAnnecy%2CFrance&zoom=15&size=200x200"]'); - } } @@ -317,8 +306,8 @@ class LieuControllerEditLognesTest extends LieuControllerTestCase { /** @test */ - public function pageShouldContainsStaticGoogleImage() { - $this->assertXPath('//img[@src="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er=48%2C825853%2C2%2C630163&markers=48%2C825853%2C2%2C630163&zoom=15&size=200x200"]', + public function pageShouldContainsStaticImage() { + $this->assertXPath('//img[@src="https://smap.afi-sa.net/staticmap.php?center=48%2C825853%2C2%2C630163&markers=48%2C825853%2C2%2C630163&zoom=15&size=200x200"]', $this->_response->getBody()); } } @@ -523,7 +512,6 @@ class LieuControllerUpdateCoordinatesForLocationActionTest extends LieuControlle class LieuControllerStaticMapOsmTest extends LieuControllerTestCase { public function setUp() { parent::setUp(); - Class_AdminVar::set('STATIC_MAP', Class_Map::OSM_API); $this->afi_annecy->setLatitude('45.798789') ->setLongitude('6.456123'); $this->dispatch('/admin/lieu/edit/id/3', true); @@ -532,7 +520,7 @@ class LieuControllerStaticMapOsmTest extends LieuControllerTestCase { /** @test */ public function pageShouldContainsStaticOSMImage() { - $this->assertXPath('//img[@src="http://staticmap.openstreetmap.de/staticmap.php?center=45.798789%2C6.456123&markers=45.798789%2C6.456123&zoom=15&size=200x200"]', + $this->assertXPath('//img[@src="https://smap.afi-sa.net/staticmap.php?center=45.798789%2C6.456123&markers=45.798789%2C6.456123&zoom=15&size=200x200"]', $this->_response->getBody()); } } \ No newline at end of file diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 7b3871eb6b5e11fa0a72222972dec5a1a7432228..65895b80de7aa3e1a0267926fa654275ab942cfd 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2253,4 +2253,21 @@ class UpgradeDB_354_Test extends UpgradeDBTestCase { public function codifEmplacementLibelleShouldBeMigratedToVarchar255() { $this->assertFieldType('codif_emplacement', 'libelle', 'varchar(255)'); } -} \ No newline at end of file +} + + + + +class UpgradeDB_355_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery('update bib_admin_var set valeur="static.openstreetmap.de" where clef="STATIC_MAP"'); + } + + + /** @test */ + public function staticMapShouldDefaultToAfiServer() { + $datas = $this->query('select valeur from bib_admin_var where clef="STATIC_MAP"')->fetch(); + $this->assertEquals('https://smap.afi-sa.net/staticmap.php', + $datas['valeur']); + } +}