You are here

views_handler_field_countries_continent.inc in Countries 8

Same filename and directory in other branches
  1. 7.2 views/views_handler_field_countries_continent.inc

Views module filter handler class.

File

views/views_handler_field_countries_continent.inc
View source
<?php

/**
 * @file
 * Views module filter handler class.
 */

/**
 * Provides a continent filter.
 */
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;
  }

}

Classes

Namesort descending Description
views_handler_field_countries_continent Provides a continent filter.