Skip to content
Snippets Groups Projects
Commit e1944bd9 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#138225_babelio_et_magasin_de_themes' into 'hotline'

hotline MT #138225 add babelio reviews

See merge request !4175
parents bc30d5d2 53e736cd
Branches
Tags
3 merge requests!4207Master,!4206Hotline,!4175hotline MT #138225 add babelio reviews
Pipeline #14680 passed with stage
in 51 minutes and 51 seconds
- ticket #138225 : Magasin de thèmes : prise en charge du service Babeltheque Babelio dans les avis de notices.
\ No newline at end of file
<?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
...@@ -311,6 +311,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { ...@@ -311,6 +311,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'a class account-link' => 'btn btn-sm btn-primary', 'a class account-link' => 'btn btn-sm btn-primary',
'a class account-disconnect' => 'btn btn-sm btn-secondary', 'a class account-disconnect' => 'btn btn-sm btn-secondary',
'span class user_notifications' => 'btn btn-sm list-group-item-danger', 'span class user_notifications' => 'btn btn-sm list-group-item-danger',
'div class babeltheque_reviews' => 'mt-3 mb-3',
], ],
'icons_map_doc_types' => [], 'icons_map_doc_types' => [],
......
...@@ -30,12 +30,37 @@ class Intonation_View_RenderRecord_RenderReviews extends ZendAfi_View_Helper_Bas ...@@ -30,12 +30,37 @@ class Intonation_View_RenderRecord_RenderReviews extends ZendAfi_View_Helper_Bas
$by_source = $record->getAllAvisPerSource(); $by_source = $record->getAllAvisPerSource();
$html = array_map([$this, '_renderSource'], $by_source, array_keys($by_source)); $html = array_map([$this, '_renderSource'], $by_source, array_keys($by_source));
$html = $this->_addBabelthequeReviewsTo($html);
$html[] = $this->_mine(); $html[] = $this->_mine();
return $this->view->grid(implode($html), [], ['class' => '']); 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) { protected function _renderSource($review_set, $type) {
if ($type_label = $this->_sourceLabelByType($type)) if ($type_label = $this->_sourceLabelByType($type))
$review_set->setLabel($type_label); $review_set->setLabel($type_label);
......
/* 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;
}
...@@ -395,6 +395,7 @@ abstract class TemplatesReviewsActionTestCase extends TemplatesIntonationTestCas ...@@ -395,6 +395,7 @@ abstract class TemplatesReviewsActionTestCase extends TemplatesIntonationTestCas
$this->fixture(Class_Notice::class, $this->fixture(Class_Notice::class,
['id' => 2, ['id' => 2,
'clef_oeuvre' => 'PSYKO', 'clef_oeuvre' => 'PSYKO',
'isbn' => '0123456789',
]); ]);
} }
} }
...@@ -713,4 +714,64 @@ class TemplatesReviewsAsAdminTest extends Admin_AbstractControllerTestCase { ...@@ -713,4 +714,64 @@ class TemplatesReviewsAsAdminTest extends Admin_AbstractControllerTestCase {
public function ratingFourShouldBeReadyToBeValidate() { public function ratingFourShouldBeReadyToBeValidate() {
$this->assertXPath('//div//a[@href="/admin/modo/validateavisnotice/id/4/active_tab/1/page/0"]'); $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"]');
}
}
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