function brightcove_cck_browser_process in Brightcove Video Connect 6
Same name and namespace in other branches
- 6.2 brightcove_cck/brightcove_cck.module \brightcove_cck_browser_process()
Brightcove CCK field form that returns the actual field to the user. Parts of this and subsequent JS taken from Nodereference Explorer. Thanks!
1 string reference to 'brightcove_cck_browser_process'
- brightcove_cck_elements in brightcove_cck/
brightcove_cck.module - Implementation of hook_elements().
File
- brightcove_cck/
brightcove_cck.module, line 374 - Brightcove CCK module provides a Content Construction Kit module to developers, allowing them to browse videos in their Brightcove Studio and upload them.
Code
function brightcove_cck_browser_process($element, $edit, $form_state, $form) {
global $brightcove_cck_settings;
$field_key = $element['#columns'][0];
$field_info = content_fields($element['#field_name'], $element['#type_name']);
modalframe_parent_js();
//dialog internal area
$element[$field_key] = array(
'#type' => 'textfield',
'#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '',
'#autocomplete_path' => 'brightcove_cck/autocomplete/' . $element['#field_name'] . '/' . $element['#type_name'] . '/' . $form['nid']['#value'],
// The following values were set by the content module and need
// to be passed down to the nested element.
'#title' => $element['#title'],
'#required' => $element['#required'],
'#description' => $element['#description'],
'#field_name' => $element['#field_name'],
'#type_name' => $element['#type_name'],
'#delta' => $element['#delta'],
'#columns' => $element['#columns'],
'#attributes' => array(
'rel' => $element['#field_name'],
'class' => 'brightcove-video-field',
),
);
// Button to browse videos.
$element['actions']['browse'] = array(
'#type' => 'brightcove_cck_browse_button',
'#id' => $element['#id'] . '-browse',
'#attributes' => array(
'class' => 'brightcove-cck-browse-button',
'rel' => $element['#id'] . '-video-id',
),
'#value' => t('Browse'),
);
if ($field_info['allow_upload']) {
$element['actions']['upload'] = array(
'#type' => 'brightcove_cck_browse_button',
'#id' => $element['#id'] . '-upload',
'#attributes' => array(
'class' => 'brightcove-cck-upload-button',
'rel' => $element['#id'] . '-video-id',
),
'#value' => t('Upload'),
);
}
$element['actions']['remove'] = array(
'#type' => 'brightcove_cck_browse_button',
'#id' => $element['#id'] . '-remove',
'#attributes' => array(
'class' => 'brightcove-cck-remove-button',
'rel' => $element['#id'] . '-video-id',
),
'#value' => t('Detach'),
);
if (!isset($element['#default_value'][$field_key])) {
$element['actions']['remove']['#attributes']['disabled'] = 'disabled';
}
if (empty($brightcove_cck_settings[$element['#field_name']])) {
$brightcove_cck_settings[$element['#field_name']] = array(
'brightcove_cck' => array(
$element['#field_name'] => array(
'node_type' => $element['#type_name'],
'field_name' => $element['#field_name'],
'nid' => $nid = $form['nid']['#value'],
),
),
);
drupal_add_js($brightcove_cck_settings[$element['#field_name']], 'setting');
}
if (empty($element[$field_key]['#element_validate'])) {
$element[$field_key]['#element_validate'] = array();
}
array_unshift($element[$field_key]['#element_validate'], 'brightcove_cck_browser_validate');
// Used so that hook_field('validate') knows where to flag an error.
// @see userreference.module
$element['_error_element'] = array(
'#type' => 'value',
'#value' => implode('][', array_merge($element['#parents'], array(
$field_key,
$field_key,
))),
);
return $element;
}