You are here

function brightcove_client_select_element in Brightcove Video Connect 7.6

Same name and namespace in other branches
  1. 7.7 brightcove.client.inc \brightcove_client_select_element()

Returns a form element to select a brightcove client.

This function should be used in a hook_form_alter() whenever a client select is needed on a form.

4 calls to brightcove_client_select_element()
BrightcovePlaylistEntityUIController::overviewForm in ./brightcove.playlist.inc
Overrides EntityDefaultUIController::overviewForm()
brightcove_playlist_form in ./brightcove.playlist.inc
Playlist edit form.
_brightcove_field_playlist_widget_form in ./brightcove_field.playlist.inc
Helper function to return the playlist widget form.
_brightcove_field_video_widget_form in ./brightcove_field.video.inc
Helper function to return the video widget form.

File

./brightcove.client.inc, line 163
Client related code.

Code

function brightcove_client_select_element() {
  $client_options = [
    BRIGHTCOVE_BCID_NONE => t('- Select a client -'),
  ];
  $client_options += _brightcove_my_client_select_options();
  if (count($client_options) > 2) {
    $default_value = variable_get('brightcove_client_default');
    if (!array_key_exists($default_value, $client_options)) {
      $default_value = BRIGHTCOVE_BCID_NONE;
    }
    $element = [
      '#type' => 'select',
      '#options' => $client_options,
      '#title' => t('Client'),
      '#default_value' => $default_value,
      '#disable_video_validation' => TRUE,
    ];
  }
  elseif (count($client_options) == 2) {
    $bcid = array_keys($client_options)[1];
    $element = [
      '#type' => 'value',
      '#value' => $bcid,
      '#default_value' => $bcid,
    ];
  }
  else {
    $element = [
      '#markup' => t('Sorry, it seems you don\'t have access to any brightcove clients. You can add clients <a href="@admin-page">here</a>.', [
        '@admin-page' => url('admin/config/media/brightcove/client/add'),
      ]),
      '#type' => 'markup',
    ];
  }
  return $element;
}