function data_get_views_handler in Data 8
Same name and namespace in other branches
- 6 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.
File
- ./
data.views.inc, line 155 - 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_numeric';
case 'int':
case 'serial':
return 'views_handler_filter_numeric';
case 'datetime':
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';
}
}