You are here

class location_handler_field_location_province in Location 6.3

Same name and namespace in other branches
  1. 7.5 handlers/location_handler_field_location_province.inc \location_handler_field_location_province
  2. 7.3 handlers/location_handler_field_location_province.inc \location_handler_field_location_province
  3. 7.4 handlers/location_handler_field_location_province.inc \location_handler_field_location_province

@file Province field handler.

Hierarchy

Expanded class hierarchy of location_handler_field_location_province

1 string reference to 'location_handler_field_location_province'
location_views_data in ./location.views.inc
Implementation of hook_views_data().

File

handlers/location_handler_field_location_province.inc, line 8
Province field handler.

View source
class location_handler_field_location_province extends views_handler_field {
  function construct() {
    parent::construct();
    $this->additional_fields = array(
      'country' => 'country',
    );
  }
  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('Province name'),
        'code' => t('Province code'),
      ),
      '#default_value' => $this->options['style'],
    );
  }
  function render($values) {
    if ($this->options['style'] == 'name') {
      return t(check_plain(location_province_name($values->{$this->aliases['country']}, $values->{$this->field_alias})));
    }
    else {

      //If we get a number for the province, there is not a "proper" code, we must us it's name.
      if (is_numeric($values->{$this->field_alias})) {
        return t(check_plain(location_province_name($values->{$this->aliases['country']}, $values->{$this->field_alias})));
      }
      else {
        return check_plain(strtoupper($values->{$this->field_alias}));
      }
    }
  }

}

Members