/*
* +----------------------------------------------------------------------+
* | PHP Version 4 |
* +----------------------------------------------------------------------+
* | Copyright (c) 2002 Heinrich Stamerjohanns |
* | |
* | oaidp-util.php -- Utilities for the OAI Data Provider |
* | |
* | This is free software; you can redistribute it and/or modify it under|
* | the terms of the GNU General Public License as published by the |
* | Free Software Foundation; either version 2 of the License, or (at |
* | your option) any later version. |
* | This software is distributed in the hope that it will be useful, but |
* | WITHOUT ANY WARRANTY; without even the implied warranty of |
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* | GNU General Public License for more details. |
* | You should have received a copy of the GNU General Public License |
* | along with software; if not, write to the Free Software Foundation, |
* | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* | |
* +----------------------------------------------------------------------+
* | Derived from work by U. Müller, HUB Berlin |
* | |
* | Written by Heinrich Stamerjohanns, May 2002 |
* | stamer@uni-oldenburg.de |
* +----------------------------------------------------------------------+
*/
//
// $Id: oaidp-util.php,v 1.03 2003/04/08 14:40:23 stamer Exp $
//
function get_token() {
list($usec, $sec) = explode(" ", microtime());
return ((int)($usec*1000) + (int)($sec*1000));
}
function oai_error($code, $argument='', $value='')
{
global $request;
global $request_err;
switch ($code) {
case 'badArgument' :
$text = "The argument '$argument' (value='$value') included in the request is not valid.";
break;
case 'badGranularity' :
$text = "The value '$value' of the argument '$argument' is not valid.";
$code = 'badArgument';
break;
case 'badResumptionToken' :
$text = "The resumptionToken '$value' does not exist or has already expired.";
break;
case 'badRequestMethod' :
$text = "The request method '$argument' is unknown.";
$code = 'badVerb';
break;
case 'badVerb' :
$text = "The verb '$argument' provided in the request is illegal.";
break;
case 'cannotDisseminateFormat' :
$text = "The metadata format '$value' given by $argument is not supported by this repository.";
break;
case 'exclusiveArgument' :
$text = 'The usage of resumptionToken as an argument allows no other arguments.';
$code = 'badArgument';
case 'idDoesNotExist' :
$text = "The value '$value' of the identifier is illegal for this repository.";
break;
case 'missingArgument' :
$text = "The required argument '$argument' is missing in the request.";
$code = 'badArgument';
break;
case 'noRecordsMatch' :
$text = 'The combination of the given values results in an empty list.';
break;
case 'noMetadataFormats' :
$text = 'There are no metadata formats available for the specified item.';
break;
case 'noVerb' :
$text = 'The request does not provide any verb.';
$code = 'badVerb';
break;
case 'noSetHierarchy' :
$text = 'This repository does not support sets.';
break;
case 'sameArgument' :
$text = 'Do not use them same argument more than once.';
$code = 'badArgument';
break;
case 'sameVerb' :
$text = 'Do not use verb more than once.';
$code = 'badVerb';
break;
default:
$text = "Unknown error: code: '$code', argument: '$argument', value: '$value'";
$code = 'badArgument';
}
if ($code == 'badVerb' || $code == 'badArgument') {
$request = $request_err;
}
$error .= ' '.xmlstr($text, 'iso8859-1', false)."\n";
return $error;
}
function xmlstr($string, $charset="iso8859-1", $xmlescaped="false")
{
// just remove invalid characters
$pattern ="/[\x-\x8\xb-\xc\xe-\x1f]/";
$string = preg_replace($pattern,'',$string);
//$string = htmlspecialchars($string);
// escape only if string is not escaped
if (!$xmlescaped) {
$xmlstr = utf8_encode($string);
}
if ($charset != "utf-8") {
$xmlstr = utf8_encode($xmlstr);
}
return $xmlstr;
}
// will split a string into elements and return XML
// supposed to print values from database
function xmlrecord($sqlrecord, $element, $attr = '', $indent = 0)
{
global $SQL;
global $xmlescaped;
global $charset;
$str = '';
if ($attr != '') {
$attr = ' '.$attr;
}
if ($sqlrecord != '') {
if (isset($SQL['split'])) {
$temparr = explode($SQL['split'], $sqlrecord);
foreach ($temparr as $val) {
$str .= str_pad('', $indent).'<'.$element.$attr.'>'.xmlstr($val, $charset, $xmlescaped).''.$element.">\n";
}
return $str;
} else {
return str_pad('', $indent).'<'.$element.$attr.'>'.utf8_encode(xmlstr($sqlrecord, $charset, $xmlescaped)).''.$element.">\n";
}
} else {
return '';
}
}
function xmlelement($element, $attr = '', &$indent, $open=true)
{
global $SQL;
if ($attr != '') {
$attr = ' '.$attr;
}
if ($open) {
return str_pad('', $indent).'<'.$element.$attr.'>'."\n";
$indent += 2;
} else {
return str_pad('', $indent).''.$element.'>'."\n";
$indent -= 2;
}
}
// takes either an array or a string and outputs them as XML entities
// this function assumes that the strings are written in iso8859-1 and have
// not been escaped yet.
function xmlformat($record, $element, $indent = 0)
{
$str = '';
if (is_array($record)) {
foreach ($record as $val) {
$str .= str_pad('', $indent).'<'.$element.'>'.xmlstr($val, 'iso8859-1', false).''.$element.">\n";
}
return $str;
} elseif ($record != '') {
return str_pad('', $indent).'<'.$element.'>'.xmlstr($record, 'iso8859-1', false).''.$element.">\n";
} else {
return '';
}
}
function date2UTCdatestamp($date)
{
global $granularity;
switch ($granularity) {
case 'YYYY-MM-DDThh:mm:ssZ':
// we assume common date ("YYYY-MM-DD") or
// datetime format ("YYYY-MM-DD hh:mm:ss")
// in the database
if (strstr($date, ' ')) {
// date is datetime format
if (strstr($date, '+')) {
// format ("YYYY-MM-DD hh:mm:ss+01")
list($ld, $lt) = explode(" ", $date);
list($y, $m, $d) = explode("-", $ld);
list($time, $tz) = explode("+", $lt);
list($h, $min, $s) = explode(":", $time);
if ($tz > 0) {
$timestamp = mktime($h, $min, $s, $m, $d, $y);
$timestamp -= (int) $tz * 86400;
return strftime("%Y-%m-%dT%H:%M:%SZ", $timestamp);
}
}
return str_replace(' ', 'T', $date).'Z';
} else {
// date is date format
// granularity 'YYYY-MM-DD' should be used...
return $date.'T00:00:00Z';
}
break;
case 'YYYY-MM-DD':
if (strstr($date, ' ')) {
// date is datetime format
list($date, $time) = explode(" ", $date);
return $date;
} else {
return $date;
}
break;
default: die("Unknown granularity!");
}
}
function checkDateFormat($date) {
global $granularity;
global $message;
if ($granularity == 'YYYY-MM-DDThh:mm:ssZ') {
$checkstr = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$';
} else {
$checkstr = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}$)';
}
if (ereg($checkstr, $date, $regs)) {
if (checkdate($regs[2], $regs[3], $regs[1])) {
return 1;
}
else {
$message = "Invalid Date: $date is not a valid date.";
return 0;
}
}
else {
$message = "Invalid Date Format: $date does not comply to the date format $granularity.";
return 0;
}
}
function formatDatestamp($datestamp)
{
global $granularity;
//$datestamp = date2UTCdatestamp($datestamp);
$datestamp = format_date($datestamp);
if (!checkDateFormat($datestamp)) {
if ($granularity == 'YYYY-MM-DD') {
return '2002-01-01';
} else {
return '2002-01-01T00:00:00Z';
}
} else {
return $datestamp;
}
}
function oai_close()
{
global $compress;
echo "\n";
//echo "";
if ($compress) {
ob_end_flush();
}
}
function oai_exit()
{
global $CONTENT_TYPE;
global $xmlheader;
global $request;
global $errors;
header($CONTENT_TYPE);
echo $xmlheader;
echo $request;
echo $errors;
oai_close();
exit();
}
function php_is_at_least($version) {
list($c_r, $c_mj, $c_mn) = explode('.', phpversion());
list($v_r, $v_mj, $v_mn) = explode('.', $version);
if ($c_r >= $v_r && $c_mj >= $v_mj && $c_mn >= $v_mn) return TRUE;
else return FALSE;
}
function metadataHeader($prefix)
{
global $METADATAFORMATS;
global $XMLSCHEMA;
if ($prefix == "kmoddl_dc")
{
// return " ";
return " ";
}
else if ($prefix == "nsdl_dc")
{
return ' ';
}
$myformat = $METADATAFORMATS[$prefix];
$str =
' <'.$prefix;
if ($myformat['record_prefix']) {
$str .= ':'.$myformat['record_prefix'];
}
$str .= "\n".
' xmlns:'.$prefix.'="'.$myformat['metadataNamespace'].'"'."\n";
if ($myformat['record_prefix'] && $myformat['record_namespace']) {
$str .=
' xmlns:'.$myformat['record_prefix'].'="'.$myformat['record_namespace'].'"'."\n";
}
$str .=
' xmlns:xsi="'.$XMLSCHEMA.'"'."\n".
' xsi:schemaLocation="'.$myformat['metadataNamespace']."\n".
' '.$myformat['schema'].'">'."\n";
return $str;
}
function changeFields($source, &$target)
{
$target = $source;
}
function format_date($mydate)
{
if (strlen($mydate) != 14)
{
return substr($mydate, 0, 4);
}
else
{
$formatdate = substr($mydate, 0, 4) . "-" . substr($mydate, 4, 2) . "-" . substr($mydate, 6, 2) . "T";
$formatdate .= substr($mydate, 8, 2) . ":" . substr($mydate, 10, 2) . ":" . substr($mydate, 12, 2) . "Z";
return $formatdate;
}
}
?>
/*
* +----------------------------------------------------------------------+
* | PHP Version 4 |
* +----------------------------------------------------------------------+
* | Copyright (c) 2002-2003 Heinrich Stamerjohanns |
* | |
* | oaidp-config.php -- Configuration of the OAI Data Provider |
* | |
* | This is free software; you can redistribute it and/or modify it under|
* | the terms of the GNU General Public License as published by the |
* | Free Software Foundation; either version 2 of the License, or (at |
* | your option) any later version. |
* | This software is distributed in the hope that it will be useful, but |
* | WITHOUT ANY WARRANTY; without even the implied warranty of |
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* | GNU General Public License for more details. |
* | You should have received a copy of the GNU General Public License |
* | along with software; if not, write to the Free Software Foundation, |
* | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* | |
* +----------------------------------------------------------------------+
* | Derived from work by U. Müller, HUB Berlin |
* | |
* | Written by Heinrich Stamerjohanns, May 2002 |
* | stamer@uni-oldenburg.de |
* +----------------------------------------------------------------------+
*/
//
// $Id: oaidp-config.php,v 1.06 2003/04/09 16:59:57 stamer Exp $
//
// This is the configuration file for the PHP OAI Data-Provider.
// Please read through the whole file, there are several things, that
// need to be adjusted, especially the DB connection and table values
// further below.
// use PEAR classes
// if you do not find PEAR, use something like this
ini_set('include_path', '.:/library_www/php/lib/php');
// Windows users might like to try this
// ini_set('include_path', '.;c:\php\pear');
// if there are problems with unknown 'numrows', then make sure
// to upgrade to a decent PEAR version.
require_once('DB.php');
// do not change
$MY_URI = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
// MUST (only one)
// please adjust
$repositoryName = 'KMODDL OAI Repository, Kroch Library, Cornell University';
$baseURL = $MY_URI;
// You can use a static URI as well.
// $baseURL = "http://my.server.org/oai/oai2.php";
// do not change
$protocolVersion = '2.0';
// How your repository handles deletions
// no: The repository does not maintain status about deletions.
// It MUST NOT reveal a deleted status.
// persistent: The repository persistently keeps track about deletions
// with no time limit. It MUST consistently reveal the status
// of a deleted record over time.
// transient: The repository does not guarantee that a list of deletions is
// maintained. It MAY reveal a deleted status for records.
//
// If your database keeps track of deleted records change accordingly.
// Currently if $record['deleted'] is set to 'true', $status_deleted is set.
// Some lines in listidentifiers.php, listrecords.php, getrecords.php
// must be changed to fit the condition for your database.
$deletedRecord = 'no';
// MAY (only one)
//granularity is days
//$granularity = 'YYYY-MM-DD';
// granularity is seconds
$granularity = 'YYYY-MM-DDThh:mm:ssZ';
//$granularity = 'YYYY-MM-DD';
// MUST (only one)
// the earliest datestamp in your repository,
// please adjust
//$earliestDatestamp = '2004-06-21T00:00:00Z';
$earliestDatestamp = '2000-01-01';
// this is appended if your granularity is seconds.
// do not change
if ($granularity == 'YYYY-MM-DDThh:mm:ssZ') {
$earliestDatestamp .= 'T00:00:00Z';
}
// MUST (multiple)
// please adjust
//$adminEmail = array('kw33@cornell.edu');
$adminEmail = array('maa21@cornell.edu');
// MAY (multiple)
// Comment out, if you do not want to use it.
// Currently only gzip is supported (you need output buffering turned on,
// and php compiled with libgz).
// The client MUST send "Accept-Encoding: gzip" to actually receive
// compressed output.
$compression = array('gzip');
// MUST (only one)
// should not be changed
$delimiter = ':';
// MUST (only one)
// You may choose any name, but for repositories to comply with the oai
// format for unique identifiers for items records.
// see: http://www.openarchives.org/OAI/2.0/guidelines-oai-identifier.htm
// Basically use domainname-word.domainname
// please adjust
$repositoryIdentifier = 'kmoddl.library.cornell.edu';
// description is defined in identify.php
$show_identifier = true;
// You may include details about your community and friends (other
// data-providers).
// Please check identify.php for other possible containers
// in the Identify response
// maximum mumber of the records to deliver
// (verb is ListRecords)
// If there are more records to deliver
// a ResumptionToken will be generated.
$MAXRECORDS = 50;
// maximum mumber of identifiers to deliver
// (verb is ListIdentifiers)
// If there are more identifiers to deliver
// a ResumptionToken will be generated.
$MAXIDS = 400;
// After 24 hours resumptionTokens become invalid.
$tokenValid = 24*3600;
$expirationdatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$tokenValid);
// use this for testing purposes
//$CONTENT_TYPE = 'Content-Type: text/plain';
// use this for production purposes
$CONTENT_TYPE = 'Content-Type: text/xml';
// define all supported sets in your repository
$SETS = array (
// array('setSpec'=>'phdthesis', 'setName'=>'PHD Thesis', 'setDescription'=>'') //,
// array('setSpec'=>'math', 'setName'=>'Mathematics') ,
// array('setSpec'=>'phys', 'setName'=>'Physics')
);
// define all supported metadata formats
//
// 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 (
'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'=>'oai_dc.php',
'record_prefix'=>'dc',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
),
'nsdl_dc' => array('metadataPrefix'=>'nsdl_dc',
'schema'=>'http://ns.nsdl.org/schemas/nsdl_dc/nsdl_dc_v1.02.xsd',
'metadataNamespace'=>'http://ns.nsdl.org/nsdl_dc_v1.02/',
'myhandler'=>'nsdl_dc.php',
'record_prefix'=>'nsdl_dc',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
),
'kmoddl_dc' => array('metadataPrefix'=>'kmoddl_dc',
'schema'=>'http://purl.org/kmoddl/kmoddl_v1.00/kmoddl_v1.00.xsd',
'metadataNamespace'=>'http://purl.org/kmoddl/kmoddl_v1.00/',
'myhandler'=>'kmoddl_dc.php',
'record_prefix'=>'kmoddl',
'record_namespace' => 'http://purl.org/dc/elements/1.1/'
)
//array('metadataPrefix'=>'olac',
// 'schema'=>'http://www.language-archives.org/OLAC/olac-2.0.xsd',
// 'metadataNamespace'=>'http://www.openarchives.org/OLAC/0.2/',
// 'handler'=>'record_olac.php'
//)
);
//
// DATABASE SETUP
//
// change according to your local DB setup.
$DB_HOST = 'localhost';
$DB_USER = 'kmoddl_p';
$DB_PASSWD = 'F6Chassis#place';
$DB_NAME = 'kmoddl_production';
// Data Source Name: This is the universal connection string
// if you use something other than mysql edit accordingly.
// Example for MySQL
$DSN = "mysql://$DB_USER:$DB_PASSWD@$DB_HOST/$DB_NAME";
// Example for Oracle
// $DSN = "oci8://$DB_USER:$DB_PASSWD@$DB_NAME";
// the charset you store your metadata in your database
// currently only utf-8 and iso8859-1 are supported
$charset = "utf-8";
// if entities such as < > ' " in your metadata has already been escaped
// then set this to true (e.g. you store < as < in your DB)
$xmlescaped = false;
// We store multiple entries for one element in a single row
// in the database. SQL['split'] ist the delimiter for these entries.
// If you do not do this, do not define $SQL['split']
// $SQL['split'] = ';';
// the name of the table where your store your metadata
// $SQL['table'] = 'oai_records';
$SQL['table'] = 'oai_records';
// the name of the column where you store your sequence
// (or autoincrement values).
$SQL['id_column'] = 'serial';
// the name of the column where you store the unique identifiers
// pointing to your item.
// this is your internal identifier for the item
// $SQL['identifier'] = 'url';
$SQL['identifier'] = 'serial';
// If you want to expand the internal identifier in some way
// use this (but not for OAI stuff, see next line)
$idPrefix = '';
// this is your external (OAI) identifier for the item
// this will be expanded to
// oai:$repositoryIdentifier:$idPrefix$SQL['identifier']
// should not be changed
//$oaiprefix = "oai".$delimiter.$repositoryIdentifier.$delimiter.$idPrefix.$delimiter;
$oaiprefix = "oai".$delimiter.$repositoryIdentifier.$delimiter;
// adjust anIdentifier with sample contents an identifier
$sampleIdentifier = $oaiprefix.'1';
// the name of the column where you store your datestamps
// $SQL['datestamp'] = 'datestamp';
$SQL['datestamp'] = 'last_update';
// the name of the column where you store information whether
// a record has been deleted. Leave it as it is if you do not use
// this feature.
$SQL['deleted'] = 'deleted';
// to be able to quickly retrieve the sets to which one item belongs,
// the setnames are stored for each item
// the name of the column where you store sets
// $SQL['set'] = 'oai_set';
$SQL['set'] = 'oai_set';
// for checking with date stamps
$SQL['earliest'] = date($earliestDatestamp);
/*
custom dublin core terms
*/
$SQL["dc_terms"] = array( "id" => "myid",
"title"=>"title",
"alternative"=>"alternative",
"subject"=>"subject",
"category_title"=>"category_title",
"creator_family"=>"name_family",
"creator_middle"=>"name_middle",
"creator_given"=>"name_given",
"description"=>"description",
"publisher"=>"publisher",
"contributor"=>"contributor",
"date"=>"desc_date",
"created"=>"date_created",
"dcmi_type"=>"dcmi_type",
"medium"=>"medium",
"format"=>"format",
"identifier"=>"identifier",
"language"=>"english",
"audience"=>"audience",
"relation"=>"relation",
"rights"=>"rights",
"kmoddl_type"=>"KMODDLType",
"voigtid" => "voigtid",
"size" => "size",
"identifier" => "identifier",
"manufacturer" => "manufacturer"
);
/*
End of custom variables
2004.06.22
by Shin-Woo Kim
*/
// Here are a couple of queries which might need to be adjusted to
// your needs. Normally, if you have correctly named the columns above,
// this does not need to be done.
// this function should generate a query which will return
// all records
// the useless condition id_column = id_column is just there to ease
// further extensions to the query, please leave it as it is.
function selectallQuery ($id = '')
{
global $SQL;
if ($id != '' )
{
if ( is_numeric($id) )
{
$sql = "SELECT oai_records.*, oai_types.title
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
WHERE oai_records.serial = $id";
$result = @mysql_query( $sql );
if ( $row = mysql_fetch_array($result) )
{
if ( $row["title"] == "model" )
{
$sql = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_models.*,
v2_models.title_english AS " . $SQL["dc_terms"]["title"] . ",
v2_models.title_german AS " . $SQL["dc_terms"]["alternative"] . ",
v2_models.title_prefix AS " . $SQL["dc_terms"]["identifier"] . ",
v2_models.keywords AS " . $SQL["dc_terms"]["subject"] . ",
v2_model_categories.title_english AS " . $SQL["dc_terms"]["category_title"] . ",
v2_people.name_family AS " . $SQL["dc_terms"]["creator_family"] . ",
v2_people.name_given AS " . $SQL["dc_terms"]["creator_given"] . ",
v2_people.name_middle AS " . $SQL["dc_terms"]["creator_middle"] . ",
v2_resource_types.oai_title AS " . $SQL["dc_terms"]["kmoddl_type"] . ",
v2_dcmi_types.title AS " . $SQL["dc_terms"]["dcmi_type"] . ",
v2_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_manufacturers.name AS " . $SQL["dc_terms"]["manufacturer"] . "
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_models ON oai_records.id = v2_models.id
INNER JOIN v2_people ON v2_models.fk_creator = v2_people.id
INNER JOIN v2_model_categories ON v2_models.fk_category = v2_model_categories.id
INNER JOIN v2_resource_types ON v2_models.fk_resource_type = v2_resource_types.id
INNER JOIN v2_dcmi_types ON v2_resource_types.fk_DCMI_type = v2_dcmi_types.id
INNER JOIN v2_publishers ON v2_models.fk_publisher = v2_publishers.id
INNER JOIN v2_manufacturers ON v2_models.fk_manufacturer = v2_manufacturers.id
WHERE oai_types.title = 'model' AND oai_records.serial = $id AND oai_records.status = 1
";
}
else if ( $row["title"] == "resource" )
{
$sql = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_resources.*,
v2_resources.keywords AS " . $SQL["dc_terms"]["subject"] . ",
v2_resource_types.oai_title AS " . $SQL["dc_terms"]["kmoddl_type"] . ",
v2_dcmi_types.title AS " . $SQL["dc_terms"]["dcmi_type"] . ",
v2_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_mimetypes.formal AS " . $SQL["dc_terms"]["format"] . "
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_resources ON oai_records.id = v2_resources.id
INNER JOIN v2_resource_types ON v2_resources.fk_resource_type = v2_resource_types.id
INNER JOIN v2_dcmi_types ON v2_resource_types.fk_DCMI_type = v2_dcmi_types.id
INNER JOIN v2_publishers ON v2_resources.fk_publisher = v2_publishers.id
INNER JOIN v2_mimetypes ON v2_resources.fk_mimetype = v2_mimetypes.id
WHERE oai_types.title = 'resource' AND oai_records.serial = $id AND v2_resources.status = 1 AND oai_records.status = 1
";
}
else if ( $row["title"] == "reference" )
{
$sql = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_bibrecords.*,
v2_bibrecords.abstract AS " . $SQL["dc_terms"]["description"] . ",
v2_bibrecord_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_bibrecord_types.oai_title
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_bibrecords ON oai_records.id = v2_bibrecords.id
INNER JOIN v2_bibrecord_types ON v2_bibrecords.fk_type = v2_bibrecord_types.id
INNER JOIN v2_bibrecord_publishers ON v2_bibrecords.fk_publisher = v2_bibrecord_publishers.id
WHERE oai_types.title = 'reference' AND oai_records.serial = $id AND oai_records.status = 1
";
}
else
{
$sql = "SELECT * FROM oai_records WHERE serial = -1";
}
}
}
else
{
return "SELECT * FROM oai_records WHERE serial = -1";
}
}
else
{
$sql["oai"] = "SELECT oai_records.*, oai_types.title
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
ORDER BY oai_records.serial";
$sql["models"] = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_models.*,
v2_models.title_english AS " . $SQL["dc_terms"]["title"] . ",
v2_models.title_german AS " . $SQL["dc_terms"]["alternative"] . ",
v2_models.title_prefix AS " . $SQL["dc_terms"]["identifier"] . ",
v2_models.keywords AS " . $SQL["dc_terms"]["subject"] . ",
v2_model_categories.title_english AS " . $SQL["dc_terms"]["category_title"] . ",
v2_people.name_family AS " . $SQL["dc_terms"]["creator_family"] . ",
v2_people.name_given AS " . $SQL["dc_terms"]["creator_given"] . ",
v2_people.name_middle AS " . $SQL["dc_terms"]["creator_middle"] . ",
v2_resource_types.oai_title AS " . $SQL["dc_terms"]["kmoddl_type"] . ",
v2_dcmi_types.title AS " . $SQL["dc_terms"]["dcmi_type"] . ",
v2_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_manufacturers.name AS " . $SQL["dc_terms"]["manufacturer"] . "
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_models ON oai_records.id = v2_models.id
INNER JOIN v2_people ON v2_models.fk_creator = v2_people.id
INNER JOIN v2_model_categories ON v2_models.fk_category = v2_model_categories.id
INNER JOIN v2_resource_types ON v2_models.fk_resource_type = v2_resource_types.id
INNER JOIN v2_dcmi_types ON v2_resource_types.fk_DCMI_type = v2_dcmi_types.id
INNER JOIN v2_publishers ON v2_models.fk_publisher = v2_publishers.id
INNER JOIN v2_manufacturers ON v2_models.fk_manufacturer = v2_manufacturers.id
WHERE oai_types.title = 'model' AND oai_records.status = 1
";
$sql["resources"] = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_resources.*,
v2_resources.keywords AS " . $SQL["dc_terms"]["subject"] . ",
v2_resource_types.oai_title AS " . $SQL["dc_terms"]["kmoddl_type"] . ",
v2_dcmi_types.title AS " . $SQL["dc_terms"]["dcmi_type"] . ",
v2_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_mimetypes.formal AS " . $SQL["dc_terms"]["format"] . "
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_resources ON oai_records.id = v2_resources.id
INNER JOIN v2_resource_types ON v2_resources.fk_resource_type = v2_resource_types.id
INNER JOIN v2_dcmi_types ON v2_resource_types.fk_DCMI_type = v2_dcmi_types.id
INNER JOIN v2_publishers ON v2_resources.fk_publisher = v2_publishers.id
INNER JOIN v2_mimetypes ON v2_resources.fk_mimetype = v2_mimetypes.id
WHERE oai_types.title = 'resource' AND oai_records.status = 1
";
/*
v2_people.name_family AS " . $SQL["dc_terms"]["creator_family"] . ",
v2_people.name_given AS " . $SQL["dc_terms"]["creator_given"] . ",
v2_people.name_middle AS " . $SQL["dc_terms"]["creator_middle"] . ",
LEFT JOIN v2_people ON v2_resources.fk_desc_author = v2_people.id
*/
$sql["references"] = "SELECT oai_records.serial, oai_records.last_update,
oai_types.title AS oai_type,
v2_bibrecords.*,
v2_bibrecord_publishers.title AS " . $SQL["dc_terms"]["publisher"] . ",
v2_bibrecord_types.oai_title
FROM oai_records
INNER JOIN oai_types ON oai_records.type = oai_types.id
INNER JOIN v2_bibrecords ON oai_records.id = v2_bibrecords.id
INNER JOIN v2_bibrecord_types ON v2_bibrecords.fk_type = v2_bibrecord_types.id
INNER JOIN v2_bibrecord_publishers ON v2_bibrecords.fk_publisher = v2_bibrecord_publishers.id
WHERE oai_types.title = 'reference' AND oai_records.status = 1
";
$sql["orderby"] = "ORDER BY oai_records.serial";
}
return $sql;
}
// this function will return identifier and datestamp for all records
function idQuery ($id = '')
{
global $SQL;
$sql = "SELECT *
FROM " . $SQL["table"] . "
WHERE oai_records.status = 1";
if ($id != '')
{
//$query .= $SQL['identifier']." ='$id'";
$sql .= " AND " . $SQL['identifier'] . " = '$id'";
}
return $sql;
}
// filter for until
function untilQuery($until)
{
global $SQL;
$myDate = date($until);
if ( $SQL['earliest'] > $myDate )
{
return " AND " . $SQL['id_column'] . " = -1 ";
}
else
{
return ' and ' . $SQL['datestamp'] . " <= '$until'";
}
}
function untilBib($until)
{
global $SQL;
$myDate = date($until);
if ( $SQL['earliest'] > $myDate )
{
return " AND " . $SQL['id_column'] . " = -1 ";
}
else
{
return " and date <= '$until'";
}
}
// filter for from
function fromQuery($from)
{
global $SQL;
return ' and ' . $SQL['datestamp'] . " >= '$from'";
}
function fromBib($from)
{
global $SQL;
return " and date >= '$from'";
}
// filter for sets
function setQuery($set)
{
global $SQL;
return ''; //$SQL; //' and '.$SQL['set']." LIKE '%$set%'";
}
// There is no need to change anything below.
// Current Date
$datetime = gmstrftime('%Y-%m-%dT%T');
$responseDate = $datetime.'Z';
// do not change
// encoding="iso-8859-1"
$XMLHEADER =
'
'."\n";
$xmlheader = $XMLHEADER .
' '.$responseDate."\n";
// the xml schema namespace, do not change this
$XMLSCHEMA = 'http://www.w3.org/2001/XMLSchema-instance';
/*
// do not change
$XMLHEADER = '
'."\n";
$OAIHEADER = '
'."\n";
$xmlheader = $OAIHEADER .
' '.$responseDate."\n";
// the xml schema namespace, do not change this
$XMLSCHEMA = 'http://ns.nsdl.org/nsdl_dc_v1.02/';
//'http://www.w3.org/2001/XMLSchema-instance';
$NSDLALL =
' ';
$NSDLALL_DATESTAMP = '
';
$NSDLLINKS = ' ';
*/
?>