diff --git a/VERSIONS_HOTLINE/93337 b/VERSIONS_HOTLINE/93337 new file mode 100644 index 0000000000000000000000000000000000000000..c7900c0d9768e6224a46ba2458fb3804e3654c37 --- /dev/null +++ b/VERSIONS_HOTLINE/93337 @@ -0,0 +1 @@ + - ticket #93337 : Respect de la licence lors d'une reprise de Wikipédia - fiche auteur \ No newline at end of file diff --git a/library/Class/CodifAuteur/Description.php b/library/Class/CodifAuteur/Description.php index ecad640d23d09ea16667ed189643ad7ad1aecbc6..1b72d9dbc1e4499cb735de0392aef3dd08c23e07 100644 --- a/library/Class/CodifAuteur/Description.php +++ b/library/Class/CodifAuteur/Description.php @@ -138,7 +138,10 @@ class Class_CodifAuteur_Description { $update_button = $view->biographie_UpdateButton($this->getRecords()[0], $this->getLabel()); - return $update_button . $thumbnail . $biography; + + $licence = $view->biographie_Licence($this->getLabel(), $data['source'], $data['url_source']); + + return $update_button . $thumbnail . $biography . $licence; } diff --git a/library/ZendAfi/View/Helper/Biographie.php b/library/ZendAfi/View/Helper/Biographie.php index e2bcb637690b07ad37422b0256bc229aa8506ccd..40773fa131f69bbd916bb26374a8e65385b00365 100644 --- a/library/ZendAfi/View/Helper/Biographie.php +++ b/library/ZendAfi/View/Helper/Biographie.php @@ -50,14 +50,18 @@ class ZendAfi_View_Helper_Biographie extends ZendAfi_View_Helper_BaseHelper { } $source = $this->view->tag('p', $this->view->_('Source'). ' : ' . $data['source']); + + $auteur = $notice->getAuteurPrincipal(); $biographie = $data['biographie']; + $source .= $this->view->biographie_Licence($auteur,$data['source'], $data['url_source']); + if(!is_array($biographie) && preg_match("/<[^<]+>/", $biographie) != 0) - return $source . $biographie; + return $biographie.$source; + - $auteur = $notice->getAuteurPrincipal(); - $content = $this->_renderTitle($auteur, $data['source']); + $content = $this->_renderTitle($auteur, $source); $suite = false; @@ -72,10 +76,7 @@ class ZendAfi_View_Helper_Biographie extends ZendAfi_View_Helper_BaseHelper { protected function _renderTitle($author, $source) { $content = $author - . $this->_tag('span', - str_repeat(' ', 6) - . '(' . $this->_('Source : %s', $source) . ')', - ['style' => 'font-size:smaller']); + . $source; return $this->_renderTitleContent($content); } diff --git a/library/ZendAfi/View/Helper/Biographie/Licence.php b/library/ZendAfi/View/Helper/Biographie/Licence.php new file mode 100644 index 0000000000000000000000000000000000000000..0f4867527c98c82a1fea59e897625910db07788d --- /dev/null +++ b/library/ZendAfi/View/Helper/Biographie/Licence.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_Biographie_Licence extends ZendAfi_View_Helper_BaseHelper{ + public function biographie_Licence($author, $source, $url) { + if ($source != 'Wikipedia') + return ''; + + return + $this->_renderCreativeCommonsLink($url) + . $this->_renderLinkToWikipediaPage($author, $url) + . $this->_renderLinkToContributors($author, $url); + } + + + protected function _renderCreativeCommonsLink($url) { + $language = substr($url,8,2); + $cc_link_params = ['rel' => "license", + 'href' => $this->_('http://creativecommons.org/licenses/by-sa/3.0/deed.%s', $language), + 'title' => $this->_('Licence Creative Commons')]; + + return $this->_tag('p', + $this->_tag('a', + $this->_tag('img','', + [ + 'alt' => $this->_('Licence Creative Commons'), + 'style' => 'border-width:0', + 'src' => $this->_('https://i.creativecommons.org/l/by-sa/3.0/%s/80x15.png',$language) + ]), + $cc_link_params) + . ' ' . $this->_('Ce contenu est mis à disposition selon les termes de la') + . ' ' . $this->_tag('a', + $this->_('Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0'), + $cc_link_params)); + } + + + protected function _renderLinkToWikipediaPage($author, $url) { + $language = substr($url,8,2); + return $this->_tag('p', + 'Source : Article ' + . $this->_tag('a',$author , + ['href' => $url, + 'title' => $this->_('Ouvrir la page wikipedia pour') . ' ' . $author]) + + .' '. + $this->_('de') . ' ' . + $this->_tag('a', + 'Wikipédia', + ['href' => $this->_('https://%s.wikipedia.org/', $language), + 'title' => $this->_('Accéder à Wikipedia')])); + } + + + protected function _renderLinkToContributors($author, $url) { + $contribs_url = $url . (strpos($url,'?') === false ? '?' : '&') . 'action=history'; + + return $this->_tag('p', + $this->_('Contributeurs'). ' : '. + $this->_tag('a', + $this->_('voir la liste'), + ['href' => $contribs_url, + 'title' => $this->_('Voir la liste des contributions de la page Wikipedia pour') . ' ' . $author])); + } +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 6ab0e3f572281f597e56d5a50d7f52d4db4a73eb..49a564d145b07f1986af514bae316a60d905c1a6 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1816,6 +1816,7 @@ class NoticeAjaxControllerBiographieTest extends NoticeAjaxControllerBiographieT ->answers(json_encode(['statut_recherche' => '0', 'source' => 'Wikipedia', + 'url_source' => 'https://fr.wikipedia.org/wiki/J._K._Rowling', 'vignette' => 'rowling.jpg', 'image' => 'rowling_big.jpg', 'biographie' => [ @@ -1838,6 +1839,27 @@ class NoticeAjaxControllerBiographieTest extends NoticeAjaxControllerBiographieT } + /** @test */ + public function licenceCCBySAShouldBeDisplayed() { + $this->assertXPathContentContains('//p', + utf8_encode('Ce contenu est mis à disposition selon les termes de la'), + $this->_response->getBody()); + } + + + /** @test */ + public function linkAuthorShouldBeDisplayed() { + $this->assertXPathContentContains('//a',utf8_encode('J.K Rowling'),$this->_response->getBody()); + } + + + /** @test */ + public function contributorLinkWikpediaShouldBeDisplayed() { + $this->assertXPath('//a[contains(@href, "https://fr.wikipedia.org/wiki/J._K._Rowling?action=history")]'); + } + + + /** @test */ public function anchorShouldContainsRowlingBigDotJpg() { $this->assertXPath('//a[@href="rowling_big.jpg"]'); @@ -1899,6 +1921,7 @@ class NoticeAjaxControllerBiographieNonTrouveeTest extends NoticeAjaxControllerB ->whenCalled('open_url') ->answers(json_encode(['statut_recherche' => '0', 'source' => '', + 'url_source' => '', 'vignette' => '', 'image' => '', 'biographie' => '' diff --git a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php index abb6d69fa16b649694b7c2eabc873d5fb9d39d66..77b27381c71960e463e0182486ab27cdcc93e05f 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php @@ -251,6 +251,7 @@ class Telephone_RechercheControllerHarryPotterBiographieTest extends Telephone_R ->whenCalled('open_url') ->answers(json_encode(['biographie' => [['texte' => 'Inspiration et controverse']], 'source' => 'afi', + 'url_source' => '', 'vignette' => ''])); Class_WebService_AllServices::setHttpClient($httpClient); } diff --git a/tests/library/ZendAfi/View/Helper/BiographieTest.php b/tests/library/ZendAfi/View/Helper/BiographieTest.php index e67989331d087632f4e24ce22cc9d5c682f254ee..385f404f7badcb0f90d2442bcd0fe6f950da611d 100644 --- a/tests/library/ZendAfi/View/Helper/BiographieTest.php +++ b/tests/library/ZendAfi/View/Helper/BiographieTest.php @@ -27,6 +27,7 @@ class ZendAfi_View_Helper_BiographieAuthorTest extends ViewHelperTestCase { $this->_helper = new ZendAfi_View_Helper_Biographie(); $this->_helper->setView($view); $this->_html = $this->_helper->renderBiographie(['source' => 'wiki', + 'url_source' => '', 'biographie' => '<p>A html biographie !</p>'], $this->fixture('Class_Notice', ['id' => 1])); @@ -35,7 +36,7 @@ class ZendAfi_View_Helper_BiographieAuthorTest extends ViewHelperTestCase { /** @test */ public function biographieShouldContainsHtml() { - $this->assertEquals('<p>Source : wiki</p><p>A html biographie !</p>', $this->_html); + $this->assertEquals('<p>A html biographie !</p><p>Source : wiki</p>', $this->_html); } } ?> \ No newline at end of file diff --git a/tests/scenarios/AuthorPage/AuthorPageTest.php b/tests/scenarios/AuthorPage/AuthorPageTest.php index 6ff7f575bf8550f787e7823b48cc23a4424d2499..7c13953da0e92b771382af62649dbe153f4302b2 100644 --- a/tests/scenarios/AuthorPage/AuthorPageTest.php +++ b/tests/scenarios/AuthorPage/AuthorPageTest.php @@ -96,6 +96,7 @@ abstract class AuthorPageTestCase extends AbstractControllerTestCase { ->answers(json_encode(['statut_recherche' => 2, 'erreur' => '', 'source' => 'Wikipedia', + 'url_source' => 'https://fr.wikipedia.org/wiki/Victor_Hugo', 'biographie' => '1980 : <i>Les Misérables</i> (adaptation d\'Alain Boublil et Claude-Michel Schönberg) pour Robert Hossein, est devenue ....avec Marcus %s \Mill bizarre', 'vignette' => 'http://images.fr/hugo_thumb.jpg', 'image' => 'http://images.fr/hugo_big.jpg', @@ -121,6 +122,7 @@ class AuthorPageViewIncompleteAuthor extends AuthorPageTestCase { ->answers(json_encode(['statut_recherche' => 0, 'erreur' => '', 'source' => '', + 'url_source' => '', 'biographie' => '', 'vignette' => '', 'image' => ''])); @@ -333,6 +335,14 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase { public function pageShouldLinkLesMiserablesWithCodeRebondAndFacet() { $this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/inspector_gadget/1/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]'); } + + + /** @test */ + public function licenceCCBySAShouldBeDisplayed() { + $this->assertXPathContentContains('//div[@class="biography"]//p', + 'Ce contenu est mis à disposition selon les termes de la', + $this->_response->getBody()); + } }