Commit 861af7c0 authored by efalcy's avatar efalcy Committed by Sebastien ANDRE
Browse files

hotline#135950 : add cookies consent on article summary

parent 64173db2
- ticket #135950 : Cookies : Prise en charge des contenus d'articles
\ No newline at end of file
......@@ -8,11 +8,11 @@ echo '<h1>'.($this->article->titre).'</h1>';
if ($this->article->hasSummary())
{
echo "<h2>Résumé</h2>";
echo $this->article->description;
echo $this->article->getSummaryWithCookiesConsent();
echo "<h2>Article</h2>";
}
echo $this->article->getFullContent();
echo $this->article->getFullContentWithCookiesConsent();
$url = 'url='.BASE_URL.'/admin/cms?z='.$this->sess_id_zone.'&b='.$this->sess_id_site;
......
......@@ -1101,6 +1101,16 @@ class Class_Article extends Storm_Model_Abstract {
}
public function getFullContentWithCookiesConsent() {
return Class_AdminVar_Cookies::manager()->replace($this->getFullContent());
}
public function getSummaryWithCookiesConsent() {
return Class_AdminVar_Cookies::manager()->replace($this->getSummary());
}
/**
* @return string
*/
......
......@@ -58,7 +58,7 @@ class Class_ICal_Event extends \Eluceo\iCal\Component\Event {
ENT_QUOTES|ENT_XHTML,
'UTF-8');
$event->setDescription($text_description);
$event->setDescriptionHTML($article->getFullContent());
$event->setDescriptionHTML($article->getFullContentWithCookiesConsent());
if ($image = $article->getFirstImageAbsoluteURL())
$event->setImage($image);
......
......@@ -95,14 +95,13 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
public function renderContent($article) {
$content = ($article->hasSummary()) ?
$this->renderSummary($article)
: $article->getFullContent();
: $article->getFullContentWithCookiesConsent();
return $this->view->article_ReplaceWidgets($content);
}
public function renderSummary($article) {
return $article->getSummary() . $this->renderReadFullArticle($article);
return $article->getSummaryWithCookiesConsent() . $this->renderReadFullArticle($article);
}
......@@ -141,4 +140,4 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
public function renderArticleInfo($article) {
return $this->view->tagArticleInfo($article);
}
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@ class ZendAfi_View_Helper_Article_RenderFullContent extends ZendAfi_View_Helper_
public function renderContent($article) {
$content = Class_AdminVar_Cookies::manager()->replace($article->getFullContent());
$content = $article->getFullContentWithCookiesConsent();
return $this->view->article_ReplaceWidgets($content);
}
......@@ -55,4 +55,4 @@ class ZendAfi_View_Helper_Article_RenderFullContent extends ZendAfi_View_Helper_
->setStrategy('Article_List')),
['class' => 'print']);
}
}
\ No newline at end of file
}
......@@ -44,7 +44,7 @@ class ZendAfi_View_Helper_Article_RenderWall extends ZendAfi_View_Helper_Article
public function renderSummary($article) {
return $article->getSummary();
return $article->getSummaryWithCookiesConsent();
}
......@@ -52,4 +52,4 @@ class ZendAfi_View_Helper_Article_RenderWall extends ZendAfi_View_Helper_Article
return '';
}
}
?>
\ No newline at end of file
?>
......@@ -85,7 +85,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr
public function getFullDescription() {
return $this->getBadges()
. $this->_view->tagArticleEvent($this->_model)
. $this->_model->getSummary();
. $this->_model->getSummaryWithCookiesConsent();
}
......
......@@ -40,7 +40,7 @@ class Intonation_Library_Widget_Free_View extends Zendafi_View_Helper_Accueil_Ba
$edit_link = $this->view->div(['class' => 'position_absolute'],
$edit_link);
$content = Class_AdminVar_Cookies::manager()->replace($this->_article->getFullContent());
$content = $this->_article->getFullContentWithCookiesConsent();
return $this->view->article_ReplaceWidgets($content)
. $edit_link;
}
......@@ -70,4 +70,4 @@ class Intonation_Library_Widget_Free_View extends Zendafi_View_Helper_Accueil_Ba
[$this->_article]);
}];
}
}
\ No newline at end of file
}
......@@ -34,7 +34,7 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {
$this->view->cardify($osm_wrapper));
$location_content = $this->view->grid($grid_content);
$full_content = Class_AdminVar_Cookies::manager()->replace($article->getFullContent());
$full_content = $article->getFullContentWithCookiesConsent();
$body_content = [$article->getCacherTitre()
? ''
......@@ -71,4 +71,4 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {
$this->_div(['class' => 'article_location_static_map'],
$this->view->mapForLieu($location, ['size' => '']))];
}
}
\ No newline at end of file
}
......@@ -388,7 +388,7 @@ class ArticleTestSmallArticle extends ModelTestCase {
/** @test */
public function fullContentShouldBeContenu() {
$this->assertEquals($this->_article->getContenu(),
$this->_article->getFullContent());
$this->_article->getFullContentWithCookiesConsent());
}
/** @test */
......@@ -454,7 +454,7 @@ class ArticleTestSummaryAndFullContentForArticleWithDescription extends ModelTes
$this->_article = $this->fixture('Class_Article',
['id' => 3,
'titre' => 'Fête de la pomme',
'description' => 'à Boussy',
'description' => 'à Boussy<iframe src="http://mylinkonotherwebsite"></iframe>',
'contenu' => 'venez nombreux!',
'debut' => '2010-10-02T00:00:00+02:00',
'fin' => '2010-10-03T00:00:00+02:00',
......@@ -465,10 +465,30 @@ class ArticleTestSummaryAndFullContentForArticleWithDescription extends ModelTes
/** @test */
public function summaryShouldBeDescription() {
$this->assertEquals('à Boussy',
$this->assertEquals('à Boussy<iframe src="http://mylinkonotherwebsite"></iframe>',
$this->_article->getSummary());
}
/** @test */
public function withCookiesActivatedShouldTransformIframeOnSummary() {
Class_Adminvar_Cookies::setManager(new Class_Cookies_TarteAuCitron());
$this->assertContains('à Boussy<div class="tac_iframe" data-url="http://mylinkonotherwebsite" ></div><script>',
$this->_article->getSummaryWithCookiesConsent());
}
/** @test */
public function withCookiesActivatedShouldTransformIframeOnDivOnContent() {
$this->_article->setContenu('<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/4Op2W-V9BrQ" title="YouTube video player" width="560"></iframe>');
Class_Adminvar_Cookies::setManager(new Class_Cookies_TarteAuCitron());
$this->assertContains('<div class="tac_iframe" data-url="https://www.youtube.com/embed/4Op2W-V9BrQ" height="315" width="560"></div><script>',
$this->_article->getFullContentWithCookiesConsent());
}
/** @test */
public function fullContentShouldBeContenu() {
$this->assertEquals('venez nombreux!',
......
......@@ -34,7 +34,7 @@ abstract class TemplatesFreeWidgetTestCase extends Admin_AbstractControllerTestC
$this->fixture(Class_Article::class,
['id' => 5,
'titre' => 'I have a dream',
'contenu' => 'all Bokeh should be free (of bugs ...)',
'contenu' => 'all Bokeh should be free (of bugs ...)<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/4Op2W-V9BrQ" title="YouTube video player" width="560"></iframe>',
'categorie' => $this->fixture(Class_ArticleCategorie::class,
['id' => 3,
'libelle' => 'Sofware'])]);
......@@ -63,9 +63,10 @@ abstract class TemplatesFreeWidgetTestCase extends Admin_AbstractControllerTestC
class TemplatesFreeWidgetIndexTest extends TemplatesFreeWidgetTestCase {
class TemplatesFreeWidgetIndexWithCookiesTest extends TemplatesFreeWidgetTestCase {
public function setUp() {
parent::setUp();
Class_Adminvar_Cookies::setManager(new Class_Cookies_TarteAuCitron());
$this->dispatch('/opac/index/index/id_profil/1');
}
......@@ -91,6 +92,12 @@ class TemplatesFreeWidgetIndexTest extends TemplatesFreeWidgetTestCase {
}
/** @test */
public function widgetOneShouldContentWithDivInsteadOfFrame() {
$this->assertXPath('//div[text()="all Bokeh should be free (of bugs ...)"]//div[@class="tac_iframe"][@height="315"][@width="560"]');
}
/** @test */
public function widgetThreeTitleShouldBeBoiteSeule() {
......
Markdown is supported
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