Skip to content

Commit

Permalink
First example lom version
Browse files Browse the repository at this point in the history
  • Loading branch information
janreijnders committed Oct 26, 2021
1 parent 4cd18cb commit 6accfa0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions oai-pmh/index.html
Expand Up @@ -16,8 +16,8 @@ <h2>Simple interface to sample server</h2>
<li><a href="oai.php?verb=Identify">Identify</a></li>
<li><a href="oai.php?verb=ListMetadataFormats">ListMetadataFormats</a></li>
<li><a href="oai.php?verb=ListSets">ListSets</a></li>
<li><a href="oai.php?verb=ListIdentifiers&amp;metadataPrefix=oai_dc">ListIdentifiers(metadataPrefix=oai_dc)</a></li>
<li><a href="oai.php?verb=ListRecords&amp;metadataPrefix=oai_dc">ListRecords(metadataPrefix=oai_dc)</a></li>
<li><a href="oai.php?verb=ListIdentifiers&amp;metadataPrefix=lom_ims">ListIdentifiers(metadataPrefix=lom_ims)</a></li>
<li><a href="oai.php?verb=ListRecords&amp;metadataPrefix=lom_ims">ListRecords(metadataPrefix=lom_ims)</a></li>
<li><a href="oai.php?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=a.b.c">GetRecord(metadataPrefix=oai_dc, identifier=a.b.c)</a></li>
</ul>
</body>
Expand Down
31 changes: 18 additions & 13 deletions oai-pmh/oai.php
Expand Up @@ -61,7 +61,12 @@ function($identifier = '') {
'schema'=>'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'metadataNamespace'=>'http://www.openarchives.org/OAI/2.0/oai_dc/',
'record_prefix'=>'dc',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'));
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
),
'lom_ims' => array('metaDataPrefix'=>'lom_ims',
'schema'=>'http://www.imsglobal.org/xsd/imsmd_v1p2p4.xsd',
'metadataNamespace'=> 'http://www.imsglobal.org/xsd/imsmd_v1p2',
));
},

'ListSets' =>
Expand Down Expand Up @@ -91,9 +96,6 @@ function($metadataPrefix, $from = '', $until = '', $set = '', $count = false, $d
if ($set != '') {
throw new OAIException('noSetHierarchy');
}
if ($metadataPrefix != 'oai_dc') {
throw new OAIException('noRecordsMatch');
}
$records = call_user_func(getTemplates);
return $records;
},
Expand Down Expand Up @@ -159,6 +161,7 @@ function getSingleTemplate($template_id) {
}

function getTemplates() {
global $xerte_toolkits_site;
$prefix = $xerte_toolkits_site->database_table_prefix;

$q = "select td.template_id,
Expand Down Expand Up @@ -205,21 +208,23 @@ function makeRecordFromTemplate($template, $metadata){
global $xerte_toolkits_site;
$record = array('identifier' => ($xerte_toolkits_site->site_url . $template['template_id']),
'datestamp' => date($template['date_modified']),
'set' => 'class:activity',
//'set' => 'class:activity',
'metadata' => array(
'container_name' => 'oai_dc:dc',
'container_name' => 'lom',
'container_attributes' => array(
'xmlns:oai_dc' => "http://www.openarchives.org/OAI/2.0/oai_dc/",
'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
'xmlns' => "http://www.imsglobal.org/xsd/imsmd_v1p2",
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
'xsi:schemaLocation' =>
'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'
'http://www.imsglobal.org/xsd/imsmd_v1p2 http://www.imsglobal.org/xsd/imsmd_v1p2p4.xsd'
),
'fields' => array(
'dc:title' => $template['template_name'],//'Testing records',
'dc:author' => $template['owner_username']
)
'general' => array(
'title' => $template['template_name'],//'Testing records',
'language'=> explode("-",$metadata->language)[0],
'description'=> $metadata->description
),
'keywords' => explode("\n",$metadata->keywords),
));
return $record;
};


9 changes: 7 additions & 2 deletions oai-pmh/oaiserver.php
Expand Up @@ -314,8 +314,13 @@ private function add_metadata($cur_record, $record)
foreach ($record['metadata']['container_attributes'] as $name => $value) {
$schema_node->setAttribute($name, $value);
}
foreach ($record['metadata']['fields'] as $name => $value) {
$this->response->addChild($schema_node, $name, $value);
$general_node = $this->response->addChild($schema_node, 'general');
foreach ($record['metadata']['general'] as $name => $value) {
$this->response->addChild($general_node, $name, $value);
}
$keyword_node = $this->response->addChild($general_node, 'keywords');
foreach ($record['metadata']['keywords'] as $value) {
$this->response->addChild($keyword_node, 'keyword', $value);
}
}

Expand Down
6 changes: 3 additions & 3 deletions oai-pmh/oaixml.php
Expand Up @@ -8,10 +8,10 @@ function __construct($uri, $verb, $request_args) {

$this->verb = $verb;
$this->doc = new DOMDocument("1.0","UTF-8");
$oai_node = $this->doc->createElement("lom"); //"OAI-PMH");
$oai_node->setAttribute("xmlns","http://ltsc.ieee.org/xsd/LOM");
$oai_node = $this->doc->createElement("OAI-PMH"); //"OAI-PMH");
$oai_node->setAttribute("xmlns","http://www.openarchives.org/OAI/2.0/");
$oai_node->setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
$oai_node->setAttribute("xsi:schemaLocation","http://ltsc.ieee.org/xsd/LOM http://standards.ieee.org/reading/ieee/downloads/LOM/lomv1.0/xsd/lomLoose.xsd");
$oai_node->setAttribute("xsi:schemaLocation","http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd");
$this->addChild($oai_node,"responseDate",gmdate("Y-m-d\TH:i:s\Z"));
$this->doc->appendChild($oai_node);

Expand Down

0 comments on commit 6accfa0

Please sign in to comment.