diff --git a/.gitattributes b/.gitattributes index 557b55a3fc0983f4d7fe7b624f7b8ceb3d6beeb0..ef05df5a92f0eba0fed00a0d0cfeb74724265f79 100644 --- a/.gitattributes +++ b/.gitattributes @@ -584,6 +584,7 @@ application/modules/opac/views/scripts/module.phtml -text application/modules/opac/views/scripts/noticeajax/notice.phtml -text application/modules/opac/views/scripts/oai/identify.xml.phtml -text svneol=unset#text/plain application/modules/opac/views/scripts/oai/list-identifiers.xml.phtml -text +application/modules/opac/views/scripts/oai/list-metadata-formats.xml.phtml -text svneol=unset#application/xml application/modules/opac/views/scripts/panier/error.phtml -text application/modules/opac/views/scripts/panier/export.phtml -text application/modules/opac/views/scripts/panier/index.phtml -text @@ -1772,6 +1773,7 @@ library/Class/WebService/OAI.php -text library/Class/WebService/OAI/CatalogueVisitor.php -text library/Class/WebService/OAI/Request/Identify.php -text library/Class/WebService/OAI/Request/ListIdentifiers.php -text +library/Class/WebService/OAI/Request/ListMetadataFormats.php -text library/Class/WebService/OAI/Response/GetRecord.php -text library/Class/WebService/OAI/Response/Identify.php -text library/Class/WebService/OAI/Response/ListIdentifiers.php -text @@ -3437,6 +3439,7 @@ tests/application/modules/opac/controllers/IndexControllerTranslationTest.php -t tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php -text tests/application/modules/opac/controllers/OAIControllerIdentifyTest.php -text tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php -text +tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php -text tests/application/modules/opac/controllers/OAIControllerTest.php -text tests/application/modules/opac/controllers/PanierControllerTest.php -text tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php -text @@ -3514,7 +3517,6 @@ tests/library/Class/UsersTest.php -text tests/library/Class/VodeclicLinkTest.php -text tests/library/Class/WebService/BabelioTest.php -text tests/library/Class/WebService/OAI/Response/GetRecordTest.php -text -tests/library/Class/WebService/OAI/Response/ListMetadataFormatsTest.php -text tests/library/Class/WebService/OAI/Response/ListRecordsTest.php -text tests/library/Class/WebService/OAI/Response/ListSetsTest.php -text tests/library/Class/WebService/OAI/ResumptionTokenTest.php -text diff --git a/application/modules/opac/controllers/OaiController.php b/application/modules/opac/controllers/OaiController.php index f3d4cd9b658b0f18daf30423789425a9d39a2732..5551c003579562336d5002d208cdf1b903dd55ab 100644 --- a/application/modules/opac/controllers/OaiController.php +++ b/application/modules/opac/controllers/OaiController.php @@ -23,6 +23,7 @@ class OaiController extends Zend_Controller_Action { $this->_helper->getHelper('contextSwitch') ->addActionContext('list-identifiers', 'xml') ->addActionContext('identify', 'xml') + ->addActionContext('list-metadata-formats', 'xml') ->initContext(); } @@ -32,7 +33,8 @@ class OaiController extends Zend_Controller_Action { $this->getHelper('ViewRenderer')->setNoRender(); $verbsMapping = array('ListIdentifiers' => 'list-identifiers', - 'Identify' => 'identify'); + 'Identify' => 'identify', + 'ListMetadataFormats' => 'list-metadata-formats'); if (array_key_exists($this->_getParam('verb'), $verbsMapping)) { $this->_forward($verbsMapping[$this->_getParam('verb')], null, null, @@ -82,12 +84,23 @@ class OaiController extends Zend_Controller_Action { $baseUrl); $this->view->request = $request; $this->view->builder = new Class_Xml_Builder(); + $this->view->repositoryName = $_SERVER['SERVER_NAME'] . ' Oai repository'; $this->view->baseUrl = $baseUrl; $this->view->earliestDatestamp = ($notice = Class_Notice::getLoader()->getEarliestNotice()) ? substr($notice->getDateMaj(), 0, 10) : ''; $this->view->adminEmail = Class_CosmoVar::get('mail_admin'); } + + + public function listMetadataFormatsAction() { + $this->getHelper('ViewRenderer')->setLayoutScript('empty.phtml'); + $baseUrl = $this->buildBaseUrl(); + $request = new Class_WebService_OAI_Request_ListMetadataFormats($this->_request->getParams(), + $baseUrl); + $this->view->request = $request; + $this->view->builder = new Class_Xml_Builder(); + } } ?> \ No newline at end of file diff --git a/application/modules/opac/views/scripts/oai/list-metadata-formats.xml.phtml b/application/modules/opac/views/scripts/oai/list-metadata-formats.xml.phtml new file mode 100644 index 0000000000000000000000000000000000000000..82dfb516fa6bed543a96403e419b53d6f6b6020e --- /dev/null +++ b/application/modules/opac/views/scripts/oai/list-metadata-formats.xml.phtml @@ -0,0 +1,14 @@ +<?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" + xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"> + <responseDate><?php echo date('c');?></responseDate> + <?php echo $this->request->renderOn($this->builder); ?> + <ListMetadataFormats> + <metadataFormat> + <metadataPrefix>oai_dc</metadataPrefix> + <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema> + <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace> + </metadataFormat> + </ListMetadataFormats> +</OAI-PMH> \ No newline at end of file diff --git a/library/Class/WebService/OAI/Request/ListMetadataFormats.php b/library/Class/WebService/OAI/Request/ListMetadataFormats.php new file mode 100644 index 0000000000000000000000000000000000000000..455df52b07e0cddab1c2169a58b8576d658a6e27 --- /dev/null +++ b/library/Class/WebService/OAI/Request/ListMetadataFormats.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +class Class_WebService_OAI_Request_ListMetadataFormats { + protected $_baseUrl; + protected $_identifier; + + public function __construct($params, $baseUrl) { + if (isset($params['identifier'])) + $this->_identifier = $params['identifier']; + $this->_baseUrl = $baseUrl; + } + + + public function renderOn($builder) { + $attributes = array('verb' => 'ListMetadataFormats'); + if ($this->_identifier) + $attributes['identifier'] = $this->_identifier; + + return $builder->request($attributes, $this->_baseUrl); + } +} +?> \ No newline at end of file diff --git a/tests/library/Class/WebService/OAI/Response/ListMetadataFormatsTest.php b/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php similarity index 79% rename from tests/library/Class/WebService/OAI/Response/ListMetadataFormatsTest.php rename to tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php index 72f8e3d42e0a8da45e0e0f85bcae099b6156d1ec..e5f2e4417d90ae132646217a3b6c6608d956f94a 100644 --- a/tests/library/Class/WebService/OAI/Response/ListMetadataFormatsTest.php +++ b/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php @@ -18,28 +18,28 @@ * along with AFI-OPAC 2.0; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ListMetadataFormatsTest extends Storm_Test_ModelTestCase { +require_once 'AbstractControllerTestCase.php'; + +class OAIControllerListMetadataFormatsTest extends AbstractControllerTestCase { protected $_xpath; - protected $_response; public function setUp() { parent::setUp(); $this->_xpath = TestXPathFactory::newOai(); - $this->_response = new Class_WebService_OAI_Response_ListMetadataFormats('http://afi-sa.fr/oai2/do'); + $this->dispatch('/opac/oai/request?verb=ListMetadataFormats'); } /** @test */ public function requestVerbShouldBeListMetadataFormats() { - $this->_xpath->assertXPathContentContains($this->_response->xml(), - '//oai:request[@verb="ListMetadataFormats"]', - 'http://afi-sa.fr/oai2/do'); + $this->_xpath->assertXPath($this->_response->getBody(), + '//oai:request[@verb="ListMetadataFormats"]'); } /** @test */ public function shouldHaveOneMetadataFormat() { - $this->_xpath->assertXpathCount($this->_response->xml(), + $this->_xpath->assertXpathCount($this->_response->getBody(), '//oai:ListMetadataFormats/oai:metadataFormat', 1); } @@ -70,7 +70,7 @@ class ListMetadataFormatsTest extends Storm_Test_ModelTestCase { protected function _assertFormatContentAt($name, $content, $position) { $path = sprintf('//oai:ListMetadataFormats/oai:metadataFormat[%s]/oai:%s', $position, $name); - $this->_xpath->assertXpathContentContains($this->_response->xml(), $path, $content); + $this->_xpath->assertXpathContentContains($this->_response->getBody(), $path, $content); } } ?> \ No newline at end of file