diff --git a/library/Class/WebService/OAI.php b/library/Class/WebService/OAI.php index 35e070caff379ca65dd9939b2e994ea916009a08..576da81fafcc548e87b3d72c7611d6c31e9b86d2 100644 --- a/library/Class/WebService/OAI.php +++ b/library/Class/WebService/OAI.php @@ -56,7 +56,7 @@ class Class_WebService_OAI extends Class_WebService_Abstract { public function __construct() { - $this->parser = new Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique(); + $this->parser = new Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique(); } diff --git a/library/Class/WebService/OAI/DublinCoreParser.php b/library/Class/WebService/OAI/DublinCoreParser.php index 3fd61b791bde5ccf379ae8103a310231d66ed6ed..89078de8c20b8cb7cbc831680aef5320ba67caf2 100644 --- a/library/Class/WebService/OAI/DublinCoreParser.php +++ b/library/Class/WebService/OAI/DublinCoreParser.php @@ -42,7 +42,8 @@ class Class_WebService_OAI_DublinCoreParser extends Class_WebService_OAI_ParserA public function newRecord($attributes) { - return $this->_record = ['id_oai' => '', + return $this->_record = ['record_id', + 'id_oai' => '', 'titre' => '', 'date' => '', 'auteur' => [], diff --git a/library/digital_resources/Omeka/Config.php b/library/digital_resources/Omeka/Config.php index 28c7d561549bea215a72af726049f28fcee8a9fc..d3e128ce56d89829889c1b4b46b62007dd45f7e8 100644 --- a/library/digital_resources/Omeka/Config.php +++ b/library/digital_resources/Omeka/Config.php @@ -45,12 +45,12 @@ class Omeka_Config extends Class_DigitalResource_Config { public function isEnabled() { - return (new ZendAfi_Validate_Url())->isValid($this->getOAIUrl()); + return (new ZendAfi_Validate_Url())->isValid($this->getRootUrl()); } - public function getOAIUrl() { - return $this->getAdminVar('OAI_URL'); + public function getRootUrl() { + return $this->getAdminVar('ROOT_URL'); } @@ -60,8 +60,10 @@ class Omeka_Config extends Class_DigitalResource_Config { public function newOAIClient() { + $parser_class = $this->withNameSpace('Service_Parser'); return (new Class_WebService_OAI()) - ->setOAIHandler($this->getOAIUrl()) + ->setOAIHandler($this->getRootUrl() . '/oai-pmh-repository/request') + ->setParser(new $parser_class) ->setNumericResourceClass($this->withNameSpace('Service_Resource')); } } \ No newline at end of file diff --git a/library/digital_resources/Omeka/Service/Parser.php b/library/digital_resources/Omeka/Service/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..653780182a296b01003c44181104dff2877a7b4a --- /dev/null +++ b/library/digital_resources/Omeka/Service/Parser.php @@ -0,0 +1,31 @@ +<?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 Omeka_Service_Parser extends Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique { + public function endIdentifier($data) { + $this->_record['id_oai'] = $data; + } + + + public function enddc_identifier($data) {} +} +?> \ No newline at end of file diff --git a/library/digital_resources/Omeka/Service/Resource.php b/library/digital_resources/Omeka/Service/Resource.php index 87af6a72874ce6757b2418cfaeaebfa39f174964..2183962e9221eb9c7f9a74747ccee2bc3b78a7b4 100644 --- a/library/digital_resources/Omeka/Service/Resource.php +++ b/library/digital_resources/Omeka/Service/Resource.php @@ -38,12 +38,23 @@ class Omeka_Service_Resource extends Class_WebService_BibNumerique_RessourceNume $responsibility)); } + public function getBaseUrl() { + return Omeka_Config::getInstance()->getRootUrl(); + } + + + protected function getTypeDoc() { + return Omeka_Config::getInstance()->getDocType(); + } - public function fillAlbum($album) { - /* $album->beCyberlibris() - ->setDescription($this->getDescription()) - ->setEditeur($this->getEditeur());*/ + public function getRessourceCategorieLibelle() { + return Omeka_Config::getInstance()->getDocTypeLabel(); + } + + + public function fillAlbum($album) { + $album->setTypeDocId($this->getTypeDoc()); return $album; } diff --git a/library/digital_resources/Omeka/View/Helper/Album.php b/library/digital_resources/Omeka/View/Helper/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..58b572d8ea2200c6fff62bca3d1629a72480325c --- /dev/null +++ b/library/digital_resources/Omeka/View/Helper/Album.php @@ -0,0 +1,41 @@ +<?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 + */ + +class Omeka_View_Helper_Album extends ZendAfi_View_Helper_TagRessourceNumerique { + protected $_album; + + public function album($album) { + $this->_album = $album; + return $this->view->tag('div', + '', + ['data-uri' => $this->_manifestURI($album)]); + } + + + protected function _manifestURI($album) { + return $album->getUrlOrigine() . '/iiif/' . $album->getIdOrigine() . '/manifest'; + } + + + protected function hasRightAccesRessourcesNumeriques($user) { + return true; + } +} \ No newline at end of file diff --git a/library/digital_resources/Omeka/tests/OmekaTest.php b/library/digital_resources/Omeka/tests/OmekaTest.php index 22090f32aaff066aa51682fa6251250ce40e32bd..1e96e025a8c8449ff0cecdcee81d09fac07a29c7 100644 --- a/library/digital_resources/Omeka/tests/OmekaTest.php +++ b/library/digital_resources/Omeka/tests/OmekaTest.php @@ -23,8 +23,8 @@ class OmekaFixtures { use Storm_Test_THelpers; public function prepare() { - Class_AdminVar::set('Omeka_OAI_URL', - 'http://omeka-demo.biblibre.com/oai-pmh-repository/request'); + Class_AdminVar::set('Omeka_ROOT_URL', + 'http://omeka-demo.biblibre.com'); $http_client = $this->mock() ->whenCalled('open_url') @@ -33,9 +33,9 @@ class OmekaFixtures { Omeka_Service::setDefaultHttpClient($http_client); return new Omeka_Service( - new Omeka_Config( - new Class_DigitalResource_Wrapper(Class_DigitalResource::getInstance(), - 'Omeka'))); + new Omeka_Config( + new Class_DigitalResource_Wrapper(Class_DigitalResource::getInstance(), + 'Omeka'))); } } @@ -73,7 +73,42 @@ class OmekaHarvestedTest extends AbstractControllerTestCase { /** @test */ public function alpesRecordAuthorResponsibilityShouldBeTextAuthor() { $this->assertEquals('Auteur du texte', - Class_Album::find(8)->getAuthors()[0]->getResponsibility()); + $this->_alpes_record->getAlbum()->getAuthors()[0]->getResponsibility()); } + + + /** @test */ + public function alpesRecordAlbumCategoryShouldBeOmeka() { + $this->assertEquals('Ressource numérique Omeka', Class_Album::find(8)->getCategoryLabel()); + } + + + /** @test */ + public function alpesRecordDocTypeShouldBeOmeka() { + $this->assertEquals('Ressource numérique Omeka', + $this->_alpes_record->getTypeDocLabel()); + } + + + /** @test */ + public function alpesRecordIdOriginShouldBe668() { + $this->assertEquals('668', + $this->_alpes_record->getAlbum()->getIdOrigine()); + } + + + /** @test */ + public function alpesRecordUrlOriginShouldBeOmekaDotDemoDotBiblibreDotCom() { + $this->assertEquals('http://omeka-demo.biblibre.com', + $this->_alpes_record->getAlbum()->getUrlOrigine()); + } + + + /** @test */ + public function alpersRecordPreviewShouldUseUniversalIIIFPlayer() { + $this->dispatch('/noticeajax/resnumeriques/id/1', true); + $this->assertXPath('//div[@data-uri="http://omeka-demo.biblibre.com/iiif/668/manifest"]'); + } + } ?> \ No newline at end of file