Skip to content

Commit

Permalink
Fixed : OAI records response error
Browse files Browse the repository at this point in the history
  • Loading branch information
dicarve committed Jun 25, 2015
1 parent c4126af commit d85b87f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
7 changes: 5 additions & 2 deletions lib/detail.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,11 @@ public function DublinCoreOutput()
// imprint/publication data
$_xml_output .= '<dc:publisher><![CDATA['.$this->record_detail['publisher_name'].']]></dc:publisher>'."\n";

// date
$_xml_output .= '<dc:date><![CDATA['.$this->record_detail['publish_year'].']]></dc:date>'."\n";
if ($this->record_detail['publish_year']) {
$_xml_output .= '<dc:date><![CDATA['.$this->record_detail['publish_year'].']]></dc:date>'."\n";
} else {
$_xml_output .= '<dc:date></dc:date>'."\n";
}

// edition
$_xml_output .= '<dc:hasVersion><![CDATA['.$this->record_detail['edition'].']]></dc:hasVersion>'."\n";
Expand Down
47 changes: 26 additions & 21 deletions lib/oai-pmh.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/**
* Class for OAI-PMH Web Services
*
* Copyright (C) 2012 Arie Nugraha ([email protected])
* Copyright (C) 2012 Arie Nugraha ([email protected])
*
* Patch by: Ismail Fahmi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -153,8 +155,10 @@ public function ListRecords($metadataPrefix = 'oai_dc') {
$where = '';

if (isset($_GET['resumptionToken'])) {
echo 'resumption';
parse_str($_GET['resumptionToken'], $resumptionToken);
// commented by Ismail
//echo 'resumption';
// we need to urldecode the parameter
parse_str(urldecode($_GET['resumptionToken']), $resumptionToken);
if (isset($resumptionToken['offset'])) {
$offset = (integer)$resumptionToken['offset'];
}
Expand Down Expand Up @@ -294,27 +298,28 @@ protected function outputRecordXML($recordID, $metadataPrefix = 'oai_dc') {
if ($metadataPrefix == 'oai_dc') {
$detail = new detail($this->db, $recordID, 'dc');
$rec_detail = $detail->DublinCoreOutput();
}

// mulai output XML
ob_start();
echo '<record>'
."<header><identifier>".$sysconf['OAI']['identifierPrefix'].$recordID."</identifier></header>";
echo "<metadata>";
if ($metadataPrefix == 'oai_dc') {
echo '<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
}


// mulai output XML
ob_start();
echo '<record>'
."<header><identifier>".$sysconf['OAI']['identifierPrefix'].$recordID."</identifier></header>";
echo "<metadata>";
if ($metadataPrefix == 'oai_dc') {
echo '<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
}

echo $rec_detail;
echo $rec_detail;

if ($metadataPrefix == 'oai_dc') {
echo '</oai_dc:dc>';
}
if ($metadataPrefix == 'oai_dc') {
echo '</oai_dc:dc>';
}

echo "</metadata>\n";
echo "</record>\n";
$recordXML = ob_get_clean();
echo "</metadata>\n";
echo "</record>\n";
$recordXML = ob_get_clean();

return $recordXML;
return $recordXML;
} // ismail: put the closing bracket here to prevent undefined $rec_detail
}
}
17 changes: 14 additions & 3 deletions oai.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/**
* OAI-PMH
*
* Copyright (C) 2012 Arie Nugraha ([email protected])
* Copyright (C) 2012 Arie Nugraha ([email protected])
*
* Patch by: Ismail Fahmi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,7 +27,12 @@

// required file
require 'sysconfig.inc.php';
$date_respons = date('Y-m-d').'T'.date('H:i:s').'Z';
if (class_exists('DateTime')) {
$date = new DateTime();
$date_respons = $date->format('Y-m-d').'T'.$date->format('H:i:s').'Z';
} else {
$date_respons = date('Y-m-d').'T'.date('H:i:s').'Z';
}

if (!$sysconf['OAI']['enable']) {
header('Content-type: text/xml');
Expand Down Expand Up @@ -80,7 +87,11 @@
break;
case 'ListRecords';
$metadataPrefix = isset($_GET['metadataPrefix'])?$dbs->escape_string(trim($_GET['metadataPrefix'])):'oai_dc';
echo $oai_respon_handlers->ListRecords($_GET['metadataPrefix']);

// ismail: metadataPrefix is not mandatory with resumptionToken
//echo $oai_respon_handlers->ListRecords($_GET['metadataPrefix']);
echo $oai_respon_handlers->ListRecords($metadataPrefix);

break;
case 'GetRecord';
$identifier = isset($_GET['identifier'])?$dbs->escape_string(trim($_GET['identifier'])):'0';
Expand Down

0 comments on commit d85b87f

Please sign in to comment.