function scald_video_form_scald_atom_add_form_options_submit in Scald: Media Management made easy 7
Atom's form save and edit submit callback.
1 string reference to 'scald_video_form_scald_atom_add_form_options_submit'
- scald_video_form_scald_atom_add_form_options_alter in modules/
providers/ scald_video/ scald_video.module - Implements hook_form_FORM_ID_alter().
File
- modules/
providers/ scald_video/ scald_video.module, line 262 - Scald Video is a Scald Atom Provider for video files.
Code
function scald_video_form_scald_atom_add_form_options_submit($form, &$form_state) {
// We check for multiple atoms on the form:
if (isset($form_state['scald']['atom'])) {
$atoms = array(
$form_state['scald']['atom'],
);
}
else {
$atoms = $form_state['scald']['atoms'];
}
foreach ($atoms as $key => $atom) {
if ($atom->provider !== 'scald_video') {
break;
}
$atom->data['video_width'] = $form_state['values']["atom{$key}"]['width'];
$atom->data['video_height'] = $form_state['values']["atom{$key}"]['height'];
// Updating uploaded alternative sources:
if (isset($atom->data['alternative_video_sources']) && count($atom->data['alternative_video_sources'])) {
foreach ($atom->data['alternative_video_sources'] as $source_key => $source) {
// Removing unchecked sources:
if (!$form_state['values']["atom{$key}"]['uploaded_video_sources'][$source_key]) {
unset($atom->data['alternative_video_sources'][$source_key]);
}
}
}
if (isset($form["atom{$key}"]['alternative_video_sources'])) {
$atom_form = $form["atom{$key}"]['alternative_video_sources'];
$atom_form_state = $form_state['values']["atom{$key}"]['alternative_video_sources'];
// Check for new alternative sources from plupload:
if (is_array($atom_form_state)) {
foreach ($atom_form_state as $source_key => $video_source) {
$file = scald_video_get_video_file($atom_form_state[$source_key], $atom_form['#upload_location']);
$atom->data['alternative_video_sources'][] = $file;
}
}
else {
$file = scald_video_get_video_file($atom_form_state, $atom_form['#upload_location']);
if ($file !== FALSE) {
$atom->data['alternative_video_sources'][] = $file;
}
}
}
scald_atom_save($atom);
}
}