From 9b38fd5bd795ce0210f91ee8ed7b2bd2ddc4a663 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Thu, 29 Mar 2018 18:12:32 +0200 Subject: [PATCH] dev #71694 : explo les yeux doc --- FEATURES/71694 | 10 +++ VERSIONS_WIP/71694 | 1 + .../digital_resources/LesYeuxDoc/Batch.php | 23 +++++ .../digital_resources/LesYeuxDoc/Config.php | 86 +++++++++++++++++++ .../LesYeuxDoc/ModuleMenu.php | 23 +++++ .../digital_resources/LesYeuxDoc/Service.php | 74 ++++++++++++++++ .../LesYeuxDoc/Service/Film.php | 48 +++++++++++ .../LesYeuxDoc/Service/FilmsReader.php | 32 +++++++ .../controllers/IndexController.php | 23 +++++ 9 files changed, 320 insertions(+) create mode 100644 FEATURES/71694 create mode 100644 VERSIONS_WIP/71694 create mode 100644 library/digital_resources/LesYeuxDoc/Batch.php create mode 100644 library/digital_resources/LesYeuxDoc/Config.php create mode 100644 library/digital_resources/LesYeuxDoc/ModuleMenu.php create mode 100644 library/digital_resources/LesYeuxDoc/Service.php create mode 100644 library/digital_resources/LesYeuxDoc/Service/Film.php create mode 100644 library/digital_resources/LesYeuxDoc/Service/FilmsReader.php create mode 100644 library/digital_resources/LesYeuxDoc/controllers/IndexController.php diff --git a/FEATURES/71694 b/FEATURES/71694 new file mode 100644 index 00000000000..c69227f4268 --- /dev/null +++ b/FEATURES/71694 @@ -0,0 +1,10 @@ + '71694' => + ['Label' => $this->_('[EXPLO] Connecteur les Yeux du doc "Les Yeux du doc"'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2018-03-29'], \ No newline at end of file diff --git a/VERSIONS_WIP/71694 b/VERSIONS_WIP/71694 new file mode 100644 index 00000000000..9f04d35f488 --- /dev/null +++ b/VERSIONS_WIP/71694 @@ -0,0 +1 @@ + - ticket #71694 : [EXPLO] Connecteur les Yeux du doc "Les Yeux du doc" \ No newline at end of file diff --git a/library/digital_resources/LesYeuxDoc/Batch.php b/library/digital_resources/LesYeuxDoc/Batch.php new file mode 100644 index 00000000000..a364e1741a9 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/Batch.php @@ -0,0 +1,23 @@ +<?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 {} diff --git a/library/digital_resources/LesYeuxDoc/Config.php b/library/digital_resources/LesYeuxDoc/Config.php new file mode 100644 index 00000000000..8a5e1949e57 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/Config.php @@ -0,0 +1,86 @@ +<?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->_('Une plateforme de vidéo à la demande conçue spécifiquement pour les bibliothèques'), + 'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme LesYeuxDoc')) + ->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')) + ->bePrivate()], + + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource LesYeuxDoc'), + + 'NotAllowedMessage' => $this->_('Votre compte n\'est pas authorisé à 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']; + } + + + public function isEnabled() { + return $this->getAdminVar('SSO_URL'); + } + + + public function getSsoUrl($user) { + if (!$id_abon = $user->getIdabon()) + $id_abon = $user->getId(); + + $hash = Class_Hash::sha256WithKey($this->getAdminVar('SSO_KEY')); + + $params = ['sso_id' => 'afi', + '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' => 'https://www.lesyeuxdoc.fr']; + + return $this->getAdminVar('SSO_URL') + . '?' + . http_build_query($params); + } + + + public function getHarvestUrl($page = 1) { + $artevod = new Class_WebService_BibNumerique_ArteVOD; + return $this->getAdminVar('CATALOG_URL') + . '?' + . http_build_query(['page_nb' => $page, + 'page_size' => 10]); + } +} \ No newline at end of file diff --git a/library/digital_resources/LesYeuxDoc/ModuleMenu.php b/library/digital_resources/LesYeuxDoc/ModuleMenu.php new file mode 100644 index 00000000000..ca8864abad5 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/ModuleMenu.php @@ -0,0 +1,23 @@ +<?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 diff --git a/library/digital_resources/LesYeuxDoc/Service.php b/library/digital_resources/LesYeuxDoc/Service.php new file mode 100644 index 00000000000..d872afc9ca5 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/Service.php @@ -0,0 +1,74 @@ +<?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) { + $url = $this->_config->getHarvestUrl($page_number); + + $content = $this->open_authenticated_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 diff --git a/library/digital_resources/LesYeuxDoc/Service/Film.php b/library/digital_resources/LesYeuxDoc/Service/Film.php new file mode 100644 index 00000000000..db58f3af657 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/Service/Film.php @@ -0,0 +1,48 @@ +<?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 { + public function fillAlbum($album) { + $album->setTypeDocId(LesYeuxDoc_Config::getInstance()->getDocType()); + $album->setDuration($this->duration.' mn') + ->setTags($this->getTags()); + + foreach ($this->getActors() as $actor) + $album->addAuthor(trim($actor['familyName'] . ' ' . $actor['givenName']), + '005'); + foreach ($this->_directors as $director) + $album->addAuthor(trim($director['familyName'] . ' ' . $director['givenName']), + '300'); + + 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 diff --git a/library/digital_resources/LesYeuxDoc/Service/FilmsReader.php b/library/digital_resources/LesYeuxDoc/Service/FilmsReader.php new file mode 100644 index 00000000000..3f536149783 --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/Service/FilmsReader.php @@ -0,0 +1,32 @@ +<?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 diff --git a/library/digital_resources/LesYeuxDoc/controllers/IndexController.php b/library/digital_resources/LesYeuxDoc/controllers/IndexController.php new file mode 100644 index 00000000000..94acb5624fe --- /dev/null +++ b/library/digital_resources/LesYeuxDoc/controllers/IndexController.php @@ -0,0 +1,23 @@ +<?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 -- GitLab