function ListIdOrRecords_OAI($verb, $request_uri, $ws_client_url, $xslPath, $metadataPrefix, $set = "", $from = "", $until = "", $control = "")
{
    global $debug;
    if (!isset($metadataPrefix) || empty($metadataPrefix)) {
        $result = "<error code=\"badArgument\">Missing or empty metadataPrefix</error>\n";
    } else {
        if (!isValidPrefix($metadataPrefix)) {
            $result = "<error code=\"cannotDisseminateFormat\"/>\n";
        } else {
            if ($from) {
                $from = substr($from, 0, 4) . substr($from, 5, 2) . substr($from, 8, 2);
            }
            if ($until) {
                $until = substr($until, 0, 4) . substr($until, 5, 2) . substr($until, 8, 2);
            }
            $parameters = array("set" => $set, "from" => $from, "until" => $until, "control" => $control, "lang" => "en", "nrm" => "iso", "count" => 40);
            if ($debug) {
                $parameters["debug"] = true;
            }
            //$xsl = $xslPath . "$verb.xsl";
            $xsl = "{$verb}.xsl";
            $result = generatePayload($ws_client_url, "listRecords", $verb, $parameters, $xsl);
        }
    }
    $oai_packet = generateOAI_packet($request_uri, $verb, $result);
    //	    $oai_packet = str_replace ( "localhost", "200.6.42.159", $oai_packet);
    return $oai_packet;
}
Exemple #2
0
function ListIdOrRecords_OAI($verb, $request_uri, $ws_client_url, $xslPath, $metadataPrefix, $set = "", $from = "", $until = "", $control = "")
{
    global $debug;
    $eds = "19090401";
    $latest_datestamp = "20991230";
    if (empty($metadataPrefix)) {
        $metadataPrefix = "oai_dc";
    }
    if ($from != '') {
        $from = substr($from, 0, 4) . substr($from, 5, 2) . substr($from, 8, 2);
    }
    if ($until != '') {
        $until = substr($until, 0, 4) . substr($until, 5, 2) . substr($until, 8, 2);
    } elseif ($from != '') {
        $until = $latest_datestamp;
    }
    if ($until < $from and $until < $eds) {
        $result = '<error code="badArgument">The request specified a date one year before the earliestDatestamp given in the Identify response</error>';
    } else {
        if (!isset($metadataPrefix) || empty($metadataPrefix)) {
            $result = "<error code=\"badArgument\">Missing or empty metadataPrefix</error>\n";
        } else {
            if (!isValidPrefix($metadataPrefix)) {
                $result = "<error code=\"cannotDisseminateFormat\"/>\n";
            } else {
                $parameters = array("set" => $set, "from" => $from, "until" => $until, "control" => $control, "lang" => "en", "nrm" => "iso", "count" => 40, "metadataprefix" => $metadataPrefix);
                if ($debug) {
                    $parameters["debug"] = true;
                }
                //$xsl = $xslPath . "$verb.xsl";
                if ($verb == 'ListRecords') {
                    if ($metadataPrefix == 'oai_dc_agris') {
                        $xsl = 'ListRecords_agris.xsl';
                        $result = generatePayload($ws_client_url, "listRecordsAgris", "ListRecordsAgris", $parameters, $xsl);
                    } else {
                        $xsl = "{$verb}.xsl";
                        $result = generatePayload($ws_client_url, "listRecords", $verb, $parameters, $xsl);
                    }
                } else {
                    $xsl = "{$verb}.xsl";
                    $result = generatePayload($ws_client_url, "listRecords", $verb, $parameters, $xsl);
                }
            }
        }
    }
    $oai_packet = generateOAI_packet($request_uri, $verb, $result);
    //	    $oai_packet = str_replace ( "localhost", "200.6.42.159", $oai_packet);
    return $oai_packet;
}
Exemple #3
0
function getRecord($identifier, $methodology, $fullpath)
{
    //create a data model, based in witch database was selected
    $dataModel = new $methodology();
    //Data model call method gerRecords to pick data from database
    $allData = $dataModel->getRecords($identifier, $fullpath);
    /*
     * Use code above to see one iten, with all fields:
     * print_r($allData[0]);
     * Use code above to see one iten, with field 8:
     * print_r($allData[0][8]);
     */
    //print_r(substr($allData[0]["8"],"35","3"));
    switch ($methodology) {
        //Pass the data to a function tha put it on XML format
        case "dblil":
            $arrDatabase = arrayToDblil($allData);
            break;
        case "cepal":
            $arrDatabase = arrayToCepal($allData);
            break;
        case "marc":
            print $fullpath;
            $arrDatabase = arrayToMarc($allData);
            break;
        default:
            $arrDatabase = arrayToDblil($allData);
    }
    //try to cath an error
    if ($arrDatabase == "") {
        $errorMsg = "No matching identifier";
        $errorCode = "idDoesNotExist";
        //print an error
        print verbError($_REQUEST["verb"], $errorMsg, $errorCode);
    } else {
        //first part of xml
        $oai_packet = generateOAI_packet($_REQUEST["verb"], "");
        //second part of xml
        $returnXml .= db2Xml($arrDatabase, "0", $_REQUEST["verb"]);
        //join booth parts
        $envelop = $oai_packet . $returnXml;
        //add date information to xml
        $responseDate = gmdate("Y-m-d\\TH:i:s\\Z");
        $envelop .= "<resumptionToken>" . $responseDate . "</resumptionToken>\n";
        $envelop .= "</GetRecord>\n";
        $envelop .= "</OAI-PMH>\n";
        //print xml
        print $envelop;
    }
}