You are here

function field_kaltura_remix_textfield_process in Kaltura 6

Same name and namespace in other branches
  1. 5 plugins/field_kaltura/field_kaltura.module \field_kaltura_remix_textfield_process()
  2. 6.2 plugins/field_kaltura/field_kaltura.module \field_kaltura_remix_textfield_process()

Process an individual element.

Build the form element. When creating a form using FAPI #process, note that $element['#value'] is already set.

The $fields array is in $form['#field_info'][$element['#field_name']].

1 string reference to 'field_kaltura_remix_textfield_process'
field_kaltura_elements in plugins/field_kaltura/field_kaltura.module
Implementation of FAPI hook_elements().

File

plugins/field_kaltura/field_kaltura.module, line 544
kaltura integration module - functions to provide kaltura as CCK field

Code

function field_kaltura_remix_textfield_process($element, $edit, $form_state, $form) {
  global $_kaltura_thumbnail_base_url;
  $field = $form['#field_info'][$element['#field_name']];
  $field_key = $element['#columns'][0];
  $delta = $element['#delta'];
  $custom_name = 'edit-' . str_replace('_', '-', $element['#field_name']) . '-' . $delta . '-' . $field_key;
  $element['data'] = array(
    '#tree' => 'true',
  );
  $cw_vars = kaltura_format_cw_vars(array(
    'kshow_id' => 0,
    'partner_data' => '',
    'type' => 'entry',
    'context' => 'field_mix',
    'field_id' => $custom_name,
    'add_filter' => 6,
  ));
  $action_buttons = '<input type="button" value="Add Kaltura Remix" onclick="kalturaInitModalBox(\'' . url('kaltura/contribution_wizard/' . $cw_vars) . '/\'+ get_title(), {width:680, height:380});" /><input type="button" value="Clear" onclick="remove_items_from_field(\'' . $custom_name . '\');" />';
  $action_buttons .= '<input type="button" value="Edit Mix" onclick="if(document.getElementById(\'' . $custom_name . '\').value) { kalturaInitModalBox(\'' . url('kaltura/simple_editor/') . '\' + document.getElementById(\'' . $custom_name . '\').value +\'/entry/empty_partner_data/no_refresh\', { width: 890, height: 546 }); }" />';
  $field_thumbs = kaltura_get_field_thumbs($element['#value'][$field_key], $custom_name, 'Remix', $element['#required']);
  $element['data'][$custom_name . '_thumbs'] = array(
    '#type' => 'item',
    '#value' => '<div id="' . $custom_name . '_thumbs_div">' . $field_thumbs . '</div>',
  );
  $element['data']['add_video'] = array(
    '#type' => 'item',
    '#value' => $action_buttons,
  );
  $element[$field_key] = array(
    '#type' => 'hidden',
    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
    '#autocomplete_path' => $element['#autocomplete_path'],
    '#size' => !empty($field['widget']['size']) ? $field['widget']['size'] : 60,
    '#attributes' => array(
      'class' => 'text',
      'readonly' => 'readonly',
    ),
    '#readonly' => 'readonly',
    // The following values were set by the content module and need
    // to be passed down to the nested element.
    '#title' => $element['#title'],
    '#description' => $element['#description'],
    '#required' => $element['#required'],
    '#field_name' => $element['#field_name'],
    '#type_name' => $element['#type_name'],
    '#delta' => $element['#delta'],
    '#columns' => $element['#columns'],
  );

  // Used so that hook_field('validate') knows where to flag an error.
  $element['_error_element'] = array(
    '#type' => 'value',
    '#value' => implode('][', array_merge($element['#parents'], array(
      $field_key,
    ))),
  );
  return $element;
}