You are here

function brightcove_playlist_edit_form_submit in Brightcove Video Connect 7.4

Same name and namespace in other branches
  1. 7.3 brightcove.playlist.inc \brightcove_playlist_edit_form_submit()
  2. 7.5 brightcove.playlist.inc \brightcove_playlist_edit_form_submit()

brightcove_playlist_edit_form submit handler.

_state

Parameters

$form:

1 string reference to 'brightcove_playlist_edit_form_submit'
brightcove_playlist_edit_form in ./brightcove.playlist.inc
Playlist edit form.

File

./brightcove.playlist.inc, line 257
This file contains function over the brightcove playlist feature.

Code

function brightcove_playlist_edit_form_submit($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']);
  }
  if (isset($form_state['playlist'])) {
    $metadata['id'] = $form_state['playlist']->id;
    brightcove_update_playlist($metadata);
  }
  else {
    brightcove_add_playlist($metadata);
  }

  // Redirect the user to the playlist listing page.
  $form_state['redirect'] = array(
    'admin/config/media/brightcove/playlist',
  );
}