function sheetnode_views_data_alter in Sheetnode 6
Same name and namespace in other branches
- 7.2 sheetnode.views.inc \sheetnode_views_data_alter()
- 7 sheetnode.views.inc \sheetnode_views_data_alter()
Implementation of hook_views_data_alter().
File
- ./
sheetnode.views.inc, line 134
Code
function sheetnode_views_data_alter(&$data) {
$cck_info = _content_type_info();
foreach ($data as $table_name => $table_info) {
foreach ($table_info as $field_name => $field_info) {
// Add a SocialCalc date converter for each date field.
if (!empty($field_info['field']['handler']) && $field_info['field']['handler'] == 'views_handler_field_date') {
$date = $field_info;
$date['real field'] = $field_name;
$date['title'] = $field_info['title'] . ' (SocialCalc)';
$date['field']['handler'] = 'sheetnode_handler_field_date';
unset($date['filter'], $date['argument'], $date['relationship'], $date['sort']);
$data[$table_name][$field_name . '_socialcalc'] = $date;
}
// Add sheetnode handlers for each sheet field.
if (!empty($field_info['field']['content_field_name']) && $cck_info['fields'][$field_info['field']['content_field_name']]['type'] == 'sheetfield') {
$field = $cck_info['fields'][$field_info['field']['content_field_name']];
$label_truncated = truncate_utf8(t($field['widget']['label']), 10, TRUE);
$title = t('@label (!name)', array(
'@label' => t($field['widget']['label']),
'!name' => $field['field_name'],
));
$title_short = check_plain($label_truncated);
$types = array();
foreach ($cck_info['content types'] as $type) {
if (isset($type['fields'][$field['field_name']])) {
$types[] = $type['name'];
}
}
$cell = $field_info;
$cell['real field'] = $field_name;
$cell['title'] = $title . ' - ' . t('cell');
$cell['title short'] = $title_short . ' - ' . t('cell');
$cell['help'] = t('Cell reference - Appears in: @types', array(
'@types' => implode(', ', $types),
));
$cell['field']['handler'] = 'sheetnode_handler_field_cell';
unset($cell['filter'], $cell['argument'], $cell['relationship'], $cell['sort'], $cell['field']['title'], $cell['field']['title short']);
$data[$table_name][$field_name . '_cell'] = $cell;
$range = $cell;
$range['title'] = $title . ' - ' . t('range');
$range['title short'] = $title_short . ' - ' . t('range');
$range['help'] = t('Range reference - Appears in: @types', array(
'@types' => implode(', ', $types),
));
$range['field']['handler'] = 'sheetnode_handler_field_range';
$data[$table_name][$field_name . '_range'] = $range;
$named_range = $cell;
$named_range['title'] = $title . ' - ' . t('named range');
$named_range['title short'] = $title_short . ' - ' . t('named range');
$named_range['help'] = t('Named range - Appears in: @types', array(
'@types' => implode(', ', $types),
));
$named_range['field']['handler'] = 'sheetnode_handler_field_named_range';
$data[$table_name][$field_name . '_named_range'] = $named_range;
}
}
}
}