You are here

function views_oai_pmh_plugin_display::parse_oai_request in Views OAI-PMH 7.2

Same name and namespace in other branches
  1. 6.2 plugins/views_oai_pmh_plugin_display.inc \views_oai_pmh_plugin_display::parse_oai_request()
  2. 6 plugins/views_oai_pmh_plugin_display.inc \views_oai_pmh_plugin_display::parse_oai_request()
  3. 7 plugins/views_oai_pmh_plugin_display.inc \views_oai_pmh_plugin_display::parse_oai_request()
1 call to views_oai_pmh_plugin_display::parse_oai_request()
views_oai_pmh_plugin_display::option_definition in plugins/views_oai_pmh_plugin_display.inc
Define the option for this view.

File

plugins/views_oai_pmh_plugin_display.inc, line 192
Contains the OAI-PMH display plugin.

Class

views_oai_pmh_plugin_display
We are based on a feed display for compatibility.

Code

function parse_oai_request() {
  $args = array();
  if (!empty($_GET)) {
    $args = $_GET;
  }
  if (!empty($_POST)) {
    $args = $_POST;
  }
  if (isset($args['q'])) {
    unset($args['q']);
  }

  // get rid of the Drupal q
  if (!count($args)) {
    $this
      ->oai_error('badRequestMethod', $_SERVER['REQUEST_METHOD']);
  }
  if (isset($args['verb']) && !count($this->oai_errors)) {
    switch ($args['verb']) {
      case 'GetRecord':
        $this
          ->oai_check_args($args, array(
          'identifier',
          'metadataPrefix',
        ));
        $this
          ->oai_check_metadata_prefix($args);
        if (count($this->oai_errors)) {
          return;
        }
        $args['nid'] = substr(strrchr($args['identifier'], ":"), 1);
        break;
      case 'ListIdentifiers':
      case 'ListRecords':
        $args += $this
          ->oai_check_args($args, array(
          'metadataPrefix',
        ), array(
          'from',
          'until',
          'set',
        ));
        $this
          ->oai_check_metadata_prefix($args);
        break;
      case 'Identify':
        $this
          ->oai_check_args($args);
        $this->oai_compression = FALSE;
        break;
      case 'ListMetadataFormats':
        $this
          ->oai_check_args($args, array(), array(
          'identifier',
        ));
        if (count($this->oai_errors)) {
          return;
        }
        if (isset($args['identifier'])) {
          $args['nid'] = substr(strrchr($args['identifier'], ":"), 1);
        }
        break;
      case 'ListSets':
        $this
          ->oai_error('noSetHierarchy');

        //  $this->oai_resumption_token();
        break;
      default:

        // we never use compression with errors
        $this->oai_compression = FALSE;
        $this
          ->oai_error('badVerb', $args['verb']);
        $args['verb'] = '';
    }
  }
  elseif (!count($this->oai_errors)) {
    $args['verb'] = '';
    $this
      ->oai_error('noVerb');
  }
  $args['response_date'] = gmstrftime('%Y-%m-%dT%H:%M:%SZ', time());
  $args['errors'] = $this->oai_errors;
  return $args;
}