location_handler_field_location_country.inc 870 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * @file
  4. * Country field handler.
  5. */
  6. class location_handler_field_location_country extends views_handler_field {
  7. function option_definition() {
  8. $options = parent::option_definition();
  9. $options['style'] = array('default' => 'name');
  10. return $options;
  11. }
  12. function options_form(&$form, &$form_state) {
  13. parent::options_form($form, $form_state);
  14. $form['style'] = array(
  15. '#title' => t('Display style'),
  16. '#type' => 'select',
  17. '#options' => array('name' => t('Country name'), 'code' => t('Country code')),
  18. '#default_value' => $this->options['style'],
  19. );
  20. }
  21. function render($values) {
  22. if ($this->options['style'] == 'name') {
  23. return check_plain(location_country_name($values->{$this->field_alias}));
  24. }
  25. else {
  26. return check_plain(strtoupper($values->{$this->field_alias}));
  27. }
  28. }
  29. }