From b165d2c9dd816e773b796d16f39b1d2133d205f4 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Thu, 8 Jul 2021 18:05:35 +0200 Subject: [PATCH] dev#129492 : Adds digital resource Mobidys --- FEATURES/129492 | 10 ++ VERSIONS_WIP/129492 | 1 + .../Class/WebService/OPDS/CatalogEntry.php | 2 + .../Class/WebService/OPDS/CatalogReader.php | 18 +- library/digital_resources/Mobidys/Batch.php | 23 +++ library/digital_resources/Mobidys/Config.php | 94 ++++++++++ .../digital_resources/Mobidys/ModuleMenu.php | 23 +++ library/digital_resources/Mobidys/Service.php | 40 +++++ .../Mobidys/Service/Album.php | 66 +++++++ .../Mobidys/Service/Parser.php | 65 +++++++ .../Mobidys/View/Helper/Album.php | 23 +++ .../Mobidys/controllers/IndexController.php | 23 +++ .../digital_resources/Mobidys/images/icon.png | Bin 0 -> 1126 bytes .../Mobidys/tests/MobidysTest.php | 165 ++++++++++++++++++ .../Mobidys/tests/mobidys.oai | 66 +++++++ .../Mobidys/tests/mobidys.opds | 55 ++++++ tests/library/Class/MoteurRechercheTest.php | 4 +- 17 files changed, 667 insertions(+), 11 deletions(-) create mode 100644 FEATURES/129492 create mode 100644 VERSIONS_WIP/129492 create mode 100644 library/digital_resources/Mobidys/Batch.php create mode 100644 library/digital_resources/Mobidys/Config.php create mode 100644 library/digital_resources/Mobidys/ModuleMenu.php create mode 100644 library/digital_resources/Mobidys/Service.php create mode 100644 library/digital_resources/Mobidys/Service/Album.php create mode 100644 library/digital_resources/Mobidys/Service/Parser.php create mode 100644 library/digital_resources/Mobidys/View/Helper/Album.php create mode 100644 library/digital_resources/Mobidys/controllers/IndexController.php create mode 100644 library/digital_resources/Mobidys/images/icon.png create mode 100644 library/digital_resources/Mobidys/tests/MobidysTest.php create mode 100644 library/digital_resources/Mobidys/tests/mobidys.oai create mode 100644 library/digital_resources/Mobidys/tests/mobidys.opds diff --git a/FEATURES/129492 b/FEATURES/129492 new file mode 100644 index 00000000000..6c2d7e0ba24 --- /dev/null +++ b/FEATURES/129492 @@ -0,0 +1,10 @@ + '129492' => + ['Label' => $this->_('Connecteur Mobidys'), + 'Desc' => $this->_('%s propose un catalogue de livres numérique à destination des dys. Le connecteur fournis l\'accès SSO et l\'aspiration du catalogue.', '<a href="https://www.mobidys.com/bibliodyssee">Mobidys</a>'), + 'Image' => '', + 'Video' => '', + 'Category' => $this->_('Bibliothèque numérique'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Mobidys', + 'Test' => '', + 'Date' => '2021-07-08'], \ No newline at end of file diff --git a/VERSIONS_WIP/129492 b/VERSIONS_WIP/129492 new file mode 100644 index 00000000000..f4c4d2819c5 --- /dev/null +++ b/VERSIONS_WIP/129492 @@ -0,0 +1 @@ + - ticket #129492 : Bibliothèque numérique : développement du connecteur Mobidys \ No newline at end of file diff --git a/library/Class/WebService/OPDS/CatalogEntry.php b/library/Class/WebService/OPDS/CatalogEntry.php index 7d2e58860e9..503d2402b60 100644 --- a/library/Class/WebService/OPDS/CatalogEntry.php +++ b/library/Class/WebService/OPDS/CatalogEntry.php @@ -51,6 +51,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R public function addFile($url, $mimeType) { $this->_files[] = Class_WebService_OPDS_EntryFile::newWith($url, $mimeType); + return $this; } @@ -92,6 +93,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R foreach ($this->_files as $file) $file->newRessourceInAlbum($album); + return $this; } diff --git a/library/Class/WebService/OPDS/CatalogReader.php b/library/Class/WebService/OPDS/CatalogReader.php index d64757ab90d..80ac57abada 100644 --- a/library/Class/WebService/OPDS/CatalogReader.php +++ b/library/Class/WebService/OPDS/CatalogReader.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_OPDS_CatalogReader { @@ -57,7 +57,7 @@ class Class_WebService_OPDS_CatalogReader { public function getSearch() { - if (null != $this->_search) + if (null != $this->_search) return $this->_search; if (null != $this->_searchUrl) @@ -85,7 +85,7 @@ class Class_WebService_OPDS_CatalogReader { public function startLink($attributes) { - if (!array_key_exists('TYPE', $attributes)) + if (!array_key_exists('TYPE', $attributes)) return; if (!$this->_xml_parser->inParents('entry')) { @@ -114,8 +114,8 @@ class Class_WebService_OPDS_CatalogReader { || false != strpos($attributes['REL'], 'acquisition'))) { $this->_current_entry->beNotice(); if (in_array($attributes['TYPE'], array('application/epub+zip', 'application/pdf'))) - $this->_current_entry->addFile($attributes['HREF'], $attributes['TYPE']); - return; + return $this->_current_entry->addFile($attributes['HREF'], $attributes['TYPE']); + return $this->_current_entry->setLink($attributes['HREF']); } if (array_key_exists('REL', $attributes) && $attributes['REL'] == 'start') { @@ -185,22 +185,22 @@ class Class_WebService_OPDS_CatalogReader { protected function _concatMetadata($name, $value, $separator = ' - ') { - $this->_metadatas[$name] = (isset($this->_metadatas[$name])) + $this->_metadatas[$name] = (isset($this->_metadatas[$name])) ? $this->_metadatas[$name] . $separator . $value : $value; } protected function _normalizeUrl($url) { - if (!$this->_selfUrl) + if (!$this->_selfUrl) return $url; - if ('http' == substr($url, 0, 4)) + if ('http' == substr($url, 0, 4)) return $url; $urlInfos = parse_url($this->_selfUrl); $normalized = $urlInfos['scheme'] . '://' . $urlInfos['host']; - if ('/' == substr($url, 0, 1)) + if ('/' == substr($url, 0, 1)) return $normalized . $url; return $normalized . dirname($urlInfos['path']) . $url; } diff --git a/library/digital_resources/Mobidys/Batch.php b/library/digital_resources/Mobidys/Batch.php new file mode 100644 index 00000000000..ba843c25d2b --- /dev/null +++ b/library/digital_resources/Mobidys/Batch.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_Batch extends Class_DigitalResource_Batch {} diff --git a/library/digital_resources/Mobidys/Config.php b/library/digital_resources/Mobidys/Config.php new file mode 100644 index 00000000000..07d4a2bc225 --- /dev/null +++ b/library/digital_resources/Mobidys/Config.php @@ -0,0 +1,94 @@ +<?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 Mobidys_Config extends Class_DigitalResource_Config { + + protected function _getConfig() { + return ['Introduction' => $this->_('Mobidys'), + 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Mobidys', + 'Url' => 'http://mobidys.com', + 'Icon' => 'https://www.mobidys.com/wp-content/uploads/2020/09/logo-Mobidys-orange-simple.png', + + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource Mobidys'), + 'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'), + + 'SsoAction' => true, + 'Harvesting' => true, + + 'MenuLabel' => $this->_('Lien vers Mobidys'), + 'ModuleMenu' => $this->withNameSpace('ModuleMenu'), + + 'Service' => $this->withNameSpace('Service'), + 'Batch' => $this->withNameSpace('Batch'), + + 'DocTypeLabel' => $this->_('Mobidys'), + + 'AdminVars' => [ + 'Harvest_Url' => Class_AdminVar_Meta::newDefault($this->_('URL du flux OPDS pour le moissonage de Mobidys'), ['value' => '']), + 'SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme Mobidys'), + ['value' => ''])->bePrivate()] + ]; + } + + + public function isEnabled() { + return '' != $this->getAdminVar('SSO_URL') + && $this->getOPDSUrl() + && ((new ZendAfi_Validate_Url())->isValid($this->getOPDSUrl())); + } + + + public function getSsoUrl($user) { + if(!$user) + return ''; + + return $this->getAdminVar('SSO_URL') + . '?ticket=' + . (new Class_CasTicket())->getTicketForUser($user); + } + + + public function getAlbumSsoUrl($user, $album) { + if(!$album) + return ''; + + return $album->getExternalUri() + . '?ticket=' + . (new Class_CasTicket())->getTicketForUser($user); + } + + + public function getOPDSUrl() { + return $this->getAdminVar('Harvest_Url'); + } + + + public function getHarvestUrl($page = 1) { + $query = ['lang' => 'fr']; + // not working in real life with parameters : + // 'format' => 'OPDS' + + $url = $this->getAdminVar('Harvest_Url'); + + return $url . '?' . http_build_query(array_filter($query)); + } +} diff --git a/library/digital_resources/Mobidys/ModuleMenu.php b/library/digital_resources/Mobidys/ModuleMenu.php new file mode 100644 index 00000000000..a1443a2eb62 --- /dev/null +++ b/library/digital_resources/Mobidys/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 Mobidys_ModuleMenu extends Class_DigitalResource_ModuleMenu {} \ No newline at end of file diff --git a/library/digital_resources/Mobidys/Service.php b/library/digital_resources/Mobidys/Service.php new file mode 100644 index 00000000000..b89bbf2251e --- /dev/null +++ b/library/digital_resources/Mobidys/Service.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_Service extends Class_DigitalResource_Service { + + public function getPageCount() { + return 1; + } + + + public function getRessourcesNumeriques() { + return $this->_parser->getEntries(); + } + + + public function loadPage($page_number = 1) { + $opds = $this->httpGet($this->_config->getHarvestUrl($page_number)); + $this->_parser = (new Mobidys_Service_Parser)->parse($opds); + return $this; + } +} diff --git a/library/digital_resources/Mobidys/Service/Album.php b/library/digital_resources/Mobidys/Service/Album.php new file mode 100644 index 00000000000..da714aa8fa1 --- /dev/null +++ b/library/digital_resources/Mobidys/Service/Album.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_Service_Album extends Class_WebService_OPDS_CatalogEntry { + + public function setId($id) { + $this->_id = $id; + return $this; + } + + + public function matchId($other_id) { + return $this->getId() === $other_id; + } + + + public function getBaseUrl() { + return Mobidys_Config::getInstance()->getAdminVar('SSO_URL'); + } + + + protected function getTypeDoc() { + return Mobidys_Config::getInstance()->getDocType(); + } + + + public function fillAlbum($album) { + parent::fillAlbum($album); + $album->setTypeDocId($this->getTypeDoc()); + return $this; + } + + + public function setAuthor($author) { + return $this->addAuthor($author); + } + + + public function getRessourceCategorieLibelle() { + return Mobidys_Config::getInstance()->getDocTypeLabel(); + } + + + public function setLink($link) { + return $this->setExternalUri($link); + } +} diff --git a/library/digital_resources/Mobidys/Service/Parser.php b/library/digital_resources/Mobidys/Service/Parser.php new file mode 100644 index 00000000000..4ea00c2f7ae --- /dev/null +++ b/library/digital_resources/Mobidys/Service/Parser.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_Service_Parser extends Class_WebService_OPDS_CatalogReader { + + protected + $_albums = []; + + public function startEntry($attributes) { + $this->_current_entry = new Mobidys_Service_Album(); + return $this; + } + + + public function endEntry() { + $this->_albums[] = $this->_current_entry; + return $this; + } + + + public function getEntries() { + return $this->_albums; + } + + + public function endSource($data) { + return $this->_current_entry->setExternalUri($data); + } + + + public function endId($data) { + if (!$this->_xml_parser->inParents('entry')) + return $this; + + $this->_current_entry->setId($data); + return $this; + } + + + public function endUpdated($data) { + if (!$this->_xml_parser->inParents('entry')) + return; + + return $this->_current_entry->setYear(date('Y', strtotime($data))); + } +} diff --git a/library/digital_resources/Mobidys/View/Helper/Album.php b/library/digital_resources/Mobidys/View/Helper/Album.php new file mode 100644 index 00000000000..7b30e3d6762 --- /dev/null +++ b/library/digital_resources/Mobidys/View/Helper/Album.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {} diff --git a/library/digital_resources/Mobidys/controllers/IndexController.php b/library/digital_resources/Mobidys/controllers/IndexController.php new file mode 100644 index 00000000000..0af7c81418a --- /dev/null +++ b/library/digital_resources/Mobidys/controllers/IndexController.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Mobidys_Plugin_IndexController extends Class_DigitalResource_Controller {} diff --git a/library/digital_resources/Mobidys/images/icon.png b/library/digital_resources/Mobidys/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..be9851e9b7fb26def2c2a52a892be32b95254f64 GIT binary patch literal 1126 zcmex=<NpH&0WUXCHwH#V1_nkTWcYuZ!I^=Lg@u)cg^iV!m5q&!os*A~lY@g(h?kd( zPgF=uOjJljL|jTyMqEN(Qba^nT~=O6Syfe4Oh!{jLq%IrMO6i42qRD{CkLk>C#Rr_ zgouO+$>9G120;!61qKCXMnMK9K}Kdl#{WkcB!P}(VrD=Btjuf-EF3^7Z2<;G7Di?! z7B-kXBNH<Vs~`iLkfNcmV_>4Fl2PHtgCb&1K*bV_V1Q%}3oA1N6HrD+kb#jIWC|lI zR2F0mgP@`i*bosVr^3dA3ymgj{P6MrEe0NDpnC+F1sUuaUV8sMa8}y4pR*|SL^#LC z*}v|Fzo?ok<ul=g#IC->YmH=7J=D!S?#yis&#T|ENVqsX#xzQ%cG(_|wN2985t2by z?=$?}YWtr-L_loo%biSzr=E{mEq-7+cdq%m1G6XZZCB7_z4mU^!pBbA^R9BfN<NdJ z=p}dBfByaGX-iF~=!YlS9hI<WeXrg7;@#x>gG)8?Z|v>cs<?Hd>ePZd<GEs&_VRCE zcq!S_`=!}I>AoqJ6Rt`+2$#%hGE-X3drNoi`Q)-c>PwIJd_R0?*`$yaCplSGsFYd; zzV7wo7gWq&Y0mKSxc<vk&nyh1d#19ibPg*lzVx?MV|K;vmBto@MYD`5_Mco7@@wOy z2^=SwmrpBR(tcSzbic!W>HiE<j3o<B>9>b&D|`R>cT{IZRN%>;uA84FS4~wEZ2vSt zR#%iEXxT~2N5wsIx3qSwS;2P2iE~?V_8a&7sw{4yfJL7e3l-)heY+#~=VP#Sq<ZeV zQ>R&P>^FYoZE*ji(3JlSa~AwrP}y6pv&v?QMTp-T`L(M}PPpvIGZ7G8d`7o!=e_MK zWkjV{-CFzkfM3L1iFv0_96IowB|GDJt75M9)o1c0m6?x^WPbTovwXXkVwisLyX=a> z#ius58Z7<p!!uoJhZ|qv>z>E1defFzv@|VQt#-TFk4N>#T8m8rOCDt1bXvA?Tcyy; zS@YQruDY(e)Xin9`pg3U2_pSV(m$@x+v7BwPo?F4@!p@+VL5J|&Z{y#wK;FZU3)$+ z?MmzFrpFaw;TtNIwya8-%6BqQ!l~}B=e758I!nyv`}toLv#Jo7QyRVgl>Ma4*n`^_ zy^~nDe9B{evr1#d#jRV`2h>OTtXNrV7RGVovxr4-xM<bn3FYj`4p-gpMEe;uoz=0H zcxlP+R$}t#?={gozn?p$8YwMza0qzC+kf`el-47&_G!)0u;tkCW4qSrw(oM!*G}fV z<)*MHTFbG>A$p#|tDfWquh?sgANfo>#a-pTFaOjot%Zk6^;9n{u5&tcy#8p!%2g4o s6SHy`v_H{4I$_O|mFfHAkIg&GnUj$6<oA`8K_Q<S)R~!Y?f-uh05(^%@Bjb+ literal 0 HcmV?d00001 diff --git a/library/digital_resources/Mobidys/tests/MobidysTest.php b/library/digital_resources/Mobidys/tests/MobidysTest.php new file mode 100644 index 00000000000..970dbf363f6 --- /dev/null +++ b/library/digital_resources/Mobidys/tests/MobidysTest.php @@ -0,0 +1,165 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 MobidysActivatedTestCase extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_user; + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('Mobidys_SSO_URL', 'https://app.mobidys.org/mybib'); + Class_AdminVar::set('Mobidys_Harvest_Url', 'http://backend.mobidys.com/opds'); + $http_client = $this->mock() + ->whenCalled('open_url') + ->with('http://backend.mobidys.com/opds?lang=fr') + ->answers(file_get_contents(__DIR__ . '/mobidys.opds')) + ->beStrict(); + Mobidys_Service::setDefaultHttpClient($http_client); + $group = $this->fixture('Class_UserGroup', + ['id' => 1, + 'libelle' => 'Digital resources']); + + $this->_user = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'Tom', + 'password' => 'pwd']) + ->setUserGroups([$group]); + + $this->fixture('Class_Permission', + ['id' => 1, + 'code' => 'Mobidys']) + ->permitTo($group, new Class_Entity()); + } +} + + + + +class MobidysHarvestTest extends MobidysActivatedTestCase { + protected $_album; + + public function setUp() { + parent::setUp(); + $ressource = Mobidys_Service::getInstance(); + $ressource->harvest(); + $this->_album = Class_Album::find(2); + $this->_album->index(); + } + + + public function getAlbumAttribs() { + return [ + ['getTitre', 'A l\'intérieur de moi'], + ['getIdOrigine', 'Interieur_de_moi'], + ['getExternalUri', 'https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1016'], + ['getAnnee', '2021'], + ['getDescription', 'Pour les tout-petits, un livre d\'éveil sensible et artistique, ouvert sur le monde qui les entoure. + +Mots-clés : Emotion'], + ['getTypeDocId' , 'Mobidys'], + ['getCategoryLabel', 'Mobidys'], + ['getPoster', 'https://d1ye1pkjd8d7nc.cloudfront.net/public_item/0001/05/4f2ee613e70ba86a9f75315766ae55db7dc669df.jpeg'], + ['getMainAuthorName', 'Aurélia Gaud'], + ]; + } + + + /** + * @test + * @dataProvider getAlbumAttribs + */ + public function albumAttribsShouldMatch($key, $value) { + $this->assertEquals($value, call_user_func([$this->_album, $key])); + } +} + + + + +class MobidysSsoTest extends MobidysActivatedTestCase { + + public function setUp() { + parent::setUp(); + $user= $this->fixture('Class_Users', + ['id' => 10, + 'login' => 'Tom', + 'password' => 'pwd']); + + $this->fixture('Class_Album', + ['id' => 1, + 'titre' => 'mobidys album title', + 'type_doc_id' => Mobidys_Config::getInstance()->getDocType(), + 'id_origine' => 'zork666', + 'external_uri' => 'http://app.mobidys/myalbum']); + + } + + + /** @test */ + public function userWithRoleInviteShouldNotHaveAccessToModulesMobidys() { + ZendAfi_Auth::getInstance()->logUser(Class_Users::find(10)); + $this->dispatch('/opac/modules/mobidys', true); + $this->assertFlashMessengerContentContains('Votre compte n\'est pas autorisé à accéder à cette ressource.'); + } + + + /** @test */ + public function userValidShouldBeRedirectToMobidys() { + ZendAfi_Auth::getInstance()->logUser($this->_user); + $this->dispatch('/opac/modules/mobidys', true); + $this->assertXPathContentContains('//script','https://app.mobidys.org/mybib?ticket='); + } + + + /** @test */ + public function userValidShouldBeRedirectToMobidysAlbum() { + ZendAfi_Auth::getInstance()->logUser($this->_user); + $this->dispatch('/opac/modules/mobidys/album_id/1', true); + $this->assertXPathContentContains('//script','http://app.mobidys/myalbum?ticket='); + } +} + + + + +class MobidysDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->dispatch('/Mobidys_Plugin', true); + } + + + /** @test */ + public function shouldDisplayDeactivated() { + $this->assertXPathContentContains('//button', 'Désactivé'); + } + + + /** @test */ + public function ssoUrlShoudlBeDisplay() { + $this->assertXPathContentContains('//table', 'Mobidys_SSO_URL'); + } +} diff --git a/library/digital_resources/Mobidys/tests/mobidys.oai b/library/digital_resources/Mobidys/tests/mobidys.oai new file mode 100644 index 00000000000..2e0adb3c79b --- /dev/null +++ b/library/digital_resources/Mobidys/tests/mobidys.oai @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:mml="http://www.w3.org/1998/Math/MathML" + xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" +> +<responseDate>2021-07-08T12:27:51Z</responseDate> +<request verb="ListRecords">https://backend.bibliodyssee.com/oai-pmh-catalogs/BM_29_Landerneau/fr</request> +<ListRecords> +<record> + <header> + <identifier>oai:catalogs:146298</identifier> + <datestamp>2021-06-25T13:51:43Z</datestamp> + </header> + + <metadata> + <oai_dc:dc + xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ + http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> + <dc:title>146298</dc:title> + <dc:description>146298. Une suite de chiffres tatoués sur le bras de sa grand-mère. Elle les a vus toute sa vie sans leur donner plus de sens. Puis un jour, en classe, elle comprend. D'abord en colère face au secret de famille trop longtemps caché, elle parvient enfin à convaincre sa grand-mère de lui parler, de faire le tri dans sa mémoire défaillante : la rafle, le voyage, le camp, la faim... Les vies de la jeune fille et de la vieille femme se croisent, s'entremêlent pour se mettre au diapason. + +Mots-clés : Famille, Historique, Société</dc:description> + <dc:identifier>146298</dc:identifier> + <dc:date>2021-06-25T13:51:43Z</dc:date> + <dc:creator>Rachel Corenblit</dc:creator> + <dc:publisher>Mobidys</dc:publisher> + <dc:source>https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1015</dc:source> <dc:type>interactive</dc:type> + <dc:language>fr</dc:language> + <dc:rights>© Actes-Sud +© Mobidys</dc:rights> + </oai_dc:dc> + </metadata> +</record> +<record> + <header> + <identifier>oai:catalogs:Interieur_de_moi</identifier> + <datestamp>2021-06-25T15:47:07Z</datestamp> + </header> + + <metadata> + <oai_dc:dc + xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ + http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> + <dc:title>A l'intérieur de moi</dc:title> + <dc:description>Pour les tout-petits, un livre d'éveil sensible et artistique, ouvert sur le monde qui les entoure. + +Mots-clés : Emotion</dc:description> + <dc:identifier>Interieur_de_moi</dc:identifier> + <dc:date>2021-06-25T15:47:07Z</dc:date> + <dc:creator>Aurélia Gaud</dc:creator> + <dc:publisher>Actes-Sud</dc:publisher> + <dc:source>https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1016</dc:source> <dc:type>interactive</dc:type> + <dc:language>fr</dc:language> + <dc:rights>© Actes Sud - © Mobidys</dc:rights> + </oai_dc:dc> + </metadata> +</record> +</ListRecords> +</OAI-PMH> diff --git a/library/digital_resources/Mobidys/tests/mobidys.opds b/library/digital_resources/Mobidys/tests/mobidys.opds new file mode 100644 index 00000000000..fbe9aa50bd4 --- /dev/null +++ b/library/digital_resources/Mobidys/tests/mobidys.opds @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" + xmlns:dc="http://purl.org/dc/terms/" + xmlns:opds="http://opds-spec.org/2010/catalog"> + <id>https://backend.bibliodyssee.com/opds-catalogs/BM_29_Landerneau/fr/root.xml</id> + <link rel="self" + href="/opds-catalogs/BM_29_Landerneau/fr/root.xml" + type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> + <link rel="start" + href="/opds-catalogs/BM_29_Landerneau/fr/root.xml" + type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> + <title>All Publications</title> + <updated>2021-07-08T15:23:24</updated> + <author> + <name>BibliOdyssée</name> + <uri>https://app.bibliodyssee.com</uri> + </author> + <entry> + <title>146298</title> + <id>146298</id> + <updated>2021-06-25T13:51:43</updated> + <author> + <name>Rachel Corenblit</name> + </author> + <dc:publisher>Mobidys</dc:publisher> + <summary>146298. Une suite de chiffres tatoués sur le bras de sa grand-mère. Elle les a vus toute sa vie sans leur donner plus de sens. Puis un jour, en classe, elle comprend. D'abord en colère face au secret de famille trop longtemps caché, elle parvient enfin à convaincre sa grand-mère de lui parler, de faire le tri dans sa mémoire défaillante : la rafle, le voyage, le camp, la faim... Les vies de la jeune fille et de la vieille femme se croisent, s'entremêlent pour se mettre au diapason. + +Mots-clés : Famille, Historique, Société</summary> + <link rel="http://opds-spec.org/image" + href="https://d1ye1pkjd8d7nc.cloudfront.net/public_item/0001/05/c9aa0f5e339d13e5df7040a8abd146284efe82c8.jpeg" + type="image/jpeg"/> + <link rel="http://opds-spec.org/acquisition" + href="https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1015" + type="text/html"/> + </entry> + <entry> + <title>A l'intérieur de moi</title> + <id>Interieur_de_moi</id> + <updated>2021-06-25T15:47:07</updated> + <author> + <name>Aurélia Gaud</name> + </author> + <dc:publisher>Actes-Sud</dc:publisher> + <summary>Pour les tout-petits, un livre d'éveil sensible et artistique, ouvert sur le monde qui les entoure. + +Mots-clés : Emotion</summary> + <link rel="http://opds-spec.org/image" + href="https://d1ye1pkjd8d7nc.cloudfront.net/public_item/0001/05/4f2ee613e70ba86a9f75315766ae55db7dc669df.jpeg" + type="image/jpeg"/> + <link rel="http://opds-spec.org/acquisition" + href="https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1016" + type="text/html"/> + </entry> + +</feed> diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index 2ec710c55df..244a1af972e 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -337,12 +337,12 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { [['expressionRecherche' => '', 'digital_lib' => '1'], 'nb_mots'=> 0, - 'req_liste' => $this->listSqlWith("(type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))")], + 'req_liste' => $this->listSqlWith("(type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))")], [['expressionRecherche' => 'logo', 'digital_lib' => '1'], 'nb_mots'=> 1, - 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and (type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))", + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and (type_doc in ('100','101','102','103','104','105','106','109','110','111','112','113','115','116','117','119','Arkhenum','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))", "(MATCH(titres) AGAINST(' LOGO') * 1.5) + (MATCH(auteurs) AGAINST(' LOGO')) desc")], [['expressionRecherche' => '', -- GitLab