function location_views_tables in Location 5
Same name and namespace in other branches
- 5.3 contrib/location_views/location_views.module \location_views_tables()
For operation with the views.module.
File
- contrib/
location_views/ location_views.module, line 24 - Views-enables the location module.
Code
function location_views_tables() {
$tables['location'] = array(
'name' => 'location',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'vid',
),
'right' => array(
'field' => 'eid',
),
),
'fields' => array(
'name' => array(
'name' => t('Location: Name'),
'sortable' => true,
),
'street' => array(
'name' => t('Location: Street'),
'sortable' => true,
),
'additional' => array(
'name' => t('Location: Additional'),
'sortable' => true,
),
'city' => array(
'name' => t('Location: City'),
'sortable' => true,
),
'province' => array(
'name' => t('Location: Province'),
'handler' => 'location_views_province_handler',
'addlfields' => array(
'country',
),
'sortable' => true,
),
'postal_code' => array(
'name' => t('Location: Postal Code'),
'sortable' => true,
),
'country' => array(
'name' => t('Location: Country'),
'handler' => 'location_views_country_handler',
'sortable' => true,
),
'latitude' => array(
'name' => t('Location: Latitude'),
'sortable' => true,
),
'longitude' => array(
'name' => t('Location: Longitude'),
'sortable' => true,
),
),
'sorts' => array(
'name' => array(
'name' => t('Location: Name'),
),
'street' => array(
'name' => t('Location: Street'),
),
'additional' => array(
'name' => t('Location: Additional'),
),
'city' => array(
'name' => t('Location: City'),
),
'province' => array(
'name' => t('Location: Province'),
),
'country' => array(
'name' => t('Location: Country'),
),
'postal_code' => array(
'name' => t('Location: Postal Code'),
),
),
'filters' => array(
'name' => array(
'field' => 'name',
'name' => t('Location: Name'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'additional' => array(
'field' => 'additional',
'name' => t('Location: Additional'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'street' => array(
'field' => 'street',
'name' => t('Location: Street'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'city' => array(
'field' => 'city',
'name' => t('Location: City'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
),
);
$tables['location']['filters']['province_select'] = array(
'field' => 'province_select',
'name' => t('Location: Province Selector'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => location_views_provinces(),
'list-type' => 'select',
);
$tables['location']['filters']['province'] = array(
'field' => 'province',
'name' => t('Location: Province'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
);
$tables['location']['filters']['postal_code'] = array(
'field' => 'postal_code',
'name' => t('Location: Postal Code'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
);
$tables['location']['filters']['country'] = array(
'field' => 'country',
'name' => t('Location: Country'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => location_views_countries(),
'list-type' => 'select',
);
$tables['location']['filters']['type'] = array(
'field' => 'type',
'name' => t('Location: Type'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => drupal_map_assoc(array(
'node',
'user',
)),
'list-type' => 'select',
);
$tables['location']['filters']['latitude'] = array(
'field' => 'latitude',
'name' => t('Location: Latitude'),
'operator' => 'views_handler_operator_gtlt',
);
$tables['location']['filters']['longitude'] = array(
'field' => 'longitude',
'name' => t('Location: Longitude'),
'operator' => 'views_handler_operator_gtlt',
);
// add a complete address in a single box as a field option
$tables['location']['fields']['address'] = array(
'name' => t('Location: Address'),
'handler' => 'location_views_field_handler_address',
'notafield' => true,
'sortable' => false,
'addlfields' => array(
'name',
'street',
'additional',
'city',
'province',
'country',
'postal_code',
),
'help' => t('Complete formatted address in a single cell, using the location theme.'),
);
$tables['location']['filters']['proximity'] = array(
'field' => 'distance',
'name' => t('Location: Proximity'),
'operator' => location_views_proximity_operators(),
'handler' => 'location_views_filter_handler_proximity',
'value' => location_views_proximity_form(),
'help' => t('Select the postal code and the distance units to be used for the proximity filter.'),
'cacheable' => 'no',
);
$tables['location']['filters']['proximity_map'] = array(
'field' => 'distance',
'name' => t('Location: Proximity Map'),
'operator' => location_views_proximity_operators(),
'handler' => 'location_views_filter_handler_proximity',
'value' => location_views_map_input_form(),
'help' => t('Map the central point and the distance units to be used for the proximity filter.'),
'cacheable' => 'no',
);
// add field showing distance from selected zip code
$tables['location']['fields']['distance'] = array(
'name' => t('Location: Distance'),
'handler' => 'location_views_field_handler_distance',
'notafield' => true,
'sortable' => false,
'addlfields' => array(
'name',
'street',
'additional',
'city',
'province',
'country',
'postal_code',
'longitude',
'latitude',
),
'help' => t('Combine with proximity filter. Displays distance from each node to the central location selected with the proximity filter.'),
);
if (module_exists('usernode')) {
$tables['user_location'] = array(
'name' => 'location',
'join' => array(
'left' => array(
'table' => 'usernode',
'field' => 'uid',
),
'right' => array(
'field' => 'eid',
),
),
'fields' => array(
'name' => array(
'name' => t('User Location: Name'),
'sortable' => true,
),
'street' => array(
'name' => t('User Location: Street'),
'sortable' => true,
),
'additional' => array(
'name' => t('User Location: Additional'),
'sortable' => true,
),
'city' => array(
'name' => t('User Location: City'),
'sortable' => true,
),
'province' => array(
'name' => t('User Location: Province'),
'handler' => 'location_views_province_handler',
'addlfields' => array(
'country',
),
'sortable' => true,
),
'postal_code' => array(
'name' => t('User Location: Postal Code'),
'sortable' => true,
),
'country' => array(
'name' => t('User Location: Country'),
'handler' => 'location_views_country_handler',
'sortable' => true,
),
'latitude' => array(
'name' => t('User Location: Latitude'),
'sortable' => true,
),
'longitude' => array(
'name' => t('User Location: Longitude'),
'sortable' => true,
),
),
'sorts' => array(
'name' => array(
'name' => t('User Location: Name'),
),
'street' => array(
'name' => t('User Location: Street'),
),
'additional' => array(
'name' => t('User Location: Additional'),
),
'city' => array(
'name' => t('User Location: City'),
),
'province' => array(
'name' => t('User Location: Province'),
),
'country' => array(
'name' => t('User Location: Country'),
),
'postal_code' => array(
'name' => t('User Location: Postal Code'),
),
),
'filters' => array(
'name' => array(
'field' => 'name',
'name' => t('User Location: Name'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'additional' => array(
'field' => 'additional',
'name' => t('User Location: Additional'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'street' => array(
'field' => 'street',
'name' => t('User Location: Street'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
'city' => array(
'field' => 'city',
'name' => t('User Location: City'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),
),
);
$tables['user_location']['filters']['province'] = array(
'field' => 'province_select',
'name' => t('User Location: Province Selector'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => location_views_provinces(),
'list-type' => 'select',
);
$tables['user_location']['filters']['province'] = array(
'field' => 'province',
'name' => t('User Location: Province'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
);
$tables['user_location']['filters']['postal_code'] = array(
'field' => 'postal_code',
'name' => t('User Location: Postal Code'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
);
$tables['user_location']['filters']['country'] = array(
'field' => 'country',
'name' => t('User Location: Country'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => location_views_countries(),
'list-type' => 'select',
);
$tables['user_location']['filters']['type'] = array(
'field' => 'type',
'name' => t('User Location: Type'),
'operator' => 'location_handler_operator_eq',
'handler' => 'location_handler_filter_eq',
'list' => drupal_map_assoc(array(
'node',
'user',
)),
'list-type' => 'select',
);
$tables['user_location']['filters']['latitude'] = array(
'field' => 'latitude',
'name' => t('User Location: Latitude'),
'operator' => 'views_handler_operator_gtlt',
);
$tables['user_location']['filters']['longitude'] = array(
'field' => 'longitude',
'name' => t('User Location: Longitude'),
'operator' => 'views_handler_operator_gtlt',
);
// add a complete address in a single box as a field option
$tables['user_location']['fields']['address'] = array(
'name' => t('User Location: Address'),
'handler' => 'location_views_field_handler_user_address',
'notafield' => true,
'sortable' => false,
'addlfields' => array(
'name',
'street',
'additional',
'city',
'province',
'country',
'postal_code',
),
'help' => t('Complete formatted address in a single cell, using the location theme.'),
);
$tables['user_location']['filters']['proximity'] = array(
'field' => 'distance',
'name' => t('User Location: Proximity'),
'operator' => location_views_proximity_operators(),
'handler' => 'location_views_filter_handler_user_proximity',
'value' => location_views_proximity_form(),
'help' => t('Select the postal code and the distance units to be used for the proximity filter.'),
'cacheable' => 'no',
);
$tables['user_location']['filters']['proximity_map'] = array(
'field' => 'distance',
'name' => t('User Location: Proximity Map'),
'operator' => location_views_proximity_operators(),
'handler' => 'location_views_filter_handler_user_proximity',
'value' => location_views_map_input_form(),
'help' => t('Map the central point and the distance units to be used for the proximity filter.'),
'cacheable' => 'no',
);
// add field showing distance from selected zip code
$tables['user_location']['fields']['distance'] = array(
'name' => t('User Location: Distance'),
'handler' => 'location_views_field_handler_distance',
'notafield' => true,
'sortable' => false,
'addlfields' => array(
'name',
'street',
'additional',
'city',
'province',
'country',
'postal_code',
'longitude',
'latitude',
),
'help' => t('Combine with proximity filter. Displays distance from each node to the central location selected with the proximity filter.'),
);
}
return $tables;
}