You are here

function brightcove_field_video_browser_value in Brightcove Video Connect 7.6

Same name and namespace in other branches
  1. 7.7 brightcove.module \brightcove_field_video_browser_value()
  2. 7.3 brightcove_field/brightcove_field.module \brightcove_field_video_browser_value()
  3. 7.4 brightcove_field/brightcove_field.module \brightcove_field_video_browser_value()
  4. 7.5 brightcove_field/brightcove_field.module \brightcove_field_video_browser_value()

Callback for Brightcove field browser widget. Will return a field value in "video-name [id:videoId]" format.

1 string reference to 'brightcove_field_video_browser_value'
_brightcove_field_video_widget_form in ./brightcove_field.video.inc
Helper function to return the video widget form.

File

./brightcove.module, line 888
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_field_video_browser_value($element, $value, $form_state) {
  $input = drupal_array_get_nested_value($form_state['input'], $element['#parents']);
  if (!$value && $input === NULL) {
    $value = $element['#default_value'];
  }
  $client_parents = $element['#parents'];
  array_pop($client_parents);
  array_push($client_parents, 'bcid');
  $bcid = drupal_array_get_nested_value($form_state['values'], $client_parents);
  if ($bcid === NULL) {
    $parent_elements = $element['#parents'];
    array_pop($parent_elements);
    $current_form =& $form_state['complete form'];
    while ($parent_elements) {
      $key = array_shift($parent_elements);
      $current_form =& $current_form[$key];
    }
    $client_element =& $current_form['bcid'];
    $bcid = $client_element['#default_value'];
  }
  if (is_numeric($value)) {
    brightcove_try(function () use ($bcid, &$value) {
      $client = brightcove_client_load_or_default($bcid);
      $video = brightcove_load_video($value, $client);
      if ($video) {
        $value = check_plain($video
          ->getName()) . " [id:{$video->getId()}]";
      }
    });
  }
  return $value;
}