From f535b4f1cec87f94fd4285a0b04e20ded239c2aa Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Wed, 25 Apr 2012 10:16:22 +0000 Subject: [PATCH] Affichage des lieux + liens google map --- .gitattributes | 1 + .../admin/views/scripts/lieu/_lieu.phtml | 9 ++--- .../admin/views/scripts/lieu/index.phtml | 13 +++++-- .../views/scripts/abonne/detail-session.phtml | 4 +-- library/Class/Lieu.php | 3 ++ library/Class/Users.php | 4 ++- library/ZendAfi/View/Helper/MapForLieu.php | 17 ++++++--- library/ZendAfi/View/Helper/RenderLieu.php | 33 +++++++++++++++++ public/admin/css/global.css | 10 ++++++ public/opac/css/global.css | 6 +++- .../admin/controllers/LieuControllerTest.php | 12 +++---- .../AbonneControllerFormationsTest.php | 35 +++++++++++++++---- 12 files changed, 121 insertions(+), 26 deletions(-) create mode 100644 library/ZendAfi/View/Helper/RenderLieu.php diff --git a/.gitattributes b/.gitattributes index 8b90c09eb31..8b1e5725625 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1944,6 +1944,7 @@ library/ZendAfi/View/Helper/Portail.php -text library/ZendAfi/View/Helper/ReadSpeaker.php -text library/ZendAfi/View/Helper/RenderAlbum.php -text library/ZendAfi/View/Helper/RenderForm.php -text +library/ZendAfi/View/Helper/RenderLieu.php -text library/ZendAfi/View/Helper/ReseauxSociaux.php -text library/ZendAfi/View/Helper/Subwords.php -text library/ZendAfi/View/Helper/TagAnchor.php -text diff --git a/application/modules/admin/views/scripts/lieu/_lieu.phtml b/application/modules/admin/views/scripts/lieu/_lieu.phtml index 62838fe1abb..10728f419fa 100644 --- a/application/modules/admin/views/scripts/lieu/_lieu.phtml +++ b/application/modules/admin/views/scripts/lieu/_lieu.phtml @@ -1,7 +1,8 @@ -<li class="<?php echo $this->item_class ?>"> +<tr class="<?php echo $this->item_class ?>"> <?php - echo sprintf("<div></div><div>%s</div>", $this->lieu->getLibelle()); - echo sprintf("<div class='actions'>%s %s</div>", + echo sprintf("<td>%s</td>", $this->mapForLieu($this->lieu, array('size' => '100x100', 'zoom' => '12'))); + echo sprintf("<td>%s</td>", $this->lieu->getLibelle()); + echo sprintf("<td>%s %s</td>", $this->tagAnchor(array('action' => 'edit', 'id' => $this->lieu->getId()), $this->boutonIco("type=edit")), @@ -10,4 +11,4 @@ 'id' => $this->lieu->getId()), $this->boutonIco("type=del"))); ?> -</li> \ No newline at end of file +</tr> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/lieu/index.phtml b/application/modules/admin/views/scripts/lieu/index.phtml index d2631845e61..8f439419da7 100644 --- a/application/modules/admin/views/scripts/lieu/index.phtml +++ b/application/modules/admin/views/scripts/lieu/index.phtml @@ -7,11 +7,20 @@ echo $this->bouton('id=add', ); ?> -<ul class="tree"> +<table class="lieux"> + <thead> + <tr class="soustitre"> + <td>Carte</td> + <td>Libellé</td> + <td></td> + </tr> + </thead> + <tbody> <?php echo $this->partialCycle('lieu/_lieu.phtml', 'lieu', $this->lieux, array('first', 'second')); ?> -</ul> \ No newline at end of file + </tbody> +</table> \ No newline at end of file diff --git a/application/modules/opac/views/scripts/abonne/detail-session.phtml b/application/modules/opac/views/scripts/abonne/detail-session.phtml index a5d9d474ba5..2608bee03c1 100644 --- a/application/modules/opac/views/scripts/abonne/detail-session.phtml +++ b/application/modules/opac/views/scripts/abonne/detail-session.phtml @@ -8,7 +8,7 @@ echo $this->openBoite(sprintf('Formation %s: session du %s', <dl class="session_formation"> <dt><?php echo $this->_('Lieu') ?></dt> - <dd><?php echo $this->session->getLibelleLieu() ?></dd> + <dd><?php echo $this->renderLieu($this->session->getLieu(), array('size' => '300x300')) ?></dd> <dt><?php echo $this->_('Horaires') ?></dt> @@ -33,7 +33,7 @@ echo $this->openBoite(sprintf('Formation %s: session du %s', <ul> <?php foreach ($this->session->getIntervenants() as $intervenant) - echo sprintf('<li>%s</li>', $intervenant->getNomAff()); + echo sprintf('<li>%s, %s</li>', $intervenant->getNom(), $intervenant->getPrenom()); ?> </ul> </dd> diff --git a/library/Class/Lieu.php b/library/Class/Lieu.php index 30317b9d169..2dd4dc7d9e5 100644 --- a/library/Class/Lieu.php +++ b/library/Class/Lieu.php @@ -22,6 +22,9 @@ class Class_Lieu extends Storm_Model_Abstract { protected $_table_name = 'lieux'; protected $_default_attribute_values = array('libelle' => '', + 'adresse' => '', + 'ville' => '', + 'code_postal' => '', 'pays' => 'FRANCE'); public static function getLoader() { diff --git a/library/Class/Users.php b/library/Class/Users.php index 19106486c9d..7012967ab48 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -163,7 +163,9 @@ class Class_Users extends Storm_Model_Abstract { 'naissance' => '', 'date_debut' => 0, 'telephone' => '', - 'mail' => '' + 'mail' => '', + 'nom' => '', + 'prenom' => '' ); protected $_translate; diff --git a/library/ZendAfi/View/Helper/MapForLieu.php b/library/ZendAfi/View/Helper/MapForLieu.php index ab4e8fb6d5e..d5bfc0baa0b 100644 --- a/library/ZendAfi/View/Helper/MapForLieu.php +++ b/library/ZendAfi/View/Helper/MapForLieu.php @@ -20,7 +20,7 @@ */ class ZendAfi_View_Helper_MapForLieu extends Zend_View_Helper_HtmlElement { - public function mapForLieu($lieu) { + public function mapForLieu($lieu, $options=null) { $full_adresse = implode(',', array($lieu->getAdresse(), $lieu->getCodePostal(), @@ -32,10 +32,19 @@ class ZendAfi_View_Helper_MapForLieu extends Zend_View_Helper_HtmlElement { 'size' => '200x200', 'center' => $full_adresse, 'markers' => $full_adresse); - - return sprintf('<img src="http://maps.googleapis.com/maps/api/staticmap?%s" alt="%s"/>', + + if (is_array($options)) + $params = array_merge($params, $options); + + return sprintf('<img style="cursor:pointer" '. + 'class="google_static_map" '. + 'src="http://maps.googleapis.com/maps/api/staticmap?%s" '. + 'alt="%s" '. + 'onclick="window.open(\'http://maps.google.com/maps?%s\');return false;" />', + http_build_query($params), - $lieu->getLibelle()); + $lieu->getLibelle(), + http_build_query(array('q' => $full_adresse))); } } diff --git a/library/ZendAfi/View/Helper/RenderLieu.php b/library/ZendAfi/View/Helper/RenderLieu.php new file mode 100644 index 00000000000..56c82833955 --- /dev/null +++ b/library/ZendAfi/View/Helper/RenderLieu.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_RenderLieu extends Zend_View_Helper_HtmlElement { + public function renderLieu($lieu, $map_options = null) { + $adresse = nl2br($lieu->getAdresse()).'<br/>'.$lieu->getCodePostal().' '.$lieu->getVille(); + + return sprintf('<div class="lieu">%s %s <p>%s</p></div>', + $this->view->mapForLieu($lieu, $map_options), + $lieu->getLibelle(), + $adresse); + } +} + +?> \ No newline at end of file diff --git a/public/admin/css/global.css b/public/admin/css/global.css index 17212db4f71..5bf787925be 100644 --- a/public/admin/css/global.css +++ b/public/admin/css/global.css @@ -888,4 +888,14 @@ div.impressions .actions{ .edit_lieu form { width: 480px; +} + + +table.lieux td:first-child { + width: 100px; +} + + +table.lieux td:last-child { + width: 48px; } \ No newline at end of file diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 21417a57543..ca54e13937e 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -731,7 +731,6 @@ dl.session_formation { dl.session_formation dt { display: block; - border-bottom: 1px solid black; font-size: 1.2em; font-weight: bold; } @@ -831,4 +830,9 @@ dl.session_formation + .actions a:last-child { padding:5px; color:#476777; background-color:#DFE7EF; +} + + +.lieu img { + float: right; } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/LieuControllerTest.php b/tests/application/modules/admin/controllers/LieuControllerTest.php index 199d50f4c7f..eed33597d9b 100644 --- a/tests/application/modules/admin/controllers/LieuControllerTest.php +++ b/tests/application/modules/admin/controllers/LieuControllerTest.php @@ -67,26 +67,26 @@ class LieuControllerListTest extends LieuControllerTestCase { /** @test */ - public function aListItemShouldContainsAnnecy() { - $this->assertXPathContentContains('//ul//li[1]', 'AFI Annecy'); + public function tableShouldContainsAnnecy() { + $this->assertXPathContentContains('//tr[1]//td', 'AFI Annecy'); } /** @test */ - public function aListItemShouldContainsLognes() { - $this->assertXPathContentContains('//ul//li[2]', 'AFI Lognes'); + public function tableShouldContainsLognes() { + $this->assertXPathContentContains('//tr[2]//td', 'AFI Lognes'); } /** @test */ public function annecyShouldHaveLinkToEdit() { - $this->assertXPath('//ul//li[1]//a[contains(@href, "lieu/edit/id/3")]'); + $this->assertXPath('//tr[1]//a[contains(@href, "lieu/edit/id/3")]'); } /** @test */ public function annecyShouldHaveLinkToDelete() { - $this->assertXPath('//ul//li[1]//a[contains(@href, "lieu/delete/id/3")]'); + $this->assertXPath('//tr[1]//a[contains(@href, "lieu/delete/id/3")]'); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index 94725d86e48..d982e112982 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -59,7 +59,10 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro $this->_bonlieu = Class_Lieu::getLoader() ->newInstanceWithId(100) - ->setLibelle('Bonlieu'); + ->setLibelle('Bonlieu') + ->setAdresse("1, rue Jean-Jaures\nBP 294") + ->setCodePostal(74007) + ->setVille('Annecy'); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') ->whenCalled('save')->answers(true); @@ -141,10 +144,15 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro ->setLieu($this->_bib_romains) ->setIntervenants( array(Class_Users::getLoader() ->newInstanceWithId(76) - ->setLogin('jpp'), + ->setLogin('jpp') + ->setPrenom('Jean-Paul') + ->setNom('Pirant'), + Class_Users::getLoader() ->newInstanceWithId(77) - ->setLogin('cm')) ) )) + ->setLogin('cc') + ->setPrenom('Christophe') + ->setNom('Cerisier')) ) )) )); $this->_amadou = Class_Users::getLoader() @@ -566,6 +574,21 @@ class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneCon $this->assertXPathContentContains('//dl/dd', 'minimum: 2, maximum: 5, actuel: 0'); } + + /** @test */ + function ddShouldContainsAdresseBonlieu() { + $this->assertXPathContentContains('//dd', 'Bonlieu'); + $this->assertXPathContentContains('//dd', '1, rue Jean-Jaures'); + $this->assertXPathContentContains('//dd', '74007 Annecy'); + } + + + /** @test */ + function ddShouldContainsGoogleMap() { + $this->assertXPath('//dd//img[@src="http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=15&size=300x300¢er=1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE&markers=1%2C+rue+Jean-Jaures%0ABP+294%2C74007%2CAnnecy%2CFRANCE"]', + $this->_response->getBody()); + } + } @@ -639,13 +662,13 @@ class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractA /** @test */ public function ddIntervenantsShouldContainsJpp() { - $this->assertXPathContentContains('//dd//li', 'jpp'); + $this->assertXPathContentContains('//dd//li', 'Pirant, Jean-Paul'); } /** @test */ - public function ddIntervenantsShouldContainsCm() { - $this->assertXPathContentContains('//dd//li', 'cm'); + public function ddIntervenantsShouldContainsCc() { + $this->assertXPathContentContains('//dd//li', 'Cerisier, Christophe'); } } -- GitLab