diff --git a/application/modules/opac/views/scripts/cms/articleview.phtml b/application/modules/opac/views/scripts/cms/articleview.phtml index 24d45eb0dc4daaddae0afc60b8889eb5e26f08ba..2646ce80578adcfca31220ecb5f1e895b56361df 100644 --- a/application/modules/opac/views/scripts/cms/articleview.phtml +++ b/application/modules/opac/views/scripts/cms/articleview.phtml @@ -1,11 +1,2 @@ -<a name="Top"></a> <?php - echo $this->partial('cms/article_partial.phtml', ['article' => $this->article]); -?> - -<table style="width:100%"> - <tr> - <td style="text-align:left"><a href="javascript:history.back()"><?php echo $this->_('Retour') ?></a></td> - <td style="text-align:right"><a href="#Top"><?php echo $this->_('Haut') ?></a></td> - </tr> -</table> +echo $this->renderArticle($this->article); diff --git a/library/ZendAfi/View/Helper/RenderArticle.php b/library/ZendAfi/View/Helper/RenderArticle.php new file mode 100644 index 0000000000000000000000000000000000000000..7ba5049bdbbd6fec5e520893d812ef0dbb1d7248 --- /dev/null +++ b/library/ZendAfi/View/Helper/RenderArticle.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012-2018, 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_RenderArticle extends ZendAfi_View_Helper_BaseHelper { + public function renderArticle($article) { + $html = [$this->_tag('a', + '', + ['name' => 'Top']), + $this->view->partial('cms/article_partial.phtml', ['article' => $article]), + $this->_tag('table', + $this->_tag('tr', + $this->_tag('td', + $this->view->tagAnchor('javascript:history.back()', + $this->_('Retour')), + ['style' => 'text-align: left']) + . $this->_tag('td', + $this->view->tagAnchor('#Top', + $this->_('Haut')), + ['style' => 'text-align: left'])))]; + + return implode($html); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderArticle.php b/library/templates/Intonation/View/RenderArticle.php new file mode 100644 index 0000000000000000000000000000000000000000..44a6eddf18dd06fa46b22beb6af1df644df8f72f --- /dev/null +++ b/library/templates/Intonation/View/RenderArticle.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright (c) 2012-2018, 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_RenderArticle extends ZendAfi_View_Helper_BaseHelper { + + public function renderArticle($article) { + $body_content = [$this->view->tagEditArticle($article), + + $this->_tag('h2', + $article->getTitre(), + ['class' => 'card-title']), + + $this->_tag('p', + $article->getAuthorName(), + ['title' => $this->_('Auteur de l\'article "%s".', $article->getAuthorName()), + 'class' => 'card-subtitle text-muted']), + + $this->_badges($article), + + $this->_tag('p', + $this->view->article_ReplaceWidgets($article->getFullContent()), + ['class' => 'card-text']), + ]; + + $body = $this->_tag('div', + implode($body_content), + ['class' => 'card-body']); + + return $this->_tag('div', + $body, + ['class' => 'card card_article']); + } + + + protected function _badges($article) { + return $this->view->renderArticleBadges($article); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderArticles.php b/library/templates/Intonation/View/RenderArticles.php index 4b35c5f4f26e42d03a7fa2f9dc0546d664e1411b..a858a65112090ee4ed1d92a88f495408eb5d0ce2 100644 --- a/library/templates/Intonation/View/RenderArticles.php +++ b/library/templates/Intonation/View/RenderArticles.php @@ -45,35 +45,6 @@ class Intonation_View_RenderArticles extends ZendAfi_View_Helper_BaseHelper { protected function _htmlForArticle($article) { - $body_content = [$this->view->tagEditArticle($article), - - $this->_tag('h2', - $article->getTitre(), - ['class' => 'card-title']), - - $this->_tag('p', - $article->getAuthorName(), - ['title' => $this->_('Auteur de l\'article "%s".', $article->getAuthorName()), - 'class' => 'card-subtitle text-muted']), - - $this->_badges($article), - - $this->_tag('p', - $this->view->article_ReplaceWidgets($article->getFullContent()), - ['class' => 'card-text']), - ]; - - $body = $this->_tag('div', - implode($body_content), - ['class' => 'card-body']); - - return $this->_tag('div', - $body, - ['class' => 'card card_article']); - } - - - protected function _badges($article) { - return $this->view->renderArticleBadges($article); + return $this->view->renderArticle($article); } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 5b4b5c4d9e8b7b2901fe778161459c7c83137fb4..f1faf095c9f5199c6385b6608d44329cd5a69c69 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1695,4 +1695,20 @@ class TemplatesCmsListActionTest extends TemplatesIntonationTestCase { $this->dispatch('/opac/cms/list/title/language/articles/7-6/id_profil/72', true); $this->assertXPathContentContains('//main//div', 'Parlez-vous français ?'); } +} + + + +class TemplatesCmsArticleViewTest extends TemplatesIntonationTestCase { + + /** @test */ + public function dispatchShouldRenderParlerVousFrançais() { + $this->fixture('Class_Article', + ['id' => 7, + 'titre' => 'Parlez-vous français ?', + 'contenu' => '<p>Une b...</p>']); + + $this->dispatch('/opac/cms/articleview/id/7/id_profil/72', true); + $this->assertXPathContentContains('//main//div', 'Parlez-vous français ?'); + } } \ No newline at end of file