| 1 |
<?php
|
| 2 |
// $Id: country_code_handler_field_node_country.inc,v 1.1 2008/10/21 00:18:23 nedjo Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Field handler for country code module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Field handler to translate a node language into a readable form of its country.
|
| 11 |
*/
|
| 12 |
class country_code_handler_field_node_country extends views_handler_field_node {
|
| 13 |
function construct() {
|
| 14 |
parent::construct();
|
| 15 |
$this->additional_fields['language'] = 'language';
|
| 16 |
}
|
| 17 |
|
| 18 |
function query() {
|
| 19 |
$this->ensure_my_table();
|
| 20 |
$this->add_additional_fields();
|
| 21 |
}
|
| 22 |
|
| 23 |
function render($values) {
|
| 24 |
$language = $values->{$this->aliases['language']};
|
| 25 |
if ($country_code = strtolower(substr($language, 3))) {
|
| 26 |
if ($value = country_code_country_name($country_code)) {
|
| 27 |
return $this->render_link(check_plain($value), $values);
|
| 28 |
}
|
| 29 |
}
|
| 30 |
return '';
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|