function _views_send_get_fields_and_tokens in Views Send 7
Same name and namespace in other branches
- 8 views_send.module \_views_send_get_fields_and_tokens()
- 6 views_send.module \_views_send_get_fields_and_tokens()
Generates and returns fields and tokens.
1 call to _views_send_get_fields_and_tokens()
- views_send_config_form in ./
views_send.module - Multistep form callback for the "configure" step.
File
- ./
views_send.module, line 1255 - The Views Send module.
Code
function _views_send_get_fields_and_tokens($view, $type) {
static $return;
if (isset($return[$type])) {
return $return[$type];
}
if (!in_array($type, array(
'fields',
'tokens',
'fields_name_text',
)) || !$view) {
return FALSE;
}
$fields = array();
$tokens = array();
$fields_name_text = array();
foreach ($view->field as $field_name => $field) {
// Ignore Views Form fields.
if (property_exists($field, 'views_form_callback') || method_exists($field, 'views_form')) {
continue;
}
if ($field instanceof views_handler_field_custom) {
$field_key = $field_name;
// Using a nice field name (for tokens) for custom text fields.
$field_name = str_replace('nothing', 'custom_text', $field_name);
}
elseif (!empty($field->field_info)) {
$field_key = $field->field_info['field_name'];
}
elseif (property_exists($field, 'field_alias')) {
$field_key = $field->field_alias;
if ($field_key == 'unknown') {
$field_key = $field_name;
}
}
else {
$field_key = $field_name;
}
// Add field position to ensure unique keys.
$field_key .= '_pos_' . $field->position;
$field_text = $field
->label() . ' (' . $field_name . ')';
$fields[$field_key] = $field_text;
$tokens[$field_key] = $field_name;
$fields_name_text[$field_name] = $field_text;
}
$return = array();
$return['fields'] = $fields;
$return['tokens'] = $tokens;
$return['fields_name_text'] = $fields_name_text;
return $return[$type];
}