diff --git a/VERSIONS_HOTLINE/122399 b/VERSIONS_HOTLINE/122399 new file mode 100644 index 0000000000000000000000000000000000000000..bcc65e610bd95a36750d25196f068bd6c115ad96 --- /dev/null +++ b/VERSIONS_HOTLINE/122399 @@ -0,0 +1 @@ + - ticket #122399 : Magasin de thèmes : Ajout des horaires dans la carte open street map des exemplaires dans le thème Chili. \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderLibrary.php b/library/ZendAfi/View/Helper/RenderLibrary.php index 520d67961de3554f8baa3a0a7c6cdaf7c3eca2b2..a879561f0cee217a35197607995651a6de6d2fbd 100644 --- a/library/ZendAfi/View/Helper/RenderLibrary.php +++ b/library/ZendAfi/View/Helper/RenderLibrary.php @@ -122,11 +122,7 @@ class ZendAfi_View_Helper_RenderLibrary extends ZendAfi_View_Helper_BaseHelper { protected function renderOpeningHours() { - $openings = $this->library->getHoraire() - ? $this->library->getHoraire() - : $this->view->libraryOpenings($this->library); - - return $this->_renderField($this->_escapeInfo($openings), + return $this->_renderField($this->view->renderLibraryOpeningHours($this->library), 'field-opening-hours'); } @@ -182,9 +178,4 @@ class ZendAfi_View_Helper_RenderLibrary extends ZendAfi_View_Helper_BaseHelper { return $this->_tag('div', $content, $attributes); } - - - protected function _escapeInfo($info) { - return str_replace('BR', '<br>', urldecode(str_replace('%0D%0A','BR', $info))); - } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderLibraryOpeningHours.php b/library/ZendAfi/View/Helper/RenderLibraryOpeningHours.php new file mode 100644 index 0000000000000000000000000000000000000000..0fb0597b96b262787103b293608ee7b500830c10 --- /dev/null +++ b/library/ZendAfi/View/Helper/RenderLibraryOpeningHours.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH 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). + * + * BOKEH 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 BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_RenderLibraryOpeningHours extends ZendAfi_View_Helper_BaseHelper { + + public function renderLibraryOpeningHours($library) { + $openings = ($horaire = $library->getHoraire()) + ? $horaire + : $this->view->libraryOpenings($library); + + return str_replace('BR', '<br>', urldecode(str_replace('%0D%0A','BR', $openings))); + } +} diff --git a/library/templates/Chili/Library/Settings.php b/library/templates/Chili/Library/Settings.php index 76360860b01893a7450364611deec580a5e5648d..4875de466244a2fc5798f204eb44ac347b55aeaf 100644 --- a/library/templates/Chili/Library/Settings.php +++ b/library/templates/Chili/Library/Settings.php @@ -103,6 +103,8 @@ class Chili_Library_Settings extends Intonation_Library_Settings { $hydrating_mapping['div class user_informations_fields'] = 'card-body pl-0 pt-2'; $hydrating_mapping['dt class user_info'] = 'col-12'; $hydrating_mapping['dd class user_info'] = 'col-12'; + $hydrating_mapping['div class description_library_openings'] = 'col-12'; + $hydrating_mapping['div class description_library_opened'] = 'col-12'; $settings[$this->_template->withNameSpace('hydrating_mapping')] = $hydrating_mapping; return $settings; diff --git a/library/templates/Chili/Library/Wrapper/Library.php b/library/templates/Chili/Library/Wrapper/Library.php new file mode 100644 index 0000000000000000000000000000000000000000..2fa6df530d72ec12e1e3b3c0d7844a0a1cfad2a3 --- /dev/null +++ b/library/templates/Chili/Library/Wrapper/Library.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH 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). + * + * BOKEH 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 BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Chili_Library_Wrapper_Library extends Intonation_Library_View_Wrapper_Library { + protected function _renderOpening(){ + $html = [$this->_view->div(['class'=>'description_library_openings'], + $this->_view->renderLibraryOpeningHours($this->_model)), + + $this->_view->div(['class'=>'description_library_opened'], + parent::_renderOpening()) + ]; + + return $this->_view->grid($html, ['class' => 'description_library_opening_hours']); + } +} diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index bae693708b6195ddffa527c63fd717cdabe74181..3ec68b9403bd992da5681a04973a2612fdbe5288 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -118,6 +118,7 @@ class Chili_Template extends Intonation_Template { protected function _getMapWrapper() { return array_merge(parent::_getMapWrapper(), - ['Class_Notice' => 'Chili_Library_Wrapper_Record']); + ['Class_Notice' => 'Chili_Library_Wrapper_Record', + 'Class_Bib' => 'Chili_Library_Wrapper_Library']); } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php b/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php index 52f9a06ca7909637acc40f44263357d998491e19..16a0ff71f854c3e91d754c79a5ba4082105286b4 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php +++ b/library/templates/Intonation/Library/View/Wrapper/ItemForOsm.php @@ -27,9 +27,7 @@ class Intonation_Library_View_Wrapper_ItemForOsm extends Intonation_Library_View if (!$library = $this->_model->getBib()) return $description; - $wrapper = (new Intonation_Library_View_Wrapper_Library) - ->setModel($library) - ->setView($this->_view); + $wrapper = Class_Template::current()->newWrapper($library, $this->_view); return $description diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 70e84abab3fff7bbfd9c5c02e580795f6f5f37a3..508d16fd26cfc209fd29c0aef3c6d8589df97582 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -408,6 +408,7 @@ class Intonation_Template extends Class_Template { protected function _getMapWrapper() { - return ['Class_Notice' => 'Intonation_Library_View_Wrapper_Record']; + return ['Class_Notice' => 'Intonation_Library_View_Wrapper_Record', + 'Class_Bib' => 'Intonation_Library_View_Wrapper_Library']; } } diff --git a/library/templates/Intonation/View/Grid.php b/library/templates/Intonation/View/Grid.php index 9fd7684525cd53cc33d34fbe838d58ece0e1e49b..bb50c9dc8cbb1781a3c6549be0d16c3058b45ae4 100644 --- a/library/templates/Intonation/View/Grid.php +++ b/library/templates/Intonation/View/Grid.php @@ -26,6 +26,9 @@ class Intonation_View_Grid extends ZendAfi_View_Helper_BaseHelper { if (!$html) return ''; + if (is_array($html)) + $html = implode($html); + if (!isset($container_attribs['class'])) $container_attribs ['class'] = ''; diff --git a/tests/scenarios/Templates/ChiliLibraryOSMTest.php b/tests/scenarios/Templates/ChiliLibraryOSMTest.php new file mode 100644 index 0000000000000000000000000000000000000000..955a16ebc27f9de3789cfeaf3e7625fea0fafe68 --- /dev/null +++ b/tests/scenarios/Templates/ChiliLibraryOSMTest.php @@ -0,0 +1,109 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH 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). + * + * BOKEH 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 BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ChiliLibraryOSMInRecordItemsTest extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 25, + 'template' => 'CHILI']); + $this->fixture('Class_Notice', + ['id' => 153, + 'exemplaires' => [ + $this->fixture('Class_Exemplaire', + ['id' => 352, + 'id_bib' => 2 + ]), + $this->fixture('Class_Exemplaire', + ['id' => 353, + 'id_bib' => 3 + ]) + ] + ]); + + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => "Annecy", + 'id_lieu' => 3, + 'horaire' => 'Lundi : 9h00' + ]); + + $this->fixture('Class_Lieu', + ['id' => 3, + 'libelle' => "Bonlieu", + 'latitude' => '45.5', + 'longitude' => '5' + ]); + + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => "Dombes", + 'id_lieu' => 4 + ]); + + $this->fixture('Class_Lieu', + ['id' => 4, + 'libelle' => "Autrelieu", + 'latitude' => '49.5', + 'longitude' => '7' + ]); + + $this->fixture('Class_Ouverture', + ['id' => 10, + 'label' => 'Normal', + 'debut_matin' => '09:00', + 'jour_semaine' => Class_Ouverture::MARDI, + 'id_site' => 3 + ]); + + $this->dispatch('noticeajax/items-resources/id/153/id_profil/25'); + } + + + /** @test */ + public function dataOSMShouldContainsAnnecyOuvertLundiA9h00() { + $this->assertXPath('//div[contains(@id,"osm_map")][contains(@data-osm,"Lundi : 9h00")]'); + } + + + /** @test */ + public function dataOSMShouldContainsDombesOuvertMardiA15h00() { + $this->assertXPath('//div[contains(@id,"osm_map")][contains(@data-osm,"Mardi : 09h")]'); + } + + + /** @test */ + public function dataOSMShouldContainsClassLibraryOpeningsCol12() { + $this->assertXPath('//div[contains(@id,"osm_map")][contains(@data-osm,"description_library_openings col-12")]'); + } + + + /** @test */ + public function dataOSMShouldContainsClassLibraryOpenedCol12() { + $this->assertXPath('//div[contains(@id,"osm_map")][contains(@data-osm,"description_library_opened col-12")]'); + } +}