function data_get_views_handler in Data 6
Same name and namespace in other branches
- 8 data.views.inc \data_get_views_handler()
- 7 data.views.inc \data_get_views_handler()
Get the handler (class name) for a specified data table field.
Parameters
$type: The view handler type ('field', 'filter', 'sort', 'argument').
$table: A data table object.
$field_name: String: name of the field.
$default: Boolean for whether to return the default handler for the given db column type.
Return value
String: A views handler class name.
2 calls to data_get_views_handler()
- data_ui_views_form in data_ui/
data_ui.admin.inc - Views handler configuration form.
- data_views_data in ./
data.views.inc - Implementation of hook_views_data().
File
- ./
data.views.inc, line 169 - Views hooks and utility functions.
Code
function data_get_views_handler($type, $table, $field_name, $default = FALSE) {
// Return the handler's custom setting if available
if (!$default) {
$meta = $table
->get('meta');
if (isset($meta['fields'][$field_name]["views_{$type}_handler"])) {
return $meta['fields'][$field_name]["views_{$type}_handler"];
}
}
$schema = $table
->get('table_schema');
switch ($type) {
case 'field':
switch ($schema['fields'][$field_name]['type']) {
case 'int':
case 'float':
case 'serial':
case 'numeric':
return 'views_handler_field_numeric';
case 'datetime':
return 'views_handler_field_date';
}
return 'views_handler_field';
case 'filter':
switch ($schema['fields'][$field_name]['type']) {
case 'float':
case 'numeric':
return 'views_handler_filter_float';
case 'int':
case 'serial':
return 'views_handler_filter_numeric';
case 'datetime':
// @TODO: make this conditional on whether the time is stored as a timestamp/datetime
if (module_exists('date_api')) {
return 'date_api_filter_handler';
}
return 'views_handler_filter_date';
}
return 'views_handler_filter_string';
case 'argument':
switch ($schema['fields'][$field_name]['type']) {
case 'int':
case 'float':
case 'serial':
case 'numeric':
return 'views_handler_argument_numeric';
case 'datetime':
return 'views_handler_argument_date';
case 'varchar':
return 'views_handler_argument_string';
}
return 'views_handler_argument';
case 'sort':
switch ($schema['fields'][$field_name]['type']) {
case 'datetime':
return 'views_handler_sort_date';
}
return 'views_handler_sort';
}
}