You are here

function views_json_query_plugin_query_json::options_form in Views JSON Query 7

Options form.

Overrides views_plugin_query::options_form

File

./views_json_query_plugin_query_json.inc, line 429
Query plugin for views_json_query.

Class

views_json_query_plugin_query_json
@file Query plugin for views_json_query.

Code

function options_form(&$form, &$form_state) {
  $form['json_file'] = array(
    '#type' => 'textfield',
    '#title' => t('Json File'),
    '#default_value' => $this->options['json_file'],
    '#description' => t("The URL or path to the Json file."),
    '#maxlength' => 1024,
  );
  $form['row_apath'] = array(
    '#type' => 'textfield',
    '#title' => t('Root path'),
    '#default_value' => $this->options['row_apath'],
    '#description' => t("Root path to records.<br />Root path is just a simple array item find method. Ex:<br /><pre>array('data' => \n\tarray('records' => \n\t\tarray(\n\t\t\tarray('name' => 'yarco', 'sex' => 'male'),\n\t\t\tarray('name' => 'someone', 'sex' => 'male')\n\t\t)\n\t)\n)</pre><br />You want 'records', so root path could be set to 'data/records'. <br />Notice: prefix '/' or postfix '/' will be trimed, so never mind you add it or not."),
    '#required' => TRUE,
  );
  $form['total_items_apath'] = array(
    '#type' => 'textfield',
    '#title' => t('Records count path'),
    '#default_value' => $this->options['total_items_apath'],
    '#description' => t("Path to records count."),
    '#required' => FALSE,
  );
  $form['enable_pagination_query_parameters'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable pagination query parameters '),
    '#default_value' => $this->options['enable_pagination_query_parameters'],
  );
  $form['pagination_offset_query_parameter'] = array(
    '#type' => 'textfield',
    '#title' => t('Offset parameter name '),
    '#default_value' => $this->options['pagination_offset_query_parameter'],
    '#description' => t('The name of the pagination offset parameter'),
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][enable_pagination_query_parameters]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['pagination_limit_query_parameter'] = array(
    '#type' => 'textfield',
    '#title' => t('Limit parameter name '),
    '#default_value' => $this->options['pagination_limit_query_parameter'],
    '#description' => t('The name of the pagination limit parameter'),
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][enable_pagination_query_parameters]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['show_errors'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Json errors'),
    '#default_value' => $this->options['show_errors'],
    '#description' => t('If there were any errors during Json parsing, display them. It is recommended to leave this on during development.'),
    '#required' => FALSE,
  );
  $form['ssl'] = array(
    '#type' => 'fieldset',
    '#title' => t('SSL Options'),
    '#description' => t('Options used for HTTP requests when the Json File is an HTTPS URL.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#parents' => array(
      'query',
      'options',
    ),
  );
  $form['ssl']['ssl_verify_peer'] = array(
    '#type' => 'checkbox',
    '#title' => t('Require verification of SSL certificate used. '),
    '#default_value' => $this->options['ssl_verify_peer'],
    '#required' => FALSE,
  );
  $form['ssl']['ssl_allow_self_signed'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow self-signed certificates.'),
    '#default_value' => $this->options['ssl_allow_self_signed'],
    '#required' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][ssl_verify_peer]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['ssl']['ssl_cafile'] = array(
    '#type' => 'textfield',
    '#title' => t('Certificate Authority file'),
    '#description' => t('Location of Certificate Authority file on local filesystem which should be used to authenticate the identity of the remote peer.'),
    '#default_value' => $this->options['ssl_cafile'],
    '#required' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][ssl_verify_peer]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['ssl']['ssl_capath'] = array(
    '#type' => 'textfield',
    '#title' => t('Certificate Authority path'),
    '#description' => t('If cafile is not specified or if the certificate is not found there, the directory pointed to by capath is searched for a suitable certificate. capath must be a correctly hashed certificate directory.'),
    '#default_value' => $this->options['ssl_capath'],
    '#required' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][ssl_verify_peer]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['ssl']['ssl_local_cert'] = array(
    '#type' => 'textfield',
    '#title' => t('Local certificate'),
    '#description' => t('Path to local certificate file on filesystem. It must be a PEM encoded file which contains your certificate and private key. It can optionally contain the certificate chain of issuers.'),
    '#default_value' => $this->options['ssl_local_cert'],
    '#required' => FALSE,
  );
  $form['ssl']['ssl_passphrase'] = array(
    '#type' => 'textfield',
    '#title' => t('Passphrase'),
    '#description' => t('Passphrase with which your local certificate file was encoded.'),
    '#default_value' => $this->options['ssl_passphrase'],
    '#required' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][ssl_local_cert]"]' => array(
          'filled' => TRUE,
        ),
      ),
    ),
  );
  $form['ssl']['ssl_CN_match'] = array(
    '#type' => 'textfield',
    '#title' => t('Common Name'),
    '#description' => t('Common Name we are expecting. PHP will perform limited wildcard matching. If the Common Name does not match this, the connection attempt will fail.'),
    '#default_value' => $this->options['ssl_CN_match'],
    '#required' => FALSE,
  );
  $form['ssl']['ssl_verify_depth'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum certificate chain depth'),
    '#description' => t('Abort if the certificate chain is too deep. Leave empty to disable verification.'),
    '#default_value' => $this->options['ssl_verify_depth'],
    '#required' => FALSE,
  );
  if (version_compare(PHP_VERSION, '5.0.0') >= 0) {
    $form['ssl']['ssl_ciphers'] = array(
      '#type' => 'textfield',
      '#title' => t('Ciphers'),
      '#description' => t('Sets the list of available ciphers. The format of the string is described in <a href="@url">ciphers(1)</a>.', array(
        '@url' => 'http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT',
      )),
      '#default_value' => $this->options['ssl_ciphers'],
      '#required' => TRUE,
    );
  }
  if (version_compare(PHP_VERSION, '5.3.2') >= 0) {
    $form['ssl']['ssl_SNI_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable SNI'),
      '#description' => t('Enabling SNI allows multiple certificates on the same IP address.'),
      '#default_value' => $this->options['ssl_SNI_enabled'],
      '#required' => FALSE,
    );
    $form['ssl']['ssl_SNI_server_name'] = array(
      '#type' => 'textfield',
      '#title' => t('SNI Server Name'),
      '#description' => t('If set, then this value will be used as server name for server name indication. If this value is not set, then the server name is guessed based on the hostname used when opening the stream.'),
      '#default_value' => $this->options['ssl_SNI_server_name'],
      '#required' => FALSE,
      '#states' => array(
        'visible' => array(
          ':input[name="query[options][ssl_SNI_enabled]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
  }
  if (version_compare(PHP_VERSION, '5.4.13') >= 0) {
    $form['ssl']['ssl_disable_compression'] = array(
      '#type' => 'checkbox',
      '#title' => t('Disable TLS compression. This can help mitigate the CRIME attack vector.'),
      '#default_value' => $this->options['ssl_disable_compression'],
      '#required' => FALSE,
    );
  }
  if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
    $form['ssl']['ssl_peer_fingerprint'] = array(
      '#type' => 'textfield',
      '#title' => t('Peer Fingerprint'),
      '#description' => t("Aborts when the remote certificate digest doesn't match the specified hash. Leave empty to disable verification. The length will determine which hashing algorithm is applied, either 'md5' (32) or 'sha1' (40)"),
      '#default_value' => $this->options['ssl_peer_fingerprint'],
      '#required' => FALSE,
    );
  }
}