function location_views_handler_arg_province in Location 5.3
Same name and namespace in other branches
- 5 contrib/location_views/location_views.module \location_views_handler_arg_province()
1 call to location_views_handler_arg_province()
- location_views_handler_arg_user_province in contrib/
location_views/ location_views.module - Province argument handler.
1 string reference to 'location_views_handler_arg_province'
- location_views_arguments in contrib/
location_views/ location_views.module
File
- contrib/
location_views/ location_views.module, line 754 - Views-enables the location module.
Code
function location_views_handler_arg_province($op, &$query, $argtype, $arg = '', $type = 'node') {
switch ($op) {
case 'summary':
$query
->ensure_table('location');
// Figure out what country to load.
// This works best when the country argument appears before.
$country = isset($query->_location_country_arg) ? $query->_location_country_arg : variable_get('location_default_country', 'us');
if ($country == t('unknown')) {
$country = '';
}
// Add country as a fake field.
$query
->add_field("'{$country}'", NULL, 'location_country_arg');
if ($type == 'node') {
$query
->add_where("location_instance_node.vid IS NOT NULL");
}
else {
if ($type == 'user') {
$query
->add_where("location_instance_user.uid IS NOT NULL");
}
}
$fieldinfo['field'] = "IF (location.province = '' OR location.province IS NULL, '" . t('unknown') . "', location.province)";
$fieldinfo['fieldname'] = 'province';
return $fieldinfo;
case 'link':
$name = location_province_name($query->location_country_arg, $query->province);
return l(empty($name) ? t('unknown') : $name, "{$arg}/{$query->province}");
case 'title':
global $_location_views_country;
$title = FALSE;
if (isset($_location_views_country)) {
$title = location_province_name($_location_views_country, $query);
}
if (!$title) {
$title = location_province_name(variable_get('location_default_country', 'us'), $query);
}
if (!$title) {
$title = check_plain($query);
}
return $title;
default:
return location_views_handler_any($op, $query, $argtype, $arg, $type, 'province');
}
}