diff --git a/VERSIONS_HOTLINE/138225 b/VERSIONS_HOTLINE/138225 new file mode 100644 index 0000000000000000000000000000000000000000..f4a6751f71901c806c0b9cce4a10f0b4b1804f27 --- /dev/null +++ b/VERSIONS_HOTLINE/138225 @@ -0,0 +1 @@ + - ticket #138225 : Magasin de thèmes : prise en charge du service Babeltheque Babelio dans les avis de notices. \ No newline at end of file diff --git a/library/Class/IsbnEan.php b/library/Class/IsbnEan.php deleted file mode 100644 index 13f3f78a83c97f4f2072d766e1fe769372afbdfd..0000000000000000000000000000000000000000 --- a/library/Class/IsbnEan.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Copyright (c) 2012, 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 - */ -/////////////////////////////////////////////////////////////////// -// OPAC3 : fonctions ISBN et EAN -/////////////////////////////////////////////////////////////////// - -class Class_IsbnEan -{ - static function getIsbn10($isbn) - { - $isbn=str_replace("-","",$isbn); - if( strlen($isbn) < 12) return $isbn; - if(substr($isbn,0,3) != "978") return $isbn; - $isbn=substr($isbn,3,9); - // Clef de controle - for($i=0;$i<9;$i++) - { - $facteur=10-$i; - $somme=$somme+(strmid($isbn,$i,1)*$facteur); - } - $car=0; - while(($car+$somme) % 11 != 0) $car++; - if ($car==10) $clef="X"; else $clef=$car; - return $isbn.$clef; - } - -} -?> \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index e7dc992969878bba553756cb4db63ae69d330635..e9e4ee3d2b3e6965b7755d329fc7341d73f6a1b3 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -311,6 +311,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'a class account-link' => 'btn btn-sm btn-primary', 'a class account-disconnect' => 'btn btn-sm btn-secondary', 'span class user_notifications' => 'btn btn-sm list-group-item-danger', + 'div class babeltheque_reviews' => 'mt-3 mb-3', ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/View/RenderRecord/RenderReviews.php b/library/templates/Intonation/View/RenderRecord/RenderReviews.php index f5e5b74ef0f144d644c5df73f764007f83badc87..6a69111a140b63c4b847876cb0d897b4731e942e 100644 --- a/library/templates/Intonation/View/RenderRecord/RenderReviews.php +++ b/library/templates/Intonation/View/RenderRecord/RenderReviews.php @@ -30,12 +30,37 @@ class Intonation_View_RenderRecord_RenderReviews extends ZendAfi_View_Helper_Bas $by_source = $record->getAllAvisPerSource(); $html = array_map([$this, '_renderSource'], $by_source, array_keys($by_source)); + $html = $this->_addBabelthequeReviewsTo($html); $html[] = $this->_mine(); return $this->view->grid(implode($html), [], ['class' => '']); } + protected function _addBabelthequeReviewsTo($html) { + if ( ! Class_AdminVar::getBabelthequeId()) + return $html; + + $isbn = (new Class_Isbn($this->_record->getIsbnOrEan()))->getAll()['isbn10']; + + Class_ScriptLoader::getInstance() + ->loadBabeltheque() + ->addOpacStyleSheet('babeltheque_bootstrap.css') + ->addJQueryReady(sprintf('loadBabelthequeScript(%s);', + $isbn)); + + $html [] = $this->_div(['class' => 'babeltheque_reviews'], + $this->_tag('form', $this->_tag('input', '' ,['id' => 'BW_id_isbn', + 'type' => 'hidden', + 'value' => $isbn])) + . $this->_tag('div', '', ['id' => 'BW_notes']) + . $this->_tag('div', '', ['id' => 'BW_critiques']) + . $this->_tag('div', '', ['id' => 'BW_critiques_pro'])); + + return $html; + } + + protected function _renderSource($review_set, $type) { if ($type_label = $this->_sourceLabelByType($type)) $review_set->setLabel($type_label); diff --git a/public/opac/css/babeltheque_bootstrap.css b/public/opac/css/babeltheque_bootstrap.css new file mode 100644 index 0000000000000000000000000000000000000000..f5d705154f0373472e32465a975f1bd347d80116 --- /dev/null +++ b/public/opac/css/babeltheque_bootstrap.css @@ -0,0 +1,40 @@ +/* rules are prefixed by body to overwritte babeltheque injected css*/ + +body #BW_notes h2 { + font-size: inherit; +} + +body #BW_notes h2 + * { + display: inline; + margin-right : 5px; +} + +body #BW_notes br { + display: none; +} + +body #BW_citations, body #BW_critiques, body #BW_critiques_pro { + background: unset; + filter: unset; + border: unset; + border-radius: unset; + color: unset; + display: unset; + float: unset; + font-weight: unset; + margin: unset; + min-width: unset; + padding: unest; + position: unset; + text-align: unset; + text-shadow: unset; + white-space: unset; +} + +body .BW_critiques_opac_add::after { + content: "sur Babelio.com"; + display: inline-block; + size: 1em; + margin-left: 5px; + color: red; +} diff --git a/tests/scenarios/Templates/TemplatesReviewsTest.php b/tests/scenarios/Templates/TemplatesReviewsTest.php index 5c112b25b01e2bcfc9f8e229973e66bcda704c9e..034560c116d4147253cdc0893c70bd1732813681 100644 --- a/tests/scenarios/Templates/TemplatesReviewsTest.php +++ b/tests/scenarios/Templates/TemplatesReviewsTest.php @@ -395,6 +395,7 @@ abstract class TemplatesReviewsActionTestCase extends TemplatesIntonationTestCas $this->fixture(Class_Notice::class, ['id' => 2, 'clef_oeuvre' => 'PSYKO', + 'isbn' => '0123456789', ]); } } @@ -713,4 +714,64 @@ class TemplatesReviewsAsAdminTest extends Admin_AbstractControllerTestCase { public function ratingFourShouldBeReadyToBeValidate() { $this->assertXPath('//div//a[@href="/admin/modo/validateavisnotice/id/4/active_tab/1/page/0"]'); } -} \ No newline at end of file +} + + + + +class TemplatesReviewsActionWithBabelthequeBabelioTest + extends TemplatesReviewsActionTestCase { + public function setUp() { + parent::setUp(); + Class_AdminVar::set('BABELTHEQUE_JS', 'https://www.babelio.com/bw_114.js'); + $this->dispatch('/record/reviews/id/2/id_profil/72'); + } + + + /** @test */ + public function leRoiShouldBePresent() { + $this->assertXPathContentContains('//div', 'Le Roi'); + } + + + /** @test */ + public function babelthequeJsShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "public/opac/js/babeltheque.js?bwid=114")]'); + } + + + /** @test */ + public function loadBabelthequeJsShouldBeLoaded() { + $this->assertXPathContentContains('//script', '$(function(){loadBabelthequeScript(0-12-345678-9);});'); + } + + + /** @test */ + public function babelthequeNoteShouldBePresent() { + $this->assertXPath('//div[@class="babeltheque_reviews mt-3 mb-3"]//div[@id="BW_notes"]'); + } + + + /** @test */ + public function babelthequeCritiquesShouldBePresent() { + $this->assertXPath('//div[@class="babeltheque_reviews mt-3 mb-3"]//div[@id="BW_critiques"]'); + } + + + /** @test */ + public function babelthequeCritiquesProShouldBePresent() { + $this->assertXPath('//div[contains(@class, "babeltheque_reviews")]//div[@id="BW_critiques_pro"]'); + } + + + /** @test */ + public function babelthequeCssShouldBePresent() { + $this->assertXPath('//head/link[contains(@href, "babeltheque_bootstrap.css")]'); + } + + + /** @test */ + public function babelthequeInputIsbnShouldBePresent() { + $this->assertXPath('//form//input[@id="BW_id_isbn"][@value="0-12-345678-9"]'); + } +}