Commit b573d8cc authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#75244_connecteur_les_yeux_du_doc_les_yeux_du_doc' into 'master'

Dev#75244 connecteur les yeux du doc les yeux du doc

See merge request afi/opacce!2681
parents 4101a2fd 89673fdb
'71694' =>
['Label' => $this->_('Connecteur "Les Yeux Doc"'),
'Desc' => $this->_('%s est une plateforme de vidéo à la demande conçue spécifiquement pour les bibliothèques',
'<a href="https://www.lesyeuxdoc.fr/">Les Yeux Doc</a>'),
'Image' => 'https://www.lesyeuxdoc.fr/dist/img/yeuxdoc.svg',
'Video' => 'https://www.youtube.com/watch?v=cvZFpTkXVKU',
'Category' => $this->_('Bibliothèque numérique'),
'Right' => function($feature_description, $user) {return true;},
'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=LesYeuxDoc',
'Test' => '',
'Date' => '2018-05-28'],
\ No newline at end of file
- ticket #71694 : Ressources numériques : ajout de la ressource numérique "Les Yeux Doc" avec les options d'authentification depuis le portail et le moissonnage des ressources.
\ No newline at end of file
......@@ -40,14 +40,24 @@ class Class_WebService_BibNumerique_ArteVOD_Film extends Class_WebService_BibNu
->setDescription($json['description'])
->addPoster($json['posterUrl'])
->setDirectors($json['directors'])
->setGenres($json['genres'])
->addTrailer($json['trailerUrl'])
->setExternalUri($json['url'])
->addMedias($json['medias'])
->addThemes($json['themes'])
->setYear(explode('-', $json['publicationDate'])[0])
->addActors($json['actors'])
->addDuration($json['duration']);
->addActors(isset($json['actors']) ?
$json['actors'] : [])
->addDuration($json['duration'])
->addMedias(isset($json['medias']) ? $json['medias'] : [])
->addThemes($json['themes']);
if (isset($json['genres']))
$this->setGenres($json['genres']);
if (isset($json['trailerUrl']))
$this->addTrailer($json['trailerUrl'] );
if (isset($json['productionYear']))
$this->setYear($json['productionYear']);
if (isset($json['publicationDate']))
$this->setYear(explode('-', $json['publicationDate'])[0]);
}
......@@ -87,11 +97,14 @@ class Class_WebService_BibNumerique_ArteVOD_Film extends Class_WebService_BibNu
return $this;
}
protected function setTypeDoc($album) {
return $album->beArteVOD();
}
public function fillAlbum($album) {
$album->beArteVOD()
->setDuration($this->duration.' mn')
->setTags($this->getTags());
$this->setTypeDoc($album)
->setDuration($this->duration.' mn')
->setTags($this->getTags());
foreach ($this->getActors() as $actor)
$album->addAuthor(trim($actor['familyName'] . ' ' . $actor['givenName']),
......
......@@ -44,7 +44,9 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View
. $this->view->tagImg($this->view->url(['module' => 'opac',
'controller' => 'digital-resource',
'action' => 'typedoc-icon',
'id' => $config->getName()])));
'id' => $config->getName()]),
['class' => 'error',
'alt' => $this->_('Aucune image')]));
$html [] = $this->_getAlbumsHtml($config);
$html [] = $this->_getRecordsHtml($config);
......
......@@ -81,8 +81,8 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_SSO extends ZendAfi_View_Hel
}
protected function _getSSOHtml($config, $user) {
return $this->_tag('pre', $config->urlFor($user));
protected function _getSSOHtml($config, $user, $album = null) {
return $this->_tag('pre', $config->urlFor($user, $album ? ['album_id' => $album->getId()] : []));
}
......@@ -100,7 +100,13 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_SSO extends ZendAfi_View_Hel
'id' => $album->getId()], $this->_('Voir l\'album'),
['style' => 'margin-left: 1em',
'data-popup' => 'true']))
. $this->_tagAnchor($album_url, $album_url, ['target' => '_blank']);
. $this->_getSSOHtml($config, $user, $album)
. $this->view->button((new Class_Entity)
->setUrl($this->view->url(['action' => 'try-sso',
'album_id' => $album->getId()]))
->setText($this->_('Essayer le SSO avec l\'utilisateur "%s" pour l\'album "%s"',
$user->getLogin(),
$album->getTitre())));
}
......
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Batch extends Class_DigitalResource_Batch {}
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Config extends Class_DigitalResource_Config {
public function getConfig() {
return ['Introduction' => $this->_('"Les Yeux Doc" est une plateforme de vidéo à la demande conçue spécifiquement pour les bibliothèques'),
'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource LesYeuxDoc'),
'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'),
'SsoAction' => true,
'MenuLabel' => $this->_('Lien vers LesYeuxDoc'),
'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
'Service' => $this->withNameSpace('Service'),
'Batch' => $this->withNameSpace('Batch'),
'DocTypeLabel' => $this->_('Vidéo (LesYeuxDoc)'),
'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/LesYeuxDoc',
'Url' => 'https://lesyeuxdoc.fr',
'Icon' => 'https://www.lesyeuxdoc.fr/dist/img/yeuxdoc.svg',
'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme LesYeuxDoc'),
['value' => 'https://portal.mediatheque-numerique.com/sso_login'])->bePrivate(),
'SSO_KEY' => Class_AdminVar_Meta::newDefault($this->_('Clef unique SSO fournit par la plateforme LesYeuxDoc'))->bePrivate(),
'CATALOG_URL' => Class_AdminVar_Meta::newDefault($this->_('Url du catalogue de la plateforme LesYeuxDoc'),
['value' => 'https://www.lesyeuxdoc.fr/api/v1/films'])->bePrivate(),
'RETURN_URL' => Class_AdminVar_Meta::newDefault($this->_('URL utilisée dans la génération du lien le SSO. Paramètre return_url.'),
['value' => 'https://www.lesyeuxdoc.fr'])->bePrivate(),
'SSO_ID' => Class_AdminVar_Meta::newDefault($this->_('Identifiant utilisé dans la génération du lien SSO, Paramètre "sso_id"'),
['value' => 'afi'])->bePrivate()]
];
}
public function isEnabled() {
return $this->getAdminVar('SSO_KEY');
}
public function getAlbumSsoUrl($user,$album) {
return $this->getSSoUrl($user, $album);
}
public function getSsoUrl($user, $album = null) {
$id_abon = $user->getIdabon()
? $user->getIdabon()
: $user->getId();
$hash = Class_Hash::sha256WithKey($this->getAdminVar('SSO_KEY'));
$return_url = $album
? $album->getExternalUri()
: $this->getAdminVar('RETURN_URL');
$params = ['sso_id' => $this->getAdminVar('SSO_ID'),
'id' => $id_abon,
'id_encrypted' => $hash->encrypt($id_abon),
'd' => $hash->encrypt(date('dmY', $this->getCurrentTime())),
'prenom' => $user->getPrenom(),
'nom' => $user->getNom(),
'email' => $user->getMail(),
'dnaiss' => $user->getNaissance(),
'datout' => $user->getDateFin(),
'return_url' => $return_url];
return $this->getAdminVar('SSO_URL')
. '?'
. http_build_query($params);
}
public function getHarvestUrl($page = 1) {
return 1 < $page
? ''
: $this->getAdminVar('CATALOG_URL') . '?' . http_build_query(['page_nb' => 1]);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Service extends Class_WebService_BibNumerique_ArteVOD {
protected $_config;
public static function getInstance() {
return Class_DigitalResource_Config::getInstanceFor(static::class)->getServiceInstance();
}
public function __construct($config) {
$this->_config = $config;
}
protected function getDocType() {
return $this->_config->getDocType();
}
protected function getUrlOrigine() {
return $this->_config->getOAIUrl();
}
public function isEnabled() {
return $this->_config->isEnabled();
}
public function getName() {
return $this->_config->getName();
}
protected function loadPage($page_number = 1) {
if (!$url = $this->_config->getHarvestUrl($page_number))
return '';
$content = $this->getWebClient()->open_url($url);
if ('' == $content) {
$this->getLogger()->error('Erreur de communication');
return;
}
$this->getLogger()->info('Réponse reçue');
$reader = $this->getFilmsReader()->parse($content);
return $reader;
}
public function getFilmsReader() {
return new LesYeuxDoc_Service_FilmsReader;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Service_Film extends Class_WebService_BibNumerique_ArteVOD_Film {
protected function setTypeDoc($album) {
$album->setTypeDocId(LesYeuxDoc_Config::getInstance()->getDocType());
return $album;
}
public function getRessourceCategorieLibelle() {
return LesYeuxDoc_Config::getInstance()->getDocTypeLabel();
}
public function getBaseUrl() {
return LesYeuxDoc_Config::getInstance()->getAdminVar('CATALOG_URL');
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Service_FilmsReader extends Class_WebService_BibNumerique_ArteVOD_FilmsReader {
public function startFilm() {
$this->_current_film = new LesYeuxDoc_Service_Films;
}
public function parseFilm($movie) {
return new LesYeuxDoc_Service_Film($movie);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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 LesYeuxDoc_Plugin_IndexController extends Class_DigitalResource_Controller {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, 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
*/
abstract class LesYeuxDocActivatedTestCase extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
LesYeuxDoc_Config::setTimeSource(new TimeSourceForTest('2018-28-05 11:50:00'));
Class_AdminVar::set('LesYeuxDoc_SSO_KEY', 'pass');
$user = $this->fixture('Class_Users',
['id' => 78,
'login' => 'JJ',
'password' => 'ry',
'nom' => 'Jumper',
'prenom' => 'Jolly',
'mail' => 'jolly@jumper.com']);
$group = $this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Premier groupe']);
LesYeuxDoc_Config::getInstance()->getPermissions();
$this->fixture('Class_UserGroup_Permission',
['id' => 1,
'id_group' => 1,
'id_permission' => Class_Permission::findFirstBy(['code' => 'LesYeuxDoc'])->getId(),
'id_model' => null,
'model_class' => null
]);
$user->setUserGroups([$group]);
$this->fixture('Class_Album',
['id' => 45,
'titre' => 'Olivier Rolin',
'type_doc_id' => 'LesYeuxDoc',
'external_uri' => 'https://www.lesyeuxdoc.fr/film/703/olivier-rolin']);
}
public function tearDown() {
LesYeuxDoc_Config::setTimeSource(null);
parent::tearDown();
}
}
class LesYeuDocDashboardTestCase extends LesYeuxDocActivatedTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/LesYeuxDoc_Plugin', true);
}
/** @test */
public function shouldBeActivated() {
$this->assertXPathContentContains('//div', 'Activ');
}
/** @test */
public function ssoUrlForTestUserShouldBePortalMediathequeNumerique() {
$this->assertContains('<pre>https://portal.mediatheque-numerique.com/sso_login?sso_id=afi&id=79&id_encrypted=aff73a5e918d0cbefa1077d3468cfcfc03abd9c94b3d827b1b7dd283db2450f9&d=d0f3e0faa0b2546ea784554bea817f2dcac68a0c5e658ce907af0711e6674e53&prenom=&nom=&email=&dnaiss=&datout=&return_url=https%3A%2F%2Fwww.lesyeuxdoc.fr</pre>',
$this->_response->getBody());
}
/** @test */
public function ssoUrlForTestUserAndAlbumOlivierRolinShouldBePortalMediathequeNumerique() {
$this->assertContains('<pre>https://portal.mediatheque-numerique.com/sso_login?sso_id=afi&id=79&id_encrypted=aff73a5e918d0cbefa1077d3468cfcfc03abd9c94b3d827b1b7dd283db2450f9&d=d0f3e0faa0b2546ea784554bea817f2dcac68a0c5e658ce907af0711e6674e53&prenom=&nom=&email=&dnaiss=&datout=&return_url=https%3A%2F%2Fwww.lesyeuxdoc.fr%2Ffilm%2F703%2Folivier-rolin</pre>',
$this->_response->getBody());
}
}
class LesYeuxDocFixtures {
use Storm_Test_THelpers;
public function activate() {
Class_AdminVar::set('LesYeuxDoc_SSO_URL', 'http://lesyeuxdoc.com');
Class_AdminVar::set('LesYeuxDoc_SSO_KEY', 'pass');
Class_AdminVar::set('LesYeuxDoc_CATALOG_URL', 'https://www.lesyeuxdoc.fr/api/v1/films');
return $this;
}
public function deactivate() {
Class_AdminVar::set('LesYeuxDoc_SSO_URL', '');
Class_AdminVar::set('LesYeuxDoc_SSO_KEY', '');
Class_AdminVar::set('LesYeuxDoc_CATALOG_URL', '');
return $this;
}
public function prepare() {
$page1 = file_get_contents(__DIR__ . '/page1.json');
$http_client = $this->mock()
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/api/v1/films?page_nb=1')