You are here

views_plugin_argument_default_bboxquery.inc in Views GeoJSON 7

Same filename and directory in other branches
  1. 6 views/views_plugin_argument_default_bboxquery.inc

Contains the BBOX query string argument default plugin.

File

views/views_plugin_argument_default_bboxquery.inc
View source
<?php

/**
 * @file
 * Contains the BBOX query string argument default plugin.
 */

/**
 * The BBOX query string argument default handler.
 *
 * @TODO: Write an options_validate() method.
 */
class views_plugin_argument_default_bboxquery extends views_plugin_argument_default {

  /**
   * Return the default argument.
   */
  public function get_argument() {
    $query = drupal_get_query_parameters();
    if (isset($query[$this->options['arg_id']])) {

      // Just set the argument here. We'll validate and sanitize the input in
      // views_geojson_bbox_argument::query().
      return $query[$this->options['arg_id']];
    }
    if ($this->argument->options['empty_result']) {

      // Return no values if arg not present and empty result option is set.
      $this->view->built = TRUE;
      $this->view->executed = TRUE;
      return FALSE;
    }

    // Return all values if arg not present.
    return TRUE;
  }

  /**
   *
   */
  public function option_definition() {
    $options = parent::option_definition();
    $options['argument'] = array(
      'default' => '',
    );
    $options['arg_id'] = array(
      'default' => 'bbox',
    );
    return $options;
  }

  /**
   *
   */
  public function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['info'] = array(
      '#markup' => '<p class="description">Attempt to pull bounding box info
      directly from the query string, bypassing Drupal\'s normal argument
      handling. If the argument does not exist, all values will be shown.</p>',
    );
    $form['arg_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Query argument ID'),
      '#size' => 60,
      '#maxlength' => 64,
      '#default_value' => $this->options['arg_id'] ? $this->options['arg_id'] : t('bbox'),
      '#description' => t('The ID of the query argument.<br />For OpenLayers use <em>bbox</em>, (as in "<em>?bbox=left,bottom,right,top</em>".)'),
    );
  }

}

Classes

Namesort descending Description
views_plugin_argument_default_bboxquery The BBOX query string argument default handler.