isolate metadataformats in a config file

This commit is contained in:
Usuario Moodle 2013-05-07 17:10:04 -03:00
parent 91a657ae57
commit f0bf8e6bf5
5 changed files with 45 additions and 46 deletions

View File

@ -0,0 +1,37 @@
<?php
/**
* - <b>$METADATAFORMATS</b>: List of supported metadata formats. It is a two-dimensional array with keys.
* Each supported format is one element of this array at the first dimension.
* The key is the name of a metadata format.
* The exact number of items within each format associated array depends on the nature of a metadata format.
* Most definitions are done here but handlers themselves are defined in separated files because only the names of PHP script are listed here.
* - metadataPrefix
* - schema
* - metadataNamespace
* - myhandler
* - other optional items: record_prefix, record_namespace and etc.
*/
// define all supported metadata formats, has to be an array
//
// myhandler is the name of the file that handles the request for the
// specific metadata format.
// [record_prefix] describes an optional prefix for the metadata
// [record_namespace] describe the namespace for this prefix
$METADATAFORMATS = array (
'rif' => array('metadataPrefix'=>'rif',
'schema'=>'http://services.ands.org.au/sandbox/orca/schemata/registryObjects.xsd',
'metadataNamespace'=>'http://ands.org.au/standards/rif-cs/registryObjects/',
'myhandler'=>'record_rif.php'
),
'oai_dc' => array('metadataPrefix'=>'oai_dc',
'schema'=>'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'metadataNamespace'=>'http://www.openarchives.org/OAI/2.0/oai_dc/',
'myhandler'=>'record_dc.php',
'record_prefix'=>'dc',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
)
);
if (!is_array($METADATAFORMATS)) { exit("Configuration of METADATAFORMAT has been wrongly set. Correct your ".__FILE__);}

View File

@ -3,8 +3,9 @@
* \file * \file
* \brief Response to Verb ListMetadataFormats * \brief Response to Verb ListMetadataFormats
* *
* The information of supported metadata formats is saved in database and retrieved by calling function <B>idFormatQuery</B>. * The information of supported metadata formats :
* \sa idFormatQuery * try database table $SQL['table']
* else try $METADATAFORMATS array from config-metadataformats.php
*/ */
/** /**
@ -26,7 +27,7 @@ function addMetedataFormat(&$outputObj,$key,$val) {
if (isset($args['identifier'])) { if (isset($args['identifier'])) {
$identifier = $args['identifier']; $identifier = $args['identifier'];
$query = idFormatQuery($identifier); $query = 'select '.$SQL['metadataPrefix'].' FROM '.$SQL['table']. " WHERE ".$SQL['identifier']." = '".$id."'";
$res = $db->query($query); $res = $db->query($query);
if ($res==false) { if ($res==false) {
if (SHOW_QUERY_ERROR) { if (SHOW_QUERY_ERROR) {
@ -47,7 +48,9 @@ if (isset($args['identifier'])) {
} }
//break and clean up on error //break and clean up on error
if (!empty($errors)) oai_exit(); if (!empty($errors)) {
oai_exit();
}
$outputObj = new ANDS_Response_XML($args); $outputObj = new ANDS_Response_XML($args);
if (isset($mf)) { if (isset($mf)) {

View File

@ -67,6 +67,7 @@ foreach($attribs as $val) {
} }
require_once('oaidp-config.php'); require_once('oaidp-config.php');
require_once('config-metadataformats.php');
// Create a PDO object // Create a PDO object
try { try {

View File

@ -14,25 +14,12 @@
* *
* Some other used variables: * Some other used variables:
* *
* - <B>$adminEmail</B>: the e-mail addresses of administrators of the repository.
*
* - <b>$repositoryIdentifier</b> : For a data provider there is only one. For repositories to comply with the oai * - <b>$repositoryIdentifier</b> : For a data provider there is only one. For repositories to comply with the oai
* format it has to be unique identifiers for items records. Basically using domainname will be fine. * format it has to be unique identifiers for items records. Basically using domainname will be fine.
* See: http://www.openarchives.org/OAI/2.0/guidelines-oai-identifier.htm. * See: http://www.openarchives.org/OAI/2.0/guidelines-oai-identifier.htm.
* *
* - <b>$SETS</b>: An array with key words . List of supported SETs. * - <b>$SETS</b>: An array with key words . List of supported SETs.
* *
* - <b>$METADATAFORMATS</b>: List of supported metadata formats. It is a two-dimensional array with keys.
* Each supported format is one element of this array at the first dimension.
* The key is the name of a metadata format.
* The exact number of items within each format associated array depends on the nature of a metadata format.
* Most definitions are done here but handlers themselves are defined in separated files because only the names of PHP script are listed here.
* - metadataPrefix
* - schema
* - metadataNamespace
* - myhandler
* - other optional items: record_prefix, record_namespace and etc.
*
* - <b>$SQL</b>: Settings for database and queries from database * - <b>$SQL</b>: Settings for database and queries from database
* *
* - <b>$DSN</b>: DSN for connecting your database. Reference PDO for details. * - <b>$DSN</b>: DSN for connecting your database. Reference PDO for details.
@ -198,29 +185,6 @@ $SETS = array (
*/ */
); );
// define all supported metadata formats, has to be an array
//
// myhandler is the name of the file that handles the request for the
// specific metadata format.
// [record_prefix] describes an optional prefix for the metadata
// [record_namespace] describe the namespace for this prefix
$METADATAFORMATS = array (
'rif' => array('metadataPrefix'=>'rif',
'schema'=>'http://services.ands.org.au/sandbox/orca/schemata/registryObjects.xsd',
'metadataNamespace'=>'http://ands.org.au/standards/rif-cs/registryObjects/',
'myhandler'=>'record_rif.php'
),
'oai_dc' => array('metadataPrefix'=>'oai_dc',
'schema'=>'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'metadataNamespace'=>'http://www.openarchives.org/OAI/2.0/oai_dc/',
'myhandler'=>'record_dc.php',
'record_prefix'=>'dc',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
)
);
if (!is_array($METADATAFORMATS)) { exit("Configuration of METADATAFORMAT has been wrongly set. Correct your ".__FILE__);}
// The shorthand of xml schema namespace, no need to change this // The shorthand of xml schema namespace, no need to change this
define('XMLSCHEMA', 'http://www.w3.org/2001/XMLSchema-instance'); define('XMLSCHEMA', 'http://www.w3.org/2001/XMLSchema-instance');

View File

@ -241,12 +241,6 @@ function selectallQuery($metadPrefix = "rif", $id = ''){
return $query; return $query;
} }
/** this function will return metadataFormat of a record */
function idFormatQuery($id) {
global $SQL;
return 'select '.$SQL['metadataPrefix'].' FROM '.$SQL['table']. " WHERE ".$SQL['identifier']." = '".$id."'";
}
/** this function will return identifier and datestamp for all records /** this function will return identifier and datestamp for all records
* not very useful * not very useful
*/ */