function uploadfield_widget_process in Video 6.3
Same name and namespace in other branches
- 6.5 types/uploadfield/uploadfield_widget.inc \uploadfield_widget_process()
- 6.4 types/uploadfield/uploadfield_widget.inc \uploadfield_widget_process()
Element #process callback function.
1 string reference to 'uploadfield_widget_process'
- uploadfield_elements in types/
uploadfield/ uploadfield.module - Implementation of hook_elements().
File
- types/
uploadfield/ uploadfield_widget.inc, line 208 - uploadfield widget hooks and callbacks.
Code
function uploadfield_widget_process($element, $edit, &$form_state, $form) {
// TODO : get play duration/ image thumbnails
$file = $element['#value'];
$field = content_fields($element['#field_name'], $element['#type_name']);
$element['#theme'] = 'uploadfield_widget_item';
if (isset($element['preview']) && $file['fid'] != 0) {
//TODO : implement preview video play
$tml_thumb = !empty($file['data']['video_thumb']) ? array(
'filepath' => $file['data']['video_thumb'],
) : $field['widget']['default_video_thumb'];
$element['preview']['#suffix'] = '<div class="video_thumbnail">' . theme('uploadfield_image', $tml_thumb, '', '', array(
'width' => '150',
), FALSE) . '</div>';
}
// Check if using the default width and replace tokens.
$default_width = user_access('override player width');
$element['data']['width'] = array(
'#type' => $default_width ? 'textfield' : 'value',
'#title' => t('Width for Player'),
'#default_value' => empty($file['data']['width']) ? $field['widget']['default_width'] : $file['data']['width'],
'#description' => t('Set player width(in pix) here, make sure your video have good resolution to fit on larger values.'),
'#size' => 15,
'#maxlength' => 5,
'#attributes' => array(
'class' => 'video-width-text',
),
);
if (!$default_width) {
$element['data']['width']['#value'] = empty($file['data']['width']) ? $field['widget']['default_width'] : $file['data']['width'];
}
// only in preview mode and then create thumbnails
if ($field['widget']['autoconversion']) {
video_module_invoke('convert', $element);
//bypass auto conversion
if (user_access('bypass conversion video')) {
$element['data']['bypass_autoconversion'] = array(
'#type' => 'checkbox',
'#title' => t('Bypass auto conversion'),
'#default_value' => !empty($file['data']['bypass_autoconversion']) ? $file['data']['bypass_autoconversion'] : FALSE,
'#description' => t('This will bypass your auto conversion of videos.'),
'#attributes' => array(
'class' => 'video-bypass-auto-conversion',
),
);
/* Future development
$element['data']['convert_video_on_save'] = array(
'#type' => 'checkbox',
'#title' => t('Convert video on save'),
'#default_value' => !empty($file['data']['convert_video_on_save']) ? $file['data']['convert_video_on_save'] : FALSE,
'#description' => t('This will convert your video to flv format when you save, instead of scheduling it for cron.'),
'#attributes' => array('class' => 'video-convert-video-on-save'),
);
*/
}
}
//Create video thubs and save in a directory then we can get thumbnails from it using folder read
// only in preview mode and then create thumbnails
if ($field['widget']['autothumbnail']) {
video_module_invoke('thumbs', $element);
}
// default image default_image
if (user_access('use default thumbnail') && !empty($field['widget']['default_video_thumb'])) {
$element['data']['use_default_video_thumb'] = array(
'#type' => 'checkbox',
'#title' => t('Override Video Thumbnail with Default'),
'#default_value' => !empty($file['data']['use_default_video_thumb']) ? $file['data']['use_default_video_thumb'] : FALSE,
'#description' => t('If you want to use default image instead of using actual thumbnail of video then check.'),
'#weight' => 9,
'#attributes' => array(
'class' => 'video-default-thumbnail',
),
);
}
//Lets use the clicked_button #submit[0] value here instead and see how that works out for now...
//@todo This switch needs rework, especially the delete. We may not need this anymore as we can hand
//off the actual checking to other functionality.
if ($form_state['submitted'] == 1) {
switch ($form_state['clicked_button']['#submit'][0]) {
case 'node_form_submit':
if (!empty($form_state['values']['nid'])) {
video_module_invoke('update', $element);
}
else {
video_module_invoke('insert', $element);
}
break;
case 'node_form_build_preview':
break;
case 'node_form_delete_submit':
//@todo When a user presses the delete button, they are then prompted with a confirmation page.
//If a user clicks cancel on that page... well the dlete hook is still executed. Need to put this somewhere else.
video_module_invoke('delete', $element);
break;
}
}
return $element;
}