You are here

function media_youtube_config in Media: YouTube 6

Media Mover configuration form element for Media: YouTube.

See also

media_youtube_validate_configuration().

1 call to media_youtube_config()
media_youtube_media_mover in ./media_youtube.module
Implementation of media_mover hook

File

includes/media_youtube.media_mover.inc, line 115
Functions to implement Media Mover behavior for Media: YouTube.

Code

function media_youtube_config($configuration) {
  $youtube_username = isset($configuration['media_youtube_username']) ? $configuration['media_youtube_username'] : media_youtube_variable_get('youtube_username');
  $youtube_password = isset($configuration['media_youtube_password']) ? $configuration['media_youtube_password'] : media_youtube_variable_get('youtube_password');
  $form['media_youtube_conf'] = array(
    '#type' => 'fieldset',
    '#title' => t('Upload to Youtube configuration'),
    '#element_validate' => array(
      'media_youtube_validate_configuration',
      array(
        'media_youtube_conf',
      ),
    ),
  );

  //   $form['media_youtube_conf']['media_youtube_username'] = array(
  //     '#title' => t('Username'),
  //     '#type' => 'textfield',
  //     '#default_value' => $youtube_username,
  //     '#description' => t('Your Youtube username.'),
  //   );
  //
  //   $form['media_youtube_conf']['media_youtube_password'] = array(
  //     '#title' => t('Password'),
  //     '#type' => 'password',
  //     '#default_value' => $youtube_password,
  //     '#description' => t('Your Youtube password.'),
  //   );
  //
  //   $form['media_youtube_conf']['media_youtube_key'] = array(
  //     '#title' => t('Developer Key'),
  //     '#type' => 'textfield',
  //     '#default_value' => $configuration['media_youtube_key'] ? $configuration['media_youtube_key'] : media_youtube_variable_get('api_key'),
  //     '#description' => t('Your Youtube developer key.'),
  //   );
  $form['media_youtube_conf']['media_youtube_category'] = array(
    '#title' => t('Category'),
    '#type' => 'textfield',
    '#default_value' => $configuration['media_youtube_category'] ? $configuration['media_youtube_category'] : '',
    '#description' => t('The category where videos will be added. This has to be a Youtube category.'),
  );
  $form['media_youtube_conf']['media_youtube_default_title'] = array(
    '#title' => t('Default title'),
    '#type' => 'textfield',
    '#default_value' => $configuration['media_youtube_default_title'] ? $configuration['media_youtube_default_title'] : '',
    '#description' => t('Videos which do not belong to a node will be given this title.'),
  );
  $options = array(
    'body' => t('<Body>'),
  );
  foreach (content_fields() as $field) {
    $options[$field['field_name']] = $field['widget']['label'];
  }
  $form['media_youtube_conf']['media_youtube_description_field'] = array(
    '#title' => t('Description field'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $configuration['media_youtube_description_field'] ? $configuration['media_youtube_description_field'] : 'body',
    '#description' => t('The video description will be pulled from this field.'),
  );
  $form['media_youtube_conf']['media_youtube_default_description'] = array(
    '#title' => t('Default description'),
    '#type' => 'textfield',
    '#default_value' => $configuration['media_youtube_default_description'] ? $configuration['media_youtube_default_description'] : 'Default description',
    '#description' => t('Videos which do not have a node, or text in the body or description field above will be given this description.'),
  );
  $form['media_youtube_conf']['media_youtube_default_tags'] = array(
    '#title' => t('Default tags'),
    '#type' => 'textfield',
    '#default_value' => $configuration['media_youtube_default_tags'] ? $configuration['media_youtube_default_tags'] : '',
    '#description' => t('Videos which do not belong to a node or which do not have tags will be given these tags. Separate them by space.'),
  );
  $vocabs = taxonomy_get_vocabularies();
  $options = array();
  foreach ($vocabs as $vocab) {
    $options[$vocab->vid] = $vocab->name;
  }
  $form['media_youtube_conf']['media_youtube_vocabs'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Take tags from'),
    '#description' => t('Tags will be taken from the selected vocabularies.'),
    '#options' => $options,
    '#default_value' => $configuration['media_youtube_vocabs'] ? $configuration['media_youtube_vocabs'] : array(),
  );
  return $form;
}