function better_formats_text_process in Better Formats 6
Same name and namespace in other branches
- 6.2 better_formats.module \better_formats_text_process()
Processes a CCK text elements.
Resets the filter area with bettter_formats default. This function is used to affect CCK text module fields not core fields.
See also
1 string reference to 'better_formats_text_process'
- better_formats_elements in ./
better_formats.module - Implementation of hook_elements().
File
- ./
better_formats.module, line 326 - Enhances Drupal's core input format settings.
Code
function better_formats_text_process($element, $edit, $form_state, $form) {
$field = $form['#field_info'][$element['#field_name']];
if (!empty($field['text_processing'])) {
// Get core default for new or selected format for existing.
$filter_key = count($element['#columns']) == 2 ? $element['#columns'][1] : 'format';
$format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : $element['#default_value'][$filter_key];
$parents = array_merge($element['#parents'], array(
$filter_key,
));
$default = better_formats_get_default_format('node', $form['type']['#value']);
// Overwrite format default if new node.
if (!isset($form_state['values']['nid']) || empty($format)) {
$format = $default;
}
$format = filter_resolve_format($format);
// Set default format for cck textarea.
$element['#value'][$filter_key] = $format;
// Set filter selection form.
$element[$filter_key] = better_formats_filter_form($format, $default, 'node', $form['type']['#value'], 1, $parents);
}
return $element;
}