You are here

function scald_player_settings_form in Scald: Media Management made easy 7

Player settings form.

1 string reference to 'scald_player_settings_form'
scald_menu in ./scald.module
Implements hook_menu().

File

includes/scald.admin.inc, line 660

Code

function scald_player_settings_form($form, $form_state, $type, $context, $player) {
  $contexts = scald_contexts();
  $players = scald_players();

  // If either the context or the player is missing (for example
  // because the module providing it was disabled), return an
  // empty form.
  if (!isset($contexts[$context]) || !isset($players[$player])) {
    return array();
  }

  // If the current player is not the same as the configure player, display a
  // notice message.
  if (($current_player = $contexts[$context]['player'][$type->type]['*']) != $player) {
    drupal_set_message(t('You are configuring the player %player, which is not the current player %current_player.', array(
      '%player' => $player,
      '%current_player' => $current_player,
    )), 'warning');
  }
  $settings_form = array();
  $function = $players[$player]['provider'] . '_scald_player_settings_form';
  if (function_exists($function)) {

    // Handle the default settings.
    $player_settings = isset($contexts[$context]['player'][$type->type]['settings']) ? $contexts[$context]['player'][$type->type]['settings'] : array();
    if (isset($players[$player]['settings'])) {
      $player_settings += $players[$player]['settings'];
    }
    $form['#scald'] = array(
      'type' => $type,
      'context' => $context,
      'player' => $player,
      'player_settings' => $player_settings,
    );
    $settings_form = $function($form, $form_state);
  }
  if ($settings_form) {
    $form['settings'] = array(
      '#type' => 'container',
      'settings' => $settings_form,
      'actions' => array(
        '#type' => 'action',
        'save_settings' => array(
          '#type' => 'submit',
          '#value' => t('Update'),
          '#op' => 'update',
        ),
      ),
    );
  }
  return $form;
}