You are here

views_oai_pmh_plugin_display.inc in Views OAI-PMH 7.3

Contains the OAI-PMH display plugin.

File

plugins/views_oai_pmh_plugin_display.inc
View source
<?php

/**
 * @file
 * Contains the OAI-PMH display plugin.
 */

/**
 * The views_oai_pmh_plugin_display Class.
 */
class views_oai_pmh_plugin_display extends views_plugin_display_page {

  /**
   * {@inheritdoc}
   */
  public function get_style_type() {
    return 'views_oai_pmh';
  }

  /**
   * {@inheritdoc}
   */
  public function option_definition() {
    $options = parent::option_definition();

    // Overrides for standard stuff:
    $options['style_plugin']['default'] = 'views_oai_pmh_style';
    $options['defaults']['default']['style_plugin'] = FALSE;
    $options['defaults']['default']['style_options'] = FALSE;
    $options['row_plugin']['default'] = '';
    $options['defaults']['default']['row_plugin'] = FALSE;
    $options['defaults']['default']['row_options'] = FALSE;

    // Set default title.
    $options['title']['default'] = variable_get('site_name', 'OAI-PMH');
    $options['defaults']['default']['title'] = FALSE;
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function options_summary(&$categories, &$options) {
    parent::options_summary($categories, $options);

    // Replace the inherited 'Page settings' label.
    $categories['page']['title'] = t('OAI-PMH settings');

    // Replace the default title label.
    $categories['title']['title'] = t('Repository name');
    $options['title']['title'] = t('Repository name');

    // Remove features that do not seem to make sense here.
    unset($options['menu']);
    unset($options['exposed_form']);
    unset($categories['exposed']);
  }

  /**
   * {@inheritdoc}
   */
  public function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    switch ($form_state['section']) {
      case 'title':
        $form['title']['#description'] = t("The repository name is given in response to OAI-PMH 'Identify' requests.");
        break;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function uses_exposed() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function uses_exposed_form_in_block() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function displays_exposed() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function use_ajax() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function uses_breadcrumb() {
    return FALSE;
  }

  /**
   * Defaultable sections.
   *
   * Ensure that some settings are unique to this display. This is necessary
   * for settings that cannot be applied on the master display.
   */
  public function defaultable_sections($section = NULL) {
    $sections = parent::defaultable_sections();
    unset($sections['title']);
    unset($sections['style_plugin']);
    unset($sections['style_options']);
    if ($section) {
      if (!empty($sections[$section])) {
        return $sections[$section];
      }
    }
    else {
      return $sections;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function execute() {

    // Let the world know that this is the page view we're using.
    views_set_page_view($this->view);

    // And now render the view.
    $output = $this->view
      ->render();
    drupal_add_http_header('Content-Type', 'text/xml');
    print $output;
  }

  /**
   * Renders this display.
   *
   * Actually delegates rendering to the style plugin.
   */
  public function render() {
    return $this->view->style_plugin
      ->render($this->view->result);
  }

  /**
   * {@inheritdoc}
   */
  public function preview() {
    return '<pre>' . check_plain($this->view
      ->render()) . '</pre>';
  }

}

Classes

Namesort descending Description
views_oai_pmh_plugin_display The views_oai_pmh_plugin_display Class.