Esempio n. 1
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;
}
Esempio n. 2
0
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;
}