handlerRequest(); ob_clean(); require_once($MIOLO->getConf('home.modules') . '/gnuteca3/classes/oaipmh/oai2server.php'); /** * Identifier settings. It needs to have proper values to reflect the settings of the data provider. * Is MUST be declared in this order * * - $identifyResponse['repositoryName'] : compulsory. A human readable name for the repository; * - $identifyResponse['baseURL'] : compulsory. The base URL of the repository; * - $identifyResponse['protocolVersion'] : compulsory. The version of the OAI-PMH supported by the repository; * - $identifyResponse['earliestDatestamp'] : compulsory. A UTCdatetime that is the guaranteed lower limit of all datestamps recording changes, modifications, or deletions in the repository. A repository must not use datestamps lower than the one specified by the content of the earliestDatestamp element. earliestDatestamp must be expressed at the finest granularity supported by the repository. * - $identifyResponse['deletedRecord'] : the manner in which the repository supports the notion of deleted records. Legitimate values are no ; transient ; persistent with meanings defined in the section on deletion. * - $identifyResponse['granularity'] : the finest harvesting granularity supported by the repository. The legitimate values are YYYY-MM-DD and YYYY-MM-DDThh:mm:ssZ with meanings as defined in ISO8601. * */ $requestURI = explode('?', $_SERVER['REQUEST_URI']); $requestURI = $requestURI[0]; $requestScheme = ''; if ( isset($_SERVER['REQUEST_SCHEME']) ) { $requestScheme = $_SERVER['REQUEST_SCHEME']; } elseif ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] = 'on') { $requestScheme = 'https'; } else { $requestScheme = ''; } $url = $requestScheme . '://' . $_SERVER['HTTP_HOST'] . $requestURI; $busMaterialControl = $MIOLO->getBusiness('gnuteca3', 'BusMaterialControl'); $minEntranceDate = $busMaterialControl->getMinEntranceDate(); $busPreference = $MIOLO->getBusiness('gnuteca3', 'BusPreference'); $adminEmail = $busPreference->getPreference('gnuteca3', 'EMAIL_ADMIN', false); $identifyResponse = array(); $identifyResponse["repositoryName"] = 'Gnuteca OAI2 PMH'; $identifyResponse["baseURL"] = $url;//'http://demonstracao.solis.com.br/oai_pmh/oai2.php'; $identifyResponse["protocolVersion"] = '2.0'; $identifyResponse['adminEmail'] = $adminEmail; $identifyResponse["earliestDatestamp"] = $minEntranceDate; //'2013-01-01T12:00:00Z'; $identifyResponse["deletedRecord"] = 'no'; // How your repository handles deletions // no: The repository does not maintain status about deletions. // It MUST NOT reveal a deleted status. // persistent: The repository persistently keeps track about deletions // with no time limit. It MUST consistently reveal the status // of a deleted record over time. // transient: The repository does not guarantee that a list of deletions is // maintained. It MAY reveal a deleted status for records. $identifyResponse["granularity"] = 'YYYY-MM-DD'; /* unit tests ;) */ if (!isset($args)) { $args = $_GET ? $_GET : $_POST; } if (!isset($uri)) { $uri = 'test.oai_pmh'; } $oai2 = new OAI2Server($uri, $args, $identifyResponse, array( 'ListMetadataFormats' => function($identifier = '') { if (!empty($identifier) && $identifier != 'a.b.c') { throw new OAI2Exception('idDoesNotExist'); } return array('oai_marcxml' => array('metadataPrefix'=>'oai_marcxml', 'schema'=>'http://www.loc.gov/MARC21/slim', 'metadataNamespace'=>'http://www.loc.gov/MARC21/slim', 'record_prefix'=>'oai_marcxml', 'record_namespace' => '')); }, 'ListSets' => function($resumptionToken = '') { $MIOLO = MIOLO::getInstance(); $busLibraryUnit = $MIOLO->getBusiness('gnuteca3' ,'BusLibraryUnit'); $units = $busLibraryUnit->listLibraryUnit(false, false); $return = array(); if ( is_array($units) ) { foreach ( $units as $i => $unit ) { $return[$i]['setSpec'] = $unit[0]; $return[$i]['setName'] = $unit[1]; } } return $return; }, 'ListRecords' => function($metadataPrefix, $from = NULL, $until = NULL, $set = NULL, $count = false, $deliveredRecords = 0, $maxItems = 0) { // Faz tratamento dos parĂ¢metros de data. $from = str_replace('Z', '', str_replace('T', ' ', $from)); $until = str_replace('Z', '', str_replace('T', ' ', $until)); $MIOLO = MIOLO::getInstance(); $busMaterial = $MIOLO->getBusiness('gnuteca3' ,'BusMaterial'); if ( $count ) { return $busMaterial->getCountMaterialForOAIPMH($from, $until, $set); } else { $records = $busMaterial->getMaterialForOAIPMH($from, $until, $deliveredRecords, $maxItems, null, $set); } if ($metadataPrefix != 'oai_marcxml') { throw new OAI2Exception('noRecordsMatch'); } return $records; }, 'GetRecord' => function($identifier, $metadataPrefix) use ($example_record) { $identifier = str_replace('oai:gnuteca:', '', $identifier); $MIOLO = MIOLO::getInstance(); $busMaterial = $MIOLO->getBusiness('gnuteca3' ,'BusMaterial'); $records = $busMaterial->getMaterialForOAIPMH(NULL, NULL, NULL, NULL, $identifier); $record = current($records); if ( !$record ) { throw new OAI2Exception('idDoesNotExist'); } return $record; }, ) ); $response = $oai2->response(); if (isset($return)) { return $response; } else { $response->formatOutput = true; $response->preserveWhiteSpace = false; header('Content-Type: text/xml'); echo $response->saveXML(); }