You are here

function geshifield_textarea_process in GeSHi Filter for syntax highlighting 7

Same name and namespace in other branches
  1. 6 geshifield/geshifield.module \geshifield_textarea_process()

Process callback for geshifield_textarea widget.

1 string reference to 'geshifield_textarea_process'
geshifield_element_info in geshifield/geshifield.module
Implementation of hook_elements_info().

File

geshifield/geshifield.module, line 100
Defines a CCK field for source code with GeSHi syntax highlighting.

Code

function geshifield_textarea_process($element, $form_state, $complete_form) {
  module_load_include('inc', 'geshifilter');
  $defaults = $element['#value'];

  #$field = content_fields($element['#field_name'], $element['#type_name']);
  $field = field_widget_instance($element, $form_state);
  $enabled_languages = _geshifilter_get_enabled_languages();

  // @todo: also add "no highlighting" options.
  $element['sourcecode'] = array(
    '#type' => 'textarea',
    '#title' => t('Source code'),
    '#default_value' => isset($defaults['sourcecode']) ? $defaults['sourcecode'] : '',
    '#required' => $element['#required'],
    '#rows' => isset($field['widget']['rows']) ? $field['widget']['rows'] : 5,
    // TODO: do we need this row field?
    '#description' => filter_xss($field['description']),
  );
  $element['language'] = array(
    '#type' => 'select',
    '#title' => t('Syntax highlighting mode'),
    '#default_value' => isset($defaults['language']) ? $defaults['language'] : '',
    '#options' => $enabled_languages,
    '#description' => t('Select the syntax highlighting mode to use for the source code.'),
  );
  return $element;
}