public function views_oai_pmh_request::__construct in Views OAI-PMH 7.3
Constructs the object based on $_REQUEST data.
File
- includes/
request.inc, line 106 - Represents an OAI-PMH request.
Class
- views_oai_pmh_request
- Class views_oai_pmh_request.
Code
public function __construct($base_url, $allowed_metadata_prefixes, $live_preview = FALSE) {
$this->base_url = $base_url;
if ($live_preview) {
$args['verb'] = 'ListRecords';
$args['metadataPrefix'] = 'oai_dc';
}
else {
$args = $_REQUEST;
}
if (isset($args['q'])) {
// Ignore the Drupal 'q' argument.
unset($args['q']);
}
$this->response_timestamp = time();
$this->response_date = gmstrftime('%Y-%m-%dT%H:%M:%SZ', $this->response_timestamp);
if (!isset($args['verb'])) {
$this->errors[] = new views_oai_pmh_error_missing_verb();
}
elseif (!in_array($args['verb'], array(
'GetRecord',
'ListIdentifiers',
'ListRecords',
'Identify',
'ListMetadataFormats',
'ListSets',
))) {
$this->errors[] = new views_oai_pmh_error_bad_verb();
}
else {
$this->verb = $args['verb'];
// Remove this one before further parsing.
unset($args['verb']);
switch ($this->verb) {
case 'Identify':
$this->callback = 'identify';
$this
->parse_arguments($args);
break;
case 'ListMetadataFormats':
$this->callback = 'list_metadata_formats';
$this
->parse_arguments($args, array(), array(
'identifier',
));
break;
case 'ListIdentifiers':
$this->callback = 'list_identifiers';
$this
->parse_arguments($args, array(
'metadataPrefix',
), array(
'resumptionToken',
'from',
'until',
'set',
));
$this
->parse_metadata_prefix($args, $allowed_metadata_prefixes);
break;
case 'GetRecord':
$this->callback = 'get_record';
$this
->parse_arguments($args, array(
'identifier',
'metadataPrefix',
));
$this
->parse_metadata_prefix($args, $allowed_metadata_prefixes);
break;
case 'ListRecords':
$this->callback = 'list_records';
$this
->parse_arguments($args, array(
'metadataPrefix',
), array(
'resumptionToken',
'from',
'until',
'set',
));
$this
->parse_metadata_prefix($args, $allowed_metadata_prefixes);
break;
case 'ListSets':
$this
->parse_arguments($args);
$this->errors[] = new views_oai_pmh_error_no_set_hierarchy();
break;
}
}
}