cleaning and fixing

This commit is contained in:
Usuario Moodle 2013-05-07 17:01:22 -03:00
parent a89f4b7fa1
commit 91a657ae57
13 changed files with 919 additions and 951 deletions

View File

@ -17,7 +17,6 @@ require_once('xml_creater.php');
* The protected member functions are the backbone functions which can be used for creating any ANDS RIF-CS records.
*
*/
class ANDS_RIFCS {
/**
* \var $oai_pmh
@ -257,4 +256,3 @@ class ANDS_RIFCS {
$c->setAttribute('type',$subject_type);
}
} // end of class ANDS_RIFCS

View File

@ -115,7 +115,7 @@ class ANDS_TPA extends ANDS_RIFCS {
$this->create_description_node(str_replace("\r\n","\n",$record['pub_descrip']));
$this->create_description_node('The experiment was carried out between '.$record['start_date'].' and '.$record['end_date'],'note');
$query = sprintf("select idr,stype from list_prj_ids_v2(%d) where stype in ('dataset','person')",$id_project);
$query = sprintf("select idr,stype from list_prj_ids_v2 where stype in ('dataset','person')",$id_project);
// echo $query;
try {
$res = $db->query($query,PDO::FETCH_ASSOC);
@ -346,4 +346,3 @@ class ANDS_TPA extends ANDS_RIFCS {
}
}
} // end of class ANDS_TPA

View File

@ -16,8 +16,7 @@ $metadataPrefix = $args['metadataPrefix'];
// myhandler is a php file which will be included to generate metadata node.
// $inc_record = $METADATAFORMATS[$metadataPrefix]['myhandler'];
if (is_array($METADATAFORMATS[$metadataPrefix])
&& isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
if (is_array($METADATAFORMATS[$metadataPrefix]) && isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
$inc_record = $METADATAFORMATS[$metadataPrefix]['myhandler'];
} else {
$errors[] = oai_error('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix);
@ -42,7 +41,6 @@ if ($res===false) {
$errors[] = oai_error('idDoesNotExist', '', $identifier);
}
if (!empty($errors)) {
oai_exit();
}
@ -60,12 +58,8 @@ $identifier = $record[$SQL['identifier']];;
$datestamp = formatDatestamp($record[$SQL['datestamp']]);
if (isset($record[$SQL['deleted']]) && ($record[$SQL['deleted']] == 'true') &&
($deletedRecord == 'transient' || $deletedRecord == 'persistent')) {
$status_deleted = TRUE;
} else {
$status_deleted = FALSE;
}
$status_deleted = (isset($record[$SQL['deleted']]) && ($record[$SQL['deleted']] == 'true') &&
($deletedRecord == 'transient' || $deletedRecord == 'persistent'));
$outputObj = new ANDS_Response_XML($args);
$cur_record = $outputObj->create_record();
@ -77,4 +71,3 @@ if (!$status_deleted) {
} else {
$cur_header->setAttribute("status","deleted");
}
?>

View File

@ -18,6 +18,7 @@ if (SHOW_QUERY_ERROR) {
echo 'XMLSCHEMA: ',XMLSCHEMA,"\n";
echo "\n";
}
$outputObj = new ANDS_Response_XML($args);
foreach($identifyResponse as $key => $val) {
$outputObj->add2_verbNode($key, $val);
@ -132,4 +133,3 @@ if(strlen($output)>10) {
$des->appendXML($output);
$outputObj->verbNode->appendChild($des);
}
?>

View File

@ -136,6 +136,3 @@ University of Adelaide
</p>
</body>
</html>

View File

@ -59,9 +59,7 @@ if (isset($mf)) {
foreach($METADATAFORMATS as $key=>$val) {
addMetedataFormat($outputObj,$key, $val);
}
}
else { // a very unlikely event
} else { // a very unlikely event
$errors[] = oai_error('noMetadataFormats');
oai_exit();
}
?>

View File

@ -54,8 +54,7 @@ if (!empty($errors)) {
}
// Load the handler
if (is_array($METADATAFORMATS[$metadataPrefix])
&& isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
if (is_array($METADATAFORMATS[$metadataPrefix]) && isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
$inc_record = $METADATAFORMATS[$metadataPrefix]['myhandler'];
include($inc_record);
} else {
@ -72,8 +71,8 @@ if (empty($errors)) {
$res = $db->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$r = $res->execute();
if ($r===false) {
if (SHOW_QUERY_ERROR) {
if (($r===false) ) {
if ( (SHOW_QUERY_ERROR)) {
echo __FILE__.','.__LINE__."<br />";
echo "Query: $query<br />\n";
print_r($db->errorInfo());
@ -88,7 +87,9 @@ if (empty($errors)) {
}
$num_rows = rowCount($metadataPrefix, $extquery, $db);
if ($num_rows==0) {
if (SHOW_QUERY_ERROR) {
echo "Cannot find records: $query\n";
}
$errors[] = oai_error('noRecordsMatch');
}
}
@ -144,12 +145,8 @@ while ($countrec++ < $maxrec) {
$setspec = $record[$SQL['set']];
// debug_var_dump('record', $record);
if (isset($record[$SQL['deleted']]) && ($record[$SQL['deleted']] === true) &&
($deletedRecord == 'transient' || $deletedRecord == 'persistent')) {
$status_deleted = TRUE;
} else {
$status_deleted = FALSE;
}
$status_deleted = (isset($record[$SQL['deleted']]) && ($record[$SQL['deleted']] === true) &&
($deletedRecord == 'transient' || $deletedRecord == 'persistent'));
//debug_var_dump('status_deleted', $status_deleted);
if($args['verb']=='ListRecords') {
@ -179,4 +176,3 @@ if (isset($restoken)) {
// end ListRecords
if (SHOW_QUERY_ERROR) {echo "Debug listrecord.php reached to the end.\n\n";}
?>

View File

@ -26,5 +26,3 @@ if (is_array($SETS)) {
$errors[] = oai_error('noSetHierarchy');
oai_exit();
}
?>

View File

@ -152,7 +152,9 @@ if (isset($args['verb'])) {
$errors[] = oai_error('noVerb');
}
if (!empty($errors)) { oai_exit(); }
if (!empty($errors)) {
oai_exit();
}
if ($compress) {
ob_start('ob_gzhandler');
@ -169,5 +171,3 @@ if(isset($outputObj)) {
if ($compress) {
ob_end_flush();
}
?>

View File

@ -119,12 +119,12 @@ $deletedRecord = $identifyResponse["deletedRecord"]; // a shorthand for checking
//granularity is days
//$granularity = 'YYYY-MM-DD';
// granularity is seconds
$identifyResponse["granularity"] = 'YYYY-MM-DD';
$identifyResponse["granularity"] = 'YYYY-MM-DDThh:mm:ssZ';
// this is appended if your granularity is seconds.
// do not change
if (strcmp($identifyResponse["granularity"],'YYYY-MM-DDThh:mm:ssZ')==0) {
$identifyResponse["earliestDatestamp"] = $identifyResponse["earliestDatestamp"].'T00:00:00Z';
// $identifyResponse["earliestDatestamp"] = $identifyResponse["earliestDatestamp"].'T00:00:00Z';
}
/** Compression methods supported. Optional (multiple). Default: null.

View File

@ -39,9 +39,10 @@ function debug_print_r($var_name, $var) {
* \see SHOW_QUERY_ERROR in oaidp-config.php
*/
function debug_message($msg) {
if (!SHOW_QUERY_ERROR) return;
if (SHOW_QUERY_ERROR) {
echo $msg,"\n";
}
}
/** Check if provided correct arguments for a request.
*
@ -117,8 +118,7 @@ function checkArgs($args, $checkList) {
* Used only by function <B>oai_error</B> code idDoesNotExist.
* \param $url Type: string
*/
function is_valid_uri($url)
{
function is_valid_uri($url) {
return((bool)preg_match('/^[-a-z\.0-9]+$/i', $url));
}
@ -134,8 +134,7 @@ function is_valid_uri($url)
/** All datestamps used in this system are GMT even
* return value from database has no TZ information
*/
function formatDatestamp($datestamp)
{
function formatDatestamp($datestamp) {
return date("Y-m-d\TH:i:s\Z",strtotime($datestamp));
}
@ -168,8 +167,8 @@ function prepare_set_names() {
}
/** Finish a request when there is an error: send back errors. */
function oai_exit()
{
function oai_exit() {
// global $CONTENT_TYPE;
header(CONTENT_TYPE);
global $args,$errors,$compress;
@ -183,14 +182,12 @@ function oai_exit()
if ($compress) {
ob_end_flush();
}
exit();
}
// ResumToken section
/** Generate a string based on the current Unix timestamp in microseconds for creating resumToken file name. */
function get_token()
{
function get_token() {
list($usec, $sec) = explode(" ", microtime());
return ((int)($usec*1000) + (int)($sec*1000));
}
@ -235,8 +232,7 @@ function readResumToken($resumptionToken) {
* 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 ($metadPrefix = "rif", $id = '')
{
function selectallQuery($metadPrefix = "rif", $id = ''){
global $SQL;
$query = "SELECT * FROM ".$SQL['table'] . " WHERE ".$SQL['metadataPrefix']." LIKE '%$metadPrefix%'";
if ($id != '') {
@ -246,8 +242,7 @@ function selectallQuery ($metadPrefix = "rif", $id = '')
}
/** this function will return metadataFormat of a record */
function idFormatQuery($id)
{
function idFormatQuery($id) {
global $SQL;
return 'select '.$SQL['metadataPrefix'].' FROM '.$SQL['table']. " WHERE ".$SQL['identifier']." = '".$id."'";
}
@ -255,8 +250,7 @@ function idFormatQuery($id)
/** this function will return identifier and datestamp for all records
* not very useful
*/
function idQuery ($metadPrefix = "rif", $id = '')
{
function idQuery($metadPrefix = "rif", $id = '') {
global $SQL;
if ($SQL['set'] != '') {
@ -273,24 +267,21 @@ function idQuery ($metadPrefix = "rif", $id = '')
}
/** filter for until, appends to the end of SQL query */
function untilQuery($until)
{
function untilQuery($until) {
global $SQL;
return ' AND '.$SQL['datestamp']." <= '$until'";
}
/** filter for from , appends to the end of SQL query */
function fromQuery($from)
{
function fromQuery($from) {
global $SQL;
return ' AND '.$SQL['datestamp']." >= '$from'";
}
/** filter for sets, appends to the end of SQL query */
function setQuery($set)
{
function setQuery($set) {
global $SQL;
// strip off "class:" which is not saved in database
if(strstr($set,"class:")) $set = substr($set,6);
@ -322,11 +313,9 @@ function process_pdo_error($query, $e) {
* \param $query string
* \return $res PDOStatement
*/
function exec_pdo_query($db, $query)
{
function exec_pdo_query($db, $query) {
$res = $db->query($query);
if ($res===false) {
throw new Exception($query.":\nIt found nothing.\n");
} else return $res;
}
?>

View File

@ -60,29 +60,29 @@ function oai_error($code, $argument = '', $value = '')
{
switch ($code) {
case 'badArgument' :
$text = "The argument '$argument' (value='$value') included in the request is not valid.";
$text = "Attribute '{$argument}' is not allowed to appear in element 'request'";
break;
case 'badGranularity' :
$text = "The value '$value' of the argument '$argument' is not valid.";
$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.";
$text = "The resumptionToken '{$value}' does not exist or has already expired.";
break;
case 'badRequestMethod' :
$text = "The request method '$argument' is unknown.";
$text = "The request method '{$argument}' is unknown.";
$code = 'badVerb';
break;
case 'badVerb' :
$text = "The verb '$argument' provided in the request is illegal.";
$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.";
$text = "The metadata format '{$value}' given by {$argument} is not supported by this repository.";
break;
case 'exclusiveArgument' :
@ -91,7 +91,7 @@ function oai_error($code, $argument = '', $value = '')
break;
case 'idDoesNotExist' :
$text = "The value '$value' of the identifier does not exist in this repository.";
$text = "The value '{$value}' of the identifier does not exist in this repository.";
if (!is_valid_uri($value)) {
$code = 'badArgument';
$text .= ' Invalidated URI has been detected.';
@ -99,7 +99,7 @@ function oai_error($code, $argument = '', $value = '')
break;
case 'missingArgument' :
$text = "The required argument '$argument' is missing in the request.";
$text = "The required argument '{$argument}' is missing in the request.";
$code = 'badArgument';
break;
@ -136,7 +136,7 @@ function oai_error($code, $argument = '', $value = '')
break;
default:
$text = "Unknown error: code: '$code', argument: '$argument', value: '$value'";
$text = "Unknown error: code: '{$code}', argument: '{$argument}', value: '{$value}'";
$code = 'badArgument';
}
return $code."|".$text;