class tripal_views_handler_filter_file_upload

  1. 2.x tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc tripal_views_handler_filter_file_upload
  2. 3.x tripal_chado_views/views/handlers/tripal_views_handler_filter_file_upload.inc tripal_views_handler_filter_file_upload
  3. 1.x tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc tripal_views_handler_filter_file_upload

This Handler provides a file upload field by extending the views_handler_filter object.

Hierarchy

Expanded class hierarchy of tripal_views_handler_filter_file_upload

1 string reference to 'tripal_views_handler_filter_file_upload'
tripal_chado_views_views_handlers in tripal_chado_views/tripal_chado_views.views.inc
Implements hook_views_handlers().

File

tripal_chado_views/views/handlers/tripal_views_handler_filter_file_upload.inc, line 13
Contains tripal_views_handler_filter_file_upload filter handler

View source
class tripal_views_handler_filter_file_upload extends views_handler_filter {

  /**
   * {@inheritdoc}
   */
  function value_form(&$form, &$form_state) {
    parent::value_form($form, $form_state);

    $this->value_form = array(
      '#type' => 'file_upload_combo',
      '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
      '#default_value' => $this->value,
      '#multiple' => FALSE,
      '#description' => t('Provide search values for %label. Please place each search
        item on a separate line or separated by commas.', array('%label' => $this->options['expose']['label'])),
    );
    $form['value'] = &$this->value_form;
  }

  /**
   * {@inheritdoc}
   */
  function exposed_form(&$form, &$form_state) {

    // don't do anything if the form isn't exposed.
    if (empty($this->options['exposed'])) {
      return;
    }
    // rebuild the form elements
    $value = $this->options['expose']['identifier'];
    $this->value_form($form, $form_state);

    $form[$value] = $form['value'];
    unset($form[$value]['#title']);

    // since this is an exposed form we want to enable file uploads by
    // setting the 'enctype' attribute and the method to POST
    $form['#attributes']['enctype'] = 'multipart/form-data';
    $form['#method'] = 'POST';
    $this->exposed_translate($form[$value], 'value');

    if ($value != 'value') {
      unset($form['value']);
    }

  }

  /**
   * {@inheritdoc}
   */
  function query() {
    $this->ensure_my_table();
    $field = "$this->table.$this->real_field";

    // get the form element values
    $value = $this->value[0];
    $values = $value['items_array'];

    // trim all values supplied
    foreach ($values as $k => $val) {
      $values[$k] = trim($val);
    }

    // Determine the operator to use depending on # of items
    if (sizeof($values)) {
      $operator = 'IN';
    }
    else {
      $operator = '=';
    }

    // if we have any items then add the where
    if (!empty($values)) {
      $this->query->add_where($this->options['group'], $field, $values, $operator);
    }
  }
}

Members