function location_views_handler_arg_country in Location 5
Same name and namespace in other branches
- 5.3 contrib/location_views/location_views.module \location_views_handler_arg_country()
1 call to location_views_handler_arg_country()
- location_views_handler_arg_user_country in contrib/
location_views/ location_views.module - Country argument handler.
1 string reference to 'location_views_handler_arg_country'
- location_views_arguments in contrib/
location_views/ location_views.module
File
- contrib/
location_views/ location_views.module, line 794 - Views-enables the location module.
Code
function location_views_handler_arg_country($op, &$query, $argtype, $arg = '', $table = 'location') {
$all_countries = _location_get_iso3166_list();
$country_name = is_object($query) ? $all_countries[$query->country] : $all_countries[$query];
switch ($op) {
case 'summary':
$query
->ensure_table($table, true);
$fieldinfo['field'] = "IF({$table}.country='' OR {$table}.country IS NULL,'" . LOCATION_VIEWS_UNKNOWN . "',{$table}.country)";
$fieldinfo['fieldname'] = 'country';
return $fieldinfo;
break;
case 'sort':
$query
->add_orderby($table, 'country', 'ASC');
break;
case 'filter':
$query
->ensure_table($table);
$query
->add_field('country', $table);
$query
->add_where("{$table}.country = '%s'", $arg);
break;
case 'link':
return l($query->country == LOCATION_VIEWS_UNKNOWN ? LOCATION_VIEWS_UNKNOWN : $country_name, "{$arg}/{$query->country}");
case 'title':
return $query == LOCATION_VIEWS_UNKNOWN ? LOCATION_VIEWS_UNKNOWN : $country_name;
}
}