Make data directory configurable
This commit is contained in:
parent
fc3a3d1861
commit
e1f59e2c66
|
@ -12,9 +12,9 @@ Installation
|
||||||
|
|
||||||
1. Deploy all the files to a webserver.
|
1. Deploy all the files to a webserver.
|
||||||
|
|
||||||
2. Put the records into the data/ directory (or create a symlink named "data" pointing to your records). Each record has to be a separate XML file with its identifier as filename (i.e. 12345678.xml).
|
2. Edit oai2config.php and adjust the settings according to your preferences.
|
||||||
|
|
||||||
3. Edit oai2config.php and adjust the settings according to your preferences.
|
3. Put the records into the specified data directory. Each record has to be a separate XML file with its identifier as filename (i.e. 12345678.xml).
|
||||||
|
|
||||||
4. Congratulations! Now you are running an OAI-PMH 2.0 compatible data provider.
|
4. Congratulations! Now you are running an OAI-PMH 2.0 compatible data provider.
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ require_once('oai2server.php');
|
||||||
$records = array();
|
$records = array();
|
||||||
$timestamps = array();
|
$timestamps = array();
|
||||||
|
|
||||||
$files = glob('data/*.xml');
|
$files = glob(rtrim($config['dataDirectory'], '/').'/*.xml');
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
$records[pathinfo($file, PATHINFO_FILENAME)] = $file;
|
$records[pathinfo($file, PATHINFO_FILENAME)] = $file;
|
||||||
$timestamps[filemtime($file)][] = pathinfo($file, PATHINFO_FILENAME);
|
$timestamps[filemtime($file)][] = pathinfo($file, PATHINFO_FILENAME);
|
||||||
|
@ -40,10 +40,11 @@ ksort($timestamps);
|
||||||
reset($timestamps);
|
reset($timestamps);
|
||||||
|
|
||||||
// Get current base URL
|
// Get current base URL
|
||||||
|
$baseURL = $_SERVER['HTTP_HOST'].parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
|
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
|
||||||
$baseURL = 'https://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
|
$baseURL = 'https://'.$baseURL;
|
||||||
} else {
|
} else {
|
||||||
$baseURL = 'http://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
|
$baseURL = 'http://'.$baseURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the Identify response
|
// Build the Identify response
|
||||||
|
|
|
@ -37,6 +37,10 @@ $config['metadataFormat'] = 'oai_dc';
|
||||||
$config['metadataSchema'] = 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd';
|
$config['metadataSchema'] = 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd';
|
||||||
$config['metadataNamespace'] = 'http://www.openarchives.org/OAI/2.0/oai_dc/';
|
$config['metadataNamespace'] = 'http://www.openarchives.org/OAI/2.0/oai_dc/';
|
||||||
|
|
||||||
|
// Directory containing the records
|
||||||
|
// (Make sure the given path is readable)
|
||||||
|
$config['dataDirectory'] = 'data/';
|
||||||
|
|
||||||
// Maximum number of records to return before giving a resumption token
|
// Maximum number of records to return before giving a resumption token
|
||||||
$config['maxRecords'] = 100;
|
$config['maxRecords'] = 100;
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ class OAI2Server {
|
||||||
$errorResponse = new OAI2XMLResponse($this->uri, $this->verb, $this->args);
|
$errorResponse = new OAI2XMLResponse($this->uri, $this->verb, $this->args);
|
||||||
$oai_node = $errorResponse->doc->documentElement;
|
$oai_node = $errorResponse->doc->documentElement;
|
||||||
foreach($this->errors as $e) {
|
foreach($this->errors as $e) {
|
||||||
$node = $errorResponse->addChild($oai_node,"error",$e->getMessage());
|
$node = $errorResponse->addChild($oai_node, 'error', $e->getMessage());
|
||||||
$node->setAttribute("code",$e->getOAI2Code());
|
$node->setAttribute('code', $e->getOAI2Code());
|
||||||
}
|
}
|
||||||
return $errorResponse->doc;
|
return $errorResponse->doc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue