function location_views_handler_arg_province in Location 5
Same name and namespace in other branches
- 5.3 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 760 - Views-enables the location module.
Code
function location_views_handler_arg_province($op, &$query, $argtype, $arg = '', $table = 'location') {
$provinces = location_views_provinces($country = '');
switch ($op) {
case 'summary':
$query
->ensure_table($table, true);
$fieldinfo['field'] = "IF({$table}.province='' OR {$table}.province IS NULL,'" . LOCATION_VIEWS_UNKNOWN . "',{$table}.province)";
$fieldinfo['fieldname'] = 'province';
// Make sure the country gets added so we can do a lookup on the province name.
$query
->add_field('country', $table);
return $fieldinfo;
break;
case 'sort':
$query
->add_orderby($table, 'province', 'ASC');
break;
case 'filter':
$query
->ensure_table($table);
$query
->add_field('province', $table);
$query
->add_where("{$table}.province = '%s'", strcasecmp($arg, LOCATION_VIEWS_UNKNOWN) ? $arg : '');
break;
case 'link':
return l($query->province == LOCATION_VIEWS_UNKNOWN ? LOCATION_VIEWS_UNKNOWN : $provinces[$query->country . '-' . $query->province], "{$arg}/{$query->province}");
case 'title':
return empty($query) ? LOCATION_VIEWS_UNKNOWN : $provinces[$country . '-' . $query];
}
}