function _brightcove_create_form_callback in Brightcove Video Connect 7.5
Same name and namespace in other branches
- 7.3 brightcove.module \_brightcove_create_form_callback()
- 7.4 brightcove.module \_brightcove_create_form_callback()
Create the new playlist.
_state
Parameters
$form:
Return value
bool|StdClass
1 call to _brightcove_create_form_callback()
- ajax_create_playlist_dialog_close_callback in brightcove_field/
brightcove_field.module
File
- ./
brightcove.module, line 1159 - Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.
Code
function _brightcove_create_form_callback(&$form, $form_state) {
$metadata = array();
$keys_to_send = array(
'name',
'shortDescription',
);
foreach ($keys_to_send as $key) {
$metadata[$key] = $form_state['values'][$key];
}
if ($form_state['values']['type'] == BRIGHTCOVE_PLAYLIST_TYPE_MANUAL) {
$metadata['playlistType'] = 'explicit';
$videos = drupal_explode_tags($form_state['values']['videos']);
foreach ($videos as $video) {
// Parse the video id.
preg_match('/\\[id:(?P<videoid>\\d+)\\]/', $video, $matches);
$metadata['videoIds'][] = $matches['videoid'];
}
}
else {
$metadata['tagInclusionRule'] = $form_state['values']['tagInclusionRule'];
$metadata['playlistType'] = $form_state['values']['playlistType'];
$metadata['filterTags'] = drupal_explode_tags($form_state['values']['filterTags']);
}
$id = brightcove_add_playlist($metadata);
// Cache video temporary, because Brightcove cache is not cleared promptly, so we
// might not get the video object for a while.
$playlist = (object) $metadata;
$playlist->id = $id;
brightcove_cache_set('brightcove:playlist:' . $id, $playlist);
// Invalidate BC cache
brightcove_invalidate_cache('brightcove:playlist:list', TRUE);
return $id;
}