You are here

class votingapi_views_handler_field_value in Voting API 6.2

Same name and namespace in other branches
  1. 7.3 views/votingapi_views_handler_field_value.inc \votingapi_views_handler_field_value
  2. 7.2 views/votingapi_views_handler_field_value.inc \votingapi_views_handler_field_value

@file Provide a views handlers for votingapi data fields.

Hierarchy

Expanded class hierarchy of votingapi_views_handler_field_value

1 string reference to 'votingapi_views_handler_field_value'
votingapi_views_data in views/votingapi.views.inc
Implementation of hook_views_data().

File

views/votingapi_views_handler_field_value.inc, line 8
Provide a views handlers for votingapi data fields.

View source
class votingapi_views_handler_field_value extends views_handler_field_numeric {
  function construct() {
    parent::construct();
    $this->definition['float'] = TRUE;
  }
  function option_definition() {
    $options = parent::option_definition();
    $options['appearance'] = array(
      'default' => '',
    );
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $appearances = module_invoke_all('votingapi_views_formatters', $this);
    $options = array(
      '' => t('Default appearance'),
    );
    $options += $appearances;
    if (count($options) > 1) {
      $form['appearance'] = array(
        '#type' => 'select',
        '#title' => t('Appearance'),
        '#options' => $options,
        '#default_value' => $this->options['appearance'],
        '#weight' => -5,
      );
    }
  }
  function element_type() {
    return 'div';
  }
  function render($values) {
    $value = $values->{$this->field_alias};
    $function = $this->options['appearance'];
    if (!empty($function) && function_exists($function)) {
      return $function($value, $this, $values);
    }
    else {
      return parent::render($values);
    }
  }

  /**
   * Called to determine what to tell the clicksorter.
   */
  function click_sort($order) {
    $this->query
      ->add_orderby(NULL, "COALESCE({$this->table_alias}.{$this->field}, 0)", $order, $this->table_alias . '_' . $this->field . '_coalesced');
  }

}

Members