You are here

class smart_ip_views_bridge_handler_field_country in Smart IP 6.2

Same name and namespace in other branches
  1. 6 modules/smart_ip_views_bridge/views/smart_ip_views_bridge_handler_field_country.inc \smart_ip_views_bridge_handler_field_country
  2. 7.2 modules/smart_ip_views_bridge/views/smart_ip_views_bridge_handler_field_country.inc \smart_ip_views_bridge_handler_field_country

Field handler to display visitor's country.

Hierarchy

Expanded class hierarchy of smart_ip_views_bridge_handler_field_country

1 string reference to 'smart_ip_views_bridge_handler_field_country'
smart_ip_views_bridge_views_data in modules/smart_ip_views_bridge/views/smart_ip_views_bridge.views.inc
Implements hook_views_data().

File

modules/smart_ip_views_bridge/views/smart_ip_views_bridge_handler_field_country.inc, line 12
Contains the 'smart_ip_views_bridge_handler_field_country' field handler.

View source
class smart_ip_views_bridge_handler_field_country extends views_handler_field {
  function query() {
    $this->field_alias = 'smart_ip_views_bridge_country_' . $this->position;
    $this->query
      ->add_field('', 1, $this->field_alias);
  }
  function option_definition() {
    $options = parent::option_definition();
    $options['style'] = array(
      'default' => 'name',
    );
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['style'] = array(
      '#title' => t('Display style'),
      '#type' => 'select',
      '#options' => array(
        'name' => t('Country name'),
        'code' => t('ISO 3166 2-character country code'),
      ),
      '#default_value' => $this->options['style'],
    );
  }
  function render($values) {
    $smart_ip_session = smart_ip_session_get('smart_ip');
    if ($this->options['style'] == 'name') {
      return $smart_ip_session['location']['country'];
    }
    else {
      return $smart_ip_session['location']['country_code'];
    }
  }

}

Members