Skip to content

Commit

Permalink
add description on identify route
Browse files Browse the repository at this point in the history
  • Loading branch information
herewithme committed Feb 17, 2023
1 parent 68684e9 commit 57440dd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
30 changes: 29 additions & 1 deletion Classes/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class Server
private $token_prefix = '';
private $token_valid = 86400;

const NS_URI_OAI_DC = 'http://www.openarchives.org/OAI/2.0/oai_dc/';
const NS_URI_DC = 'http://purl.org/dc/elements/1.1/';

public function __construct($uri, $args, $identifyResponse, $callbacks, $config)
{
$this->uri = $uri;
Expand Down Expand Up @@ -92,7 +95,32 @@ public function Identify()
$cmf = $this->response->addToVerbNode('Identify', null, true);

foreach ($this->identifyResponse as $key => $val) {
$this->response->addChild($cmf, $key, $val);
if ( $key === 'description' ) {
$element = $this->response->doc->createElement( 'description' );
$metadata_node = $cmf->appendChild( $element );

$element = $this->response->doc->createElement( 'oai_dc:dc' );
$element->setAttribute( 'xmlns:oai_dc', self::NS_URI_OAI_DC );
$element->setAttribute( 'xmlns', 'http://www.openarchives.org/OAI/2.0/' );
$element->setAttribute( 'xmlns:dc', 'http://purl.org/dc/elements/1.1/' );
$element->setAttribute( 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance' );
$element->setAttribute( 'xsi:schemaLocation',
'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd' );
$sub_description_node = $metadata_node->appendChild( $element );

foreach ( $val as $_key => $content ) {
if ( 'identifier' == $_key ) {
$element = $this->response->doc->createElement( 'dc:identifier', htmlspecialchars( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ), ENT_XML1, 'UTF-8' ) );
} else {
$element = $this->response->doc->createElement( 'dc:description', htmlspecialchars( html_entity_decode( $content, ENT_QUOTES, 'UTF-8' ), ENT_XML1, 'UTF-8' ) );
$element->setAttribute( 'xml:lang', str_replace('lang:', '', $_key) );
}

$sub_description_node->appendChild( $element );
}
} else {
$this->response->addChild($cmf, $key, $val);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Configuration/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
'oai_dc' => [
'schema' => 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'namespace' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'description' => array(
'identifier' => 'https://urloftheoairepo/',
'lang:fre' => 'French language description of the OAI warehouse.',
'lang:eng' => 'English language description of the OAI warehouse.'
// You can add any additional languages
)
],
],

Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
'adminEmail' => $config->getConfigValue('adminEmail'),
'earliestDatestamp' => gmdate('Y-m-d\TH:i:s\Z', $data->getEarliest()),
'deletedRecord' => $config->getConfigValue('deletedRecord'),
'granularity' => 'YYYY-MM-DDThh:mm:ssZ'
'granularity' => 'YYYY-MM-DDThh:mm:ssZ',
'description' => $config->getConfigValue('metadataPrefix')['oai_dc']['description']
];

$oai2 = new Server(
Expand Down

0 comments on commit 57440dd

Please sign in to comment.