Skip to content
Snippets Groups Projects
Commit d6ae8fa7 authored by Laurent's avatar Laurent
Browse files

hotline #113511 Templates : add missing static map in articles

parent df790eca
Branches
Tags
2 merge requests!3589Hotline,!3584Hotline#113511 bt agenda
Pipeline #10716 passed with stage
in 45 minutes and 18 seconds
......@@ -58,7 +58,8 @@ abstract class ZendAfi_Controller_Action_Helper_ListViewMode_Abstract
if ($this->isSearching())
return;
$description = (new Class_TableDescription('categories_' . get_class($this->getModel())));
$model_class = $this->getModel() ? get_class($this->getModel()) : '';
$description = (new Class_TableDescription('categories_' . $model_class));
return $this->_describeCategoriesIn($description)
->addRowAction(function($model)
{
......
......@@ -37,6 +37,7 @@ class ZendAfi_View_Helper_MapForLieu extends ZendAfi_View_Helper_BaseHelper {
return $this->view->tagImg($static_map_url,
['class' => sprintf('%s_static_map', $map->getLabel()),
'style' => 'cursor: pointer',
'alt' => $lieu->getLibelle(),
'onclick' => sprintf("window.open("%s");return false;", $map->getFullMapUrl())]);
}
......
......@@ -24,18 +24,34 @@ class ZendAfi_View_Helper_RenderLieu extends ZendAfi_View_Helper_BaseHelper {
if (!$lieu)
return '';
return $this->_renderMedia($this->view->mapForLieu($lieu, $map_options),
$this->_renderTitle($lieu),
$this->_renderAddress($lieu));
}
protected function _renderMedia($map, $title, $address) {
return $this->_tag('div',
$map
. $title
. $address,
['class' => 'lieu']);
}
protected function _renderTitle($lieu) {
return $this->_tag('h3', $lieu->getLibelle());
}
protected function _renderAddress($lieu) {
$adresse = [nl2br($lieu->getAdresse()),
$lieu->getCodePostal() . ' ' . $lieu->getVille(),
$lieu->getTelephone(),
$lieu->getMail()];
$adresse_str = implode('<br/>', array_filter($adresse));
return $this->_tag('div',
$this->view->mapForLieu($lieu, $map_options)
. $this->_tag('h3', $lieu->getLibelle())
. $adresse_str,
['class' => 'lieu']);
return implode('<br/>', array_filter($adresse));
}
}
......
......@@ -43,6 +43,9 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {
$this->_tag('p',
$this->view->article_ReplaceWidgets($article->getFullContent()),
['class' => 'card-text']),
$this->view->renderLieu($article->getLieu(),
['size' => '300x200'])
];
$body = $this->_tag('div',
......
<?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));
}
}
......@@ -96,6 +96,7 @@ class TemplatesCmsListActionTest extends TemplatesIntonationTestCase {
class TemplatesCmsArticleViewTest extends TemplatesIntonationTestCase {
public function setUp() {
parent::setUp();
......@@ -159,3 +160,60 @@ class TemplatesCmsArticleViewWithHiddenTitleTest extends TemplatesIntonationTest
$this->assertNotXPath('//main//div//h2[@class="card-title"]');
}
}
class TemplatesCmsArticleViewWithLocationTest extends TemplatesIntonationTestCase {
public function setUp() {
parent::setUp();
$annecy = $this->fixture('Class_Lieu',
['id' => '4156465',
'libelle' => 'Annecy',
'adresse' => 'Rue des tomates',
'telephone' => '01 23 87 38 47',
'code_postal' => '74000',
'mail' => 'contact@annecy.fr',
'latitude' => '45.9262592',
'longitude' => '6.1459837']);
$this->fixture('Class_Article',
['id' => 7,
'titre' => 'Parlez-vous français ?',
'contenu' => '<p>Une b...</p>',
'events_debut' => '2020-03-13 00:00:00',
'events_fin' => '2020-07-31 00:00:00',
'lieu' => $annecy,
'all_day' => 1]);
$this->dispatch('/opac/cms/articleview/id/7/id_profil/72');
}
/** @test */
public function mediaDivShouldContainsStaticMap() {
$this->assertXPath('//div[contains(@class, "media")]//img[contains(@src,"https://smap.afi-sa.net/staticmap.php")]');
}
/** @test */
public function mediaDivShouldContainsAddressAnnecy() {
$this->assertXPathContentContains('//div[contains(@class, "media")]//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"]',
'01 23 87 38 47');
}
/** @test */
public function mediaDivShouldLinkToMailContactAtAnnecy() {
$this->assertXPathContentContains('//div[contains(@class, "media")]//a[@href="mailto:contact@annecy.fr"]',
'contact@annecy.fr');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment