You are here

public function link_views_handler_filter_protocol::value_form in Link 7

Same name and namespace in other branches
  1. 6.2 views/link_views_handler_filter_protocol.inc \link_views_handler_filter_protocol::value_form()
  2. 6 views/link_views_handler_filter_protocol.inc \link_views_handler_filter_protocol::value_form()

Provide a select list to choose the desired protocols.

@codingStandardsIgnoreStart

Overrides views_handler_filter_string::value_form

File

views/link_views_handler_filter_protocol.inc, line 64
Contains filter handlers for protocol filters with views.

Class

link_views_handler_filter_protocol
Filter handler for limiting a view to URLs of a certain protocol.

Code

public function value_form(&$form, &$form_state) {

  // @codingStandardsIgnoreEnd
  // We have to make some choices when creating this as an exposed
  // filter form. For example, if the operator is locked and thus
  // not rendered, we can't render dependencies; instead we only
  // render the form items we need.
  $which = 'all';
  if (!empty($form_state['exposed']) && empty($this->options['expose']['operator'])) {
    $which = in_array($this->operator, $this
      ->operator_values(1)) ? 'value' : 'none';
  }
  if ($which == 'all' || $which == 'value') {
    $form['value'] = array(
      '#type' => 'select',
      '#title' => t('Protocol'),
      '#default_value' => $this->value,
      '#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array(
        'http',
        'https',
        'ftp',
        'news',
        'nntp',
        'telnet',
        'mailto',
        'irc',
        'ssh',
        'sftp',
        'webcal',
      ))),
      '#multiple' => 1,
      '#size' => 4,
      '#description' => t('The protocols displayed here are those globally available. You may add more protocols by modifying the <em>filter_allowed_protocols</em> variable in your installation.'),
    );
  }
}