You are here

class views_handler_field_countries_continent in Countries 8

Same name and namespace in other branches
  1. 7.2 views/views_handler_field_countries_continent.inc \views_handler_field_countries_continent

Provides a continent filter.

Hierarchy

Expanded class hierarchy of views_handler_field_countries_continent

1 string reference to 'views_handler_field_countries_continent'
countries_views_data in views/countries.views.inc
Implements hook_views_data().

File

views/views_handler_field_countries_continent.inc, line 11
Views module filter handler class.

View source
class views_handler_field_countries_continent extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();
    $options['continent_code'] = array(
      'default' => FALSE,
    );
    return $options;
  }

  /**
   * Provide continent_code option.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['continent_code'] = array(
      '#title' => t('Output machine name'),
      '#description' => t('Display field as the continent machine name.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['continent_code']),
    );
  }

  /**
   * Render contient as human readable name or continent code
   */
  function render($values) {
    $data = parent::render($values);
    if ($this->options['continent_code'] != 1 && $data !== NULL && $data !== '') {
      $continents = countries_get_continents();
      return $continents[$data];
    }
    return $data;
  }

}

Members