diff --git a/VERSIONS_HOTLINE/122293 b/VERSIONS_HOTLINE/122293 new file mode 100644 index 0000000000000000000000000000000000000000..1889c335f2336602bdbff57696a582c12f4ae4fb --- /dev/null +++ b/VERSIONS_HOTLINE/122293 @@ -0,0 +1 @@ + - ticket #122293 : Magasin de thèmes : Amélioration de l'affichage du lieu dans la page article. \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 278dcadd536b65e318046d5d641f8a5e85772ce8..f36bc69d2d5ec73c4869ff7135437adfef376726 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -242,6 +242,14 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class review_date' => 'col-12 col-lg-6 text-md-right', 'div class card_with_overlay' => 'card text-center', 'div class card_overlay' => 'card-block card-img-overlay rounded text-center text-white', + 'div class article_location_header' => 'col-12 order-1', + 'div class article_location_static_map' => 'col-12 col-md-6 col-xl-4 order-3 order-md-2 pt-md-5 px-5 px-md-0', + 'div class article_location_data' => 'col-12 col-md-6 col-xl-4 order-2 order-md-3', + 'span class badge_article_draft' => 'badge-danger', + 'a class badge_article_library' => 'badge-primary no_truncate', + 'span class badge_article_category' => 'badge-info', + 'span class badge_article_location' => 'badge-secondary no_truncate' + ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 95a5c02481d328fafccbf797bb643db00be5750a..4f2503d96bd7fd69790ed6241d022d36f21e0f45 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -108,6 +108,13 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + protected function _getInUtilsIco($ico_key) { + return Class_Template::current()->getIco($this->_view, + $ico_key, + 'utils'); + } + + protected function _truncate($text) { $number_of_word = $this->_widget_context ? $this->_widget_context->getDescriptionLength() diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index f1f110e4c481051b25c93017d73b633d2ed1a2e2..94b9658df58d221bab086ed7ef9eb118c5932433 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -115,7 +115,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr if ($this->_model->isStatusDraft()) $badges [] = ((new Intonation_Library_Badge) ->setTag('span') - ->setClass('badge-danger') + ->setClass('badge_article_draft') ->setText($this->_('Brouillon')) ->setTitle($this->_('Cet article "%s" est un brouillon.', $title))); @@ -125,7 +125,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr ->setUrl($this->_view->url(['controller' => 'bib', 'action' => 'en-lire-plus', 'id' => $library->getId()])) - ->setClass('badge-primary') + ->setClass('badge_article_library') ->setImage(Class_Template::current() ->getIco($this->_view, 'library', @@ -133,18 +133,16 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr ->setText($library->getLibelle()) ->setTitle($this->_('Bibliothèque de l\'article "%s"', $title))); - $badges [] = ((new Intonation_Library_Badge) - ->setTag('span') - ->setClass('badge-info') - ->setText($this->_model->getCategorieLibelle()) - ->setTitle($this->_('Catégorie de l\'article "%s"', $title))); - - if ($location = $this->_model->getLieuLibelle()) + if ( $library && $library->isPortail() && ($location = $this->_model->getLieuLibelle())) $badges [] = ((new Intonation_Library_Badge) ->setTag('span') - ->setClass('badge-secondary') - ->setText($location) - ->setTitle($this->_('Lieu relié à l\'article "%s"', $title))); + ->setClass('badge_article_location') + ->setText($location)); + + $badges [] = ((new Intonation_Library_Badge) + ->setTag('span') + ->setClass('badge_article_category') + ->setText($this->_model->getCategorieLibelle())); $badges = $this->_addEventsBadges($badges); @@ -268,7 +266,15 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr return null; return new Intonation_Library_OsmData(['lat' => $location->getLatitude(), - 'lon' => $location->getLongitude()]); + 'lon' => $location->getLongitude(), + 'wrapper' => $this->_wrapperForOsmRendering($location)]); + } + + + protected function _wrapperForOsmRendering($location) { + return ($library = Class_Bib::findFirstBy(['id_lieu' => $location->getId()])) + ? new Intonation_Library_View_Wrapper_Library($library, $this->_view) + : new Intonation_Library_View_Wrapper_Location($location, $this->_view); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Location.php b/library/templates/Intonation/Library/View/Wrapper/Location.php new file mode 100644 index 0000000000000000000000000000000000000000..debcb1c685d7193d7638b7e39e3c7391eb1e2661 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Location.php @@ -0,0 +1,135 @@ +<?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 Intonation_Library_View_Wrapper_Location extends Intonation_Library_View_Wrapper_Abstract { + + public function getMainTitle() { + return $this->_model->getLibelle(); + } + + + public function getSecondaryTitle() { + } + + + public function getDescription() { + return $this->getBadges(); + } + + + public function getFullDescription() { + return $this->getDescription(); + } + + + public function getDescriptionTitle() { + return ''; + } + + + public function getMainLink() { + return null; + } + + + public function getSecondaryLink() { + return null; + } + + + public function getSecondaryIco() { + return null; + } + + + public function getBadges() { + $badges = [ + (new Intonation_Library_Badge) + ->setTag('address') + ->setClass('badge_address') + ->setText(sprintf('%s %s %s', + $this->_model->getAdresse(), + $this->_model->getCodePostal(), + $this->_model->getVille())), + + (new Intonation_Library_Badge) + ->setTag('a') + ->setUrl(sprintf('tel:%s', $this->_model->getTelephone())) + ->setClass('badge_phone') + ->setImage($this->_getInUtilsIco('phone')) + ->setText($this->_model->getTelephone()) + ->setTitle($this->_('Téléphoner à %s', + $this->_model->getLibelle())), + + (new Intonation_Library_Badge) + ->setTag('a') + ->setClass('badge_mail') + ->setImage($this->_getInUtilsIco('email')) + ->setUrl(sprintf('mailto:%s', $this->_model->getMail())) + ->setText($this->_model->getMail()) + ->setTitle($this->_('Envoyer un e-mail à %s', + $this->_model->getLibelle())) + ]; + + return $this->_view->renderBadges($badges, $this); + } + + + public function getPicture() { + return ''; + } + + + public function getPictureAction() { + return ''; + } + + + public function getDocType() { + return ''; + } + + + public function getDocTypeLabel() { + return ''; + } + + + public function getActions() { + return []; + } + + + public function getEmbedMedia() { + return ''; + } + + + public function getHtmlPicture() { + return ''; + } + + + public function getOsmData() { + return null; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderArticle.php b/library/templates/Intonation/View/RenderArticle.php index 5d22038fed566b9bfe489986c7e6b868a817c137..97a1a689ac903d1ecca50c3a625be2dfd281519f 100644 --- a/library/templates/Intonation/View/RenderArticle.php +++ b/library/templates/Intonation/View/RenderArticle.php @@ -27,21 +27,32 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { ->setModel($article) ->setView($this->view); + $osm = $this->view->mapForLieu($article->getLieu(), ['size' => '']); + + $grid_content = [$this->_div(['class' => 'article_location_header'], + $this->_tag('h2', $this->_('Lieu de l\'événement'))), + + $this->_div(['class' => 'article_location_static_map'], + $osm)]; + + if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper())) + $grid_content [] = $this->_div(['class' => 'article_location_data'], + $this->view->cardify($osm_wrapper)); + + $location_content = $this->view->grid(implode($grid_content)); + $body_content = [$article->getCacherTitre() ? '' : $this->_tag('h2', $article->getTitre(), ['class' => 'card-title']), - $this->_badges($wrapper), + $wrapper->getBadges(), $this->view->tagArticleEvent($article), $this->_tag('p', $this->view->article_ReplaceWidgets($article->getFullContent()), ['class' => 'card-text']), - - $this->view->renderLieu($article->getLieu(), - ['size' => '300x200']) - ]; + $location_content]; $body = $this->_tag('div', implode($body_content), @@ -54,9 +65,4 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { . $footer, ['class' => 'card card_article']); } - - - protected function _badges($wrapper) { - return $wrapper->getBadges(); - } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderLieu.php b/library/templates/Intonation/View/RenderLieu.php deleted file mode 100644 index de6e61d34b7079dcac92ef0332f37a372df7817c..0000000000000000000000000000000000000000 --- a/library/templates/Intonation/View/RenderLieu.php +++ /dev/null @@ -1,66 +0,0 @@ -<?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 Intonation_View_RenderLieu extends ZendAfi_View_Helper_RenderLieu { - protected function _renderMedia($map, $title, $address) { - return $this->_tag('div', - $map - . $this->_tag('div', - $this->_tag('h5', - $title, - ['class' => 'mt-0']) - . $address, - ['class' => 'media-body ml-3']), - ['class' => 'media col-12']); - } - - - protected function _renderAddress($lieu) { - $html = [ $this->_tag('address', - nl2br($lieu->getAdresse()) - . '<br/>' - . $lieu->getCodePostal() . ' ' . $lieu->getVille()) ]; - - if ($phone = $lieu->getTelephone()) - $html []= $this->_renderAction(['Url' => 'tel:' . $phone, - 'Image' => Class_Template::current()->getIco($this->view, - 'phone', - 'utils'), - 'Text' => $phone, - 'Title' => $this->_('Composer le numéro %s', $phone)]); - - if ($mail = $lieu->getMail()) - $html []= $this->_renderAction(['Url' => 'mailto:' . $mail, - 'Image' => Class_Template::current()->getIco($this->view, - 'email', - 'utils'), - 'Text' => $mail, - 'Title' => $this->_('Envoyer un courrier à %s', $mail)]); - - return implode('<br/>', $html); - } - - - protected function _renderAction($params) { - return $this->view->tagAction(new Intonation_Library_Link($params)); - } -} diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index dd81ff23722063911137b4fdb1262bd05f6d4949..3dde55116f4d56a25677c7ab6c717156f3be1380 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -228,7 +228,7 @@ class MuscleTemplateProfilePatcherTest extends MuscleTemplateTestCase { /** @test */ public function calendarWidgetShouldContainsBadgeInfoTESTING() { - $this->assertXPathContentContains('//div[contains(@class, "boite calendar")]//span[contains(@class,"badge-info text-left badge")]', + $this->assertXPathContentContains('//div[contains(@class, "boite calendar")]//span[contains(@class,"badge_article_category text-left badge badge-info")]', 'TESTING'); } } diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index fc62d23a67494011e6b1adcc20083a423db4b89d..3e9e213cd23829da8004161571bdbf5f1d75a717 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -351,28 +351,28 @@ class TemplatesArticlesWithLocationViewTest extends TemplatesArticlesWithLocatio /** @test */ - public function mediaDivShouldContainsStaticMap() { - $this->assertXPath('//div[contains(@class, "media")]//img[contains(@src,"https://smap.afi-sa.net/staticmap.php")]'); + public function locationDivShouldContainsStaticMap() { + $this->assertXPath('//div[@class = "article_location_static_map col-12 col-md-6 col-xl-4 order-3 order-md-2 pt-md-5 px-5 px-md-0"]//img[contains(@src,"https://smap.afi-sa.net/staticmap.php")]'); } /** @test */ - public function mediaDivShouldContainsAddressAnnecy() { - $this->assertXPathContentContains('//div[contains(@class, "media")]//address', + public function locationDivShouldContainsAddressAnnecy() { + $this->assertXPathContentContains('//div[contains(@class, "badge-group badge_group badge_group_Intonation_Library_View_Wrapper_Location")]//address', 'Rue des tomates'); } /** @test */ public function mediaDivShouldLinkToPhone01_23_87_38_47() { - $this->assertXPathContentContains('//div[contains(@class, "media")]//a[@href="tel:01 23 87 38 47"]', + $this->assertXPathContentContains('//div[@class="badge-group badge_group badge_group_Intonation_Library_View_Wrapper_Location"]//a[@href="tel:01 23 87 38 47"]', '01 23 87 38 47'); } /** @test */ public function mediaDivShouldLinkToMailContactAtAnnecy() { - $this->assertXPathContentContains('//div[contains(@class, "media")]//a[@href="mailto:contact@annecy.fr"]', + $this->assertXPathContentContains('//div[@class="badge-group badge_group badge_group_Intonation_Library_View_Wrapper_Location"]//a[@href="mailto:contact@annecy.fr"]', 'contact@annecy.fr'); } } @@ -380,6 +380,84 @@ class TemplatesArticlesWithLocationViewTest extends TemplatesArticlesWithLocatio +class TemplatesArticlesWithLocationRelatedToLibraryViewTest extends TemplatesArticlesWithLocationTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Bib', + ['id' => 123, + 'libelle' => 'Médiathèque d\'annecy', + 'id_lieu' => 4156465]); + + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + } + + + /** @test */ + public function linkToMediathequeAnnecyShouldBePresent() { + $this->assertXPathContentContains('//div[@class="article_location_data col-12 col-md-6 col-xl-4 order-2 order-md-3"]//div[@class="card card_template card_Intonation_Library_View_Wrapper_Library"]//a[contains(@href, "bib/en-lire-plus/id/123")]', 'Médiathèque d\'annecy'); + } +} + + + + +class TemplatesArticlesBadgesTest extends TemplatesArticlesWithLocationTestCase { + /** @test */ + public function articleBadgeDraftShouldBeBadgeDanger() { + Class_AdminVar::set('WORKFLOW', 1); + $article = Class_Article::find(7)->beDraft(); + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + $this->assertXPath('//span[@class="badge_tag badge_article_draft text-left badge badge-danger"]'); + } + + + + /** @test */ + public function articleBadgeLibraryShouldBeBadgePrimaryNoTruncate() { + $this->fixture('Class_Bib', + ['id' => 123, + 'libelle' => 'Médiathèque d\'annecy', + 'id_lieu' => 4156465]); + + $this->fixture('Class_ArticleCategorie', + ['id' => 12374832, + 'libelle' => 'annecy', + 'id_site' => 123]); + + $article = Class_Article::find(7) + ->setIdCat(12374832); + + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + $this->assertXPathContentContains('//a[@class="badge_tag badge_article_library text-left badge badge-primary no_truncate"]', 'Médiathèque d\'annecy'); + } + + + /** @test */ + public function articleBadgeCategoryShouldBeBadgeInfo() { + $this->fixture('Class_ArticleCategorie', + ['id' => 12374832, + 'libelle' => 'annecy', + 'id_site' => 123]); + + $article = Class_Article::find(7) + ->setIdCat(12374832); + + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + $this->assertXPathContentContains('//span[@class="badge_tag badge_article_category text-left badge badge-info"]', 'annecy'); + } + + + /** @test */ + public function articleBadgeLocationShouldBeBadgeSecondaryNoTruncate() { + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + $this->assertXPathContentContains('//span[@class="badge_tag badge_article_location text-left badge badge-secondary no_truncate"]', 'Annecy'); + } +} + + + + class TemplatesArticlesMapTest extends TemplatesArticlesWithLocationTestCase { public function setUp() { parent::setUp(); @@ -438,7 +516,6 @@ class TemplatesArticlesWithInvalidConfigurationTest extends TemplatesArticlesWid } - /** @test */ public function pageShouldContainsErrorAucunArticle() { $this->assertXPathContentContains('//div[@id="boite_1"]//p',