function location_views_data in Location 7.3
Same name and namespace in other branches
- 6.3 location.views.inc \location_views_data()
- 7.5 location.views.inc \location_views_data()
- 7.4 location.views.inc \location_views_data()
Implementation of hook_views_data().
File
- ./
location.views.inc, line 17 - Views 3 support for Location.
Code
function location_views_data() {
// Location table -- basic table information.
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data['location']['table']['group'] = t('Location', array(), array(
'context' => 'geolocation',
));
// Advertise this table as a possible base table.
$data['location']['table']['base'] = array(
'field' => 'lid',
'title' => t('Location', array(), array(
'context' => 'geolocation',
)),
'help' => t('Locations are addresses and map coordinates.'),
'weight' => -10,
);
$data['location']['table']['join'] = array(
// Location links to node through location_instance via lid.
'node' => array(
'left_table' => 'location_instance',
'left_field' => 'lid',
'field' => 'lid',
),
// Location links to node_revision through location_instance via lid.
'node_revision' => array(
'left_table' => 'location_instance',
'left_field' => 'lid',
'field' => 'lid',
),
// Location links to taxonomy_term_data through location_instance via lid.
'taxonomy_term_data' => array(
'left_table' => 'location_instance',
'left_field' => 'lid',
'field' => 'lid',
),
// Location links to users through location_instance via lid.
'users' => array(
'left_table' => 'location_instance',
'left_field' => 'lid',
'field' => 'lid',
),
);
// Location table -- fields.
$data['location']['lid'] = array(
'title' => t('Lid'),
// The help that appears on the UI.
'help' => t('The location ID of the location.'),
// Information for displaying the lid.
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
// Information for accepting a lid as an argument
/*
'argument' => array(
'handler' => 'views_handler_argument_node_nid',
'name field' => 'title', // the field to display in the summary.
'numeric' => TRUE,
'validate type' => 'nid',
),
*/
// Information for accepting a lid as a filter.
'filter' => array(
'handler' => 'views_handler_filter_numeric',
'allow empty' => TRUE,
),
// Information for sorting on a lid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['name'] = array(
'title' => t('Name'),
'help' => t('The name of the selected location.'),
'field' => array(
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// @@@ 1.x Conversion -- 'additional' => 'street', style 'additional'
$data['location']['street'] = array(
'title' => t('Street'),
'help' => t('The street address of the selected location.'),
'field' => array(
'handler' => 'location_handler_field_location_street',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['additional'] = array(
'title' => t('Additional'),
'help' => t('Additional street address of the selected location.'),
'field' => array(
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['city'] = array(
'title' => t('City'),
'help' => t('The city of the selected location.'),
'field' => array(
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'views_handler_argument_string',
'empty field name' => t('Unknown'),
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// @@@ 1.x Conversion -- 'province' => 'province', style 'name'; 'province_code' => 'province', style 'code'
$data['location']['province'] = array(
'title' => t('Province'),
'help' => t('The province of the selected location.'),
'field' => array(
'handler' => 'location_handler_field_location_province',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'location_handler_argument_location_province',
),
'filter' => array(
'handler' => 'location_handler_filter_location_province',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['postal_code'] = array(
'title' => t('Postal Code'),
'help' => t('The postal code of the selected location.'),
'field' => array(
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// @@@ 1.x Conversion -- 'country' => 'country', style 'name'; 'country_code' => 'country', style 'code'.
$data['location']['country'] = array(
'title' => t('Country'),
'help' => t('The country of the selected location.'),
'field' => array(
'handler' => 'location_handler_field_location_country',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'location_handler_argument_location_country',
),
'filter' => array(
'handler' => 'location_handler_filter_location_country',
),
'sort' => array(
'handler' => 'location_handler_sort_location_country',
),
);
$data['location']['latitude'] = array(
'title' => t('Latitude'),
'help' => t('The latitude of the selected location.'),
'field' => array(
'handler' => 'location_views_handler_field_latitude',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['longitude'] = array(
'title' => t('Longitude'),
'help' => t('The longitude of the selected location.'),
'field' => array(
'handler' => 'location_views_handler_field_longitude',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['location']['coordinates'] = array(
'title' => t('Coordinates'),
'help' => t("The coordinates of the selected location in 'lat, long' format."),
'field' => array(
// The handler adds the longitude.
'field' => 'latitude',
'handler' => 'location_views_handler_field_coordinates',
'click sortable' => FALSE,
),
);
$data['location']['distance'] = array(
'title' => t('Distance / Proximity'),
'help' => t("The distance from the selected location and either the current user or a specific location."),
'field' => array(
'handler' => 'location_handler_field_location_distance',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'location_handler_sort_location_distance',
),
'argument' => array(
'handler' => 'location_handler_argument_location_proximity',
),
'filter' => array(
'handler' => 'location_views_handler_filter_proximity',
),
);
$data['location']['address'] = array(
'title' => t('Address'),
'help' => t('The entire address block for the location.'),
'field' => array(
'field' => 'lid',
'handler' => 'location_handler_field_location_address',
'element type' => 'div',
),
);
$data['location_instance']['table']['group'] = t('Location', array(), array(
'context' => 'geolocation',
));
$data['location_instance']['table']['join'] = array(
'location' => array(
'left_field' => 'lid',
'field' => 'lid',
),
'users' => array(
'left_field' => 'uid',
'field' => 'uid',
),
'node' => array(
'left_field' => 'vid',
'field' => 'vid',
),
'node_revision' => array(
'left_field' => 'vid',
'field' => 'vid',
),
'taxonomy_term_data' => array(
'left_field' => 'tid',
'field' => 'vid',
),
);
// Tell the base tables about us.
$data['node']['table']['join']['location'] = array(
'left_table' => 'location_instance',
'left_field' => 'vid',
'field' => 'vid',
);
$data['node_revision']['table']['join']['location'] = array(
'left_table' => 'location_instance',
'left_field' => 'vid',
'field' => 'vid',
);
$data['taxonomy_term_data']['table']['join']['location'] = array(
'left_table' => 'location_instance',
'left_field' => 'vid',
'field' => 'tid',
);
$data['users']['table']['join']['location'] = array(
'left_table' => 'location_instance',
'left_field' => 'uid',
'field' => 'uid',
);
return $data;
}