2013-05-07 19:48:37 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief Response to Verb ListMetadataFormats
|
|
|
|
*
|
2013-05-07 22:10:04 +02:00
|
|
|
* The information of supported metadata formats :
|
|
|
|
* try database table $SQL['table']
|
|
|
|
* else try $METADATAFORMATS array from config-metadataformats.php
|
2013-05-07 19:48:37 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a metadata format node to an ANDS_Response_XML
|
|
|
|
* \param &$outputObj
|
|
|
|
* type: ANDS_Response_XML. The ANDS_Response_XML object for output.
|
|
|
|
* \param $key
|
|
|
|
* type string. The name of new node.
|
|
|
|
* \param $val
|
|
|
|
* type: array. Values accessable through keywords 'schema' and 'metadataNamespace'.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function addMetedataFormat(&$outputObj,$key,$val) {
|
2013-05-07 22:01:22 +02:00
|
|
|
$cmf = $outputObj->add2_verbNode("metadataFormat");
|
|
|
|
$outputObj->addChild($cmf,'metadataPrefix',$key);
|
|
|
|
$outputObj->addChild($cmf,'schema',$val['schema']);
|
|
|
|
$outputObj->addChild($cmf,'metadataNamespace',$val['metadataNamespace']);
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($args['identifier'])) {
|
2013-05-07 22:01:22 +02:00
|
|
|
$identifier = $args['identifier'];
|
2013-05-07 22:10:04 +02:00
|
|
|
$query = 'select '.$SQL['metadataPrefix'].' FROM '.$SQL['table']. " WHERE ".$SQL['identifier']." = '".$id."'";
|
2013-05-07 22:01:22 +02:00
|
|
|
$res = $db->query($query);
|
|
|
|
if ($res==false) {
|
|
|
|
if (SHOW_QUERY_ERROR) {
|
|
|
|
echo __FILE__.','.__LINE__."<br />";
|
|
|
|
echo "Query: $query<br />\n";
|
|
|
|
die($db->errorInfo());
|
|
|
|
} else {
|
|
|
|
$errors[] = oai_error('idDoesNotExist','', $identifier);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$record = $res->fetch();
|
|
|
|
if($record===false) {
|
|
|
|
$errors[] = oai_error('idDoesNotExist', '', $identifier);
|
|
|
|
} else {
|
|
|
|
$mf = explode(",",$record[$SQL['metadataPrefix']]);
|
|
|
|
}
|
|
|
|
}
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//break and clean up on error
|
2013-05-07 22:10:04 +02:00
|
|
|
if (!empty($errors)) {
|
|
|
|
oai_exit();
|
|
|
|
}
|
2013-05-07 19:48:37 +02:00
|
|
|
|
|
|
|
$outputObj = new ANDS_Response_XML($args);
|
|
|
|
if (isset($mf)) {
|
2013-05-07 22:01:22 +02:00
|
|
|
foreach($mf as $key) {
|
|
|
|
$val = $METADATAFORMATS[$key];
|
|
|
|
addMetedataFormat($outputObj,$key, $val);
|
|
|
|
}
|
2013-05-07 19:48:37 +02:00
|
|
|
} elseif (is_array($METADATAFORMATS)) {
|
2013-05-07 22:01:22 +02:00
|
|
|
foreach($METADATAFORMATS as $key=>$val) {
|
|
|
|
addMetedataFormat($outputObj,$key, $val);
|
|
|
|
}
|
|
|
|
} else { // a very unlikely event
|
|
|
|
$errors[] = oai_error('noMetadataFormats');
|
|
|
|
oai_exit();
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|