Make some variables global

This commit is contained in:
Sebastian Meyer 2017-05-13 12:21:26 +02:00
parent 387bc4c161
commit 2ec415907a
2 changed files with 6 additions and 4 deletions

View File

@ -57,6 +57,7 @@ $oai2 = new OAI2Server(
array( array(
'GetRecord' => 'GetRecord' =>
function($identifier, $metadataPrefix) { function($identifier, $metadataPrefix) {
global $records;
if (empty($records[$identifier])) { if (empty($records[$identifier])) {
return array(); return array();
} else { } else {
@ -69,6 +70,7 @@ $oai2 = new OAI2Server(
}, },
'ListRecords' => 'ListRecords' =>
function($metadataPrefix, $from = null, $until = null, $count = false, $deliveredRecords = 0, $maxItems = 100) { function($metadataPrefix, $from = null, $until = null, $count = false, $deliveredRecords = 0, $maxItems = 100) {
global $records, $timestamps;
$resultSet = array(); $resultSet = array();
foreach($timestamps as $timestamp => $identifiers) { foreach($timestamps as $timestamp => $identifiers) {
if ((is_null($from) || $timestamp >= $from) && (is_null($until) || $timestamp <= $until)) { if ((is_null($from) || $timestamp >= $from) && (is_null($until) || $timestamp <= $until)) {
@ -89,14 +91,14 @@ $oai2 = new OAI2Server(
}, },
'ListMetadataFormats' => 'ListMetadataFormats' =>
function($identifier = '') { function($identifier = '') {
if (!empty($identifier) && empty($records[$identifier]) { global $config;
if (!empty($identifier) && empty($records[$identifier])) {
throw new OAI2Exception('idDoesNotExist'); throw new OAI2Exception('idDoesNotExist');
} else { } else {
return array( return array(
$config['metadataFormat'] => array( $config['metadataFormat'] => array(
'metadataPrefix' => $config['metadataFormat'],
'schema'=> $config['metadataSchema'], 'schema'=> $config['metadataSchema'],
'metadataNamespace' => $config['metadataNamespace'] 'namespace' => $config['metadataNamespace']
) )
); );
} }

View File

@ -105,7 +105,7 @@ class OAI2Server {
$cmf = $this->response->addToVerbNode('metadataFormat'); $cmf = $this->response->addToVerbNode('metadataFormat');
$this->response->addChild($cmf, 'metadataPrefix', $key); $this->response->addChild($cmf, 'metadataPrefix', $key);
$this->response->addChild($cmf, 'schema', $val['schema']); $this->response->addChild($cmf, 'schema', $val['schema']);
$this->response->addChild($cmf, 'metadataNamespace', $val['metadataNamespace']); $this->response->addChild($cmf, 'metadataNamespace', $val['namespace']);
} }
} else { } else {
$this->errors[] = new OAI2Exception('noMetadataFormats'); $this->errors[] = new OAI2Exception('noMetadataFormats');