function location_views_handler_any in Location 5.3
6 calls to location_views_handler_any()
- location_views_handler_arg_city in contrib/
location_views/ location_views.module - location_views_handler_arg_country in contrib/
location_views/ location_views.module - location_views_handler_arg_postal_code in contrib/
location_views/ location_views.module - Postal code argument handler.
- location_views_handler_arg_province in contrib/
location_views/ location_views.module - location_views_handler_arg_user_city in contrib/
location_views/ location_views.module - City argument handler.
File
- contrib/
location_views/ location_views.module, line 651 - Views-enables the location module.
Code
function location_views_handler_any($op, &$query, $argtype, $arg = '', $type = 'node', $col) {
switch ($op) {
case 'summary':
$query
->ensure_table('location');
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");
}
}
// if a length option has been provided, display only the $len left letters of the name
$len = intval($arg);
if ($len <= 0) {
$fieldinfo['field'] = "IF (location.{$col} = '' OR location.{$col} IS NULL, '" . t('unknown') . "', location.{$col})";
}
else {
$fieldinfo['field'] = "IF (location.{$col} = '' OR location.{$col} IS NULL, '" . t('unknown') . "', LEFT(location.{$col}, {$len}))";
}
$fieldinfo['fieldname'] = $col;
return $fieldinfo;
case 'sort':
$query
->add_orderby('location', $col, 'ASC');
break;
case 'filter':
$query
->ensure_table('location');
$query
->add_field($col, 'location');
// adjust the search based on whether you are looking for the full value or the first $len letters
$len = intval($argtype['options']);
if ($len <= 0) {
$query
->add_where("location.{$col} = '%s'", strcasecmp($arg, t('unknown')) ? $arg : '');
}
else {
$query
->add_where("LEFT(location.{$col}, {$len}) = '%s'", strcasecmp($arg, t('unknown')) ? $arg : '');
}
break;
// case 'link':
// break;
case 'title':
return $query;
}
}