addressfield.views.inc in Address Field 7
File
views/addressfield.views.inc
View source
<?php
function addressfield_field_views_data($field) {
$data = field_views_field_default_views_data($field);
$key = key($field['storage']['details']);
foreach ($field['storage']['details'][$key] as $type => $tables) {
foreach ($tables as $table_name => $columns) {
if (!isset($columns['country'])) {
continue;
}
$column_real_name = $columns['country'];
if (!isset($data[$table_name][$column_real_name]['filter'])) {
continue;
}
$data[$table_name][$column_real_name]['filter']['handler'] = 'addressfield_views_handler_filter_country';
}
}
$implemented = array(
'country' => 'addressfield_views_handler_field_country',
'administrative_area' => 'addressfield_views_handler_field_administrative_area',
'sub_administrative_area' => 'views_handler_field',
'dependent_locality' => 'views_handler_field',
'locality' => 'views_handler_field',
'postal_code' => 'views_handler_field',
'thoroughfare' => 'views_handler_field',
'premise' => 'views_handler_field',
'sub_premise' => 'views_handler_field',
'organisation_name' => 'views_handler_field',
'name_line' => 'views_handler_field',
'first_name' => 'views_handler_field',
'last_name' => 'views_handler_field',
'data' => 'views_handler_field_serialized',
);
$properties = addressfield_data_property_info();
foreach ($data as &$table) {
if (isset($table[$field['field_name']]['field'])) {
$field_def = $table[$field['field_name']]['field'];
unset($field_def['additional fields']);
$valid_columns = array();
foreach ($implemented as $implement => $handler) {
$column_name = $field['field_name'] . '_' . $implement;
$valid_columns[$column_name] = $handler;
}
foreach ($table as $column_name => &$column) {
if (empty($column['field']) && isset($valid_columns[$column_name])) {
$column['field'] = $field_def;
$column['field']['real field'] = $column_name;
$column['field']['handler'] = $valid_columns[$column_name];
$field_labels = field_views_field_label($field['field_name']);
$field_label = array_shift($field_labels);
$property = str_replace($field_def['field_name'] . '_', '', $column_name);
if (!empty($properties[$property])) {
$property_label = $properties[$property]['label'];
$title = t('@field-label - @property-label', array(
'@field-label' => $field_label,
'@property-label' => $property_label,
));
$column['title'] = $title;
$column['title short'] = $title;
}
}
}
}
}
return $data;
}