You are here

function soundcloudfield_field_instance_settings_form in SoundCloud field 7

Implements hook_field_settings_form().

Pseudo-hook.

File

./soundcloudfield.module, line 78
@author Attila Fekete - http://drupal.org/user/762986

Code

function soundcloudfield_field_instance_settings_form($field, $instance) {
  $settings = $instance['settings'];
  if ($field['type'] == 'soundcloud') {
    $form = array(
      '#element_validate' => array(
        'soundcloudfield_settings_form_validate',
      ),
    );
    $form['soundcloudplayer'] = array(
      '#type' => 'fieldset',
      '#title' => t('SoundCloud settings'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['soundcloudplayer']['width'] = array(
      '#type' => 'textfield',
      '#title' => t('Width'),
      '#size' => 4,
      '#default_value' => empty($settings['soundcloudplayer']['width']) ? SOUNDCLOUDFIELD_DEFAULT_WIDTH : $settings['soundcloudplayer']['width'],
      '#description' => t('Player width in percent. Default is @width.', array(
        '@width' => SOUNDCLOUDFIELD_DEFAULT_WIDTH,
      )),
      '#required' => TRUE,
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
    );

    // HTML5 (classic) player-only settings.
    $form['soundcloudplayer']['html5_player'] = array(
      '#type' => 'fieldset',
      '#title' => t('SoundCloud HTML5 player-only settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['soundcloudplayer']['html5_player']['html5_player_height'] = array(
      '#type' => 'textfield',
      '#title' => t('Height for tracks'),
      '#size' => 4,
      '#default_value' => empty($settings['soundcloudplayer']['html5_player']['html5_player_height']) ? SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT : $settings['soundcloudplayer']['html5_player']['html5_player_height'],
      '#description' => t('Player height for tracks. Default is @height.', array(
        '@height' => SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT,
      )),
      '#required' => TRUE,
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
    );
    $form['soundcloudplayer']['html5_player']['html5_player_height_sets'] = array(
      '#type' => 'textfield',
      '#title' => t('Height for sets'),
      '#size' => 4,
      '#default_value' => empty($settings['soundcloudplayer']['html5_player']['html5_player_height_sets']) ? SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT_SETS : $settings['soundcloudplayer']['html5_player']['html5_player_height_sets'],
      '#description' => t('Player height for sets. Default is @height.', array(
        '@height' => SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT_SETS,
      )),
      '#required' => TRUE,
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
    );

    // Visual (new) player-only settings.
    $form['soundcloudplayer']['visual_player'] = array(
      '#type' => 'fieldset',
      '#title' => t('SoundCloud HTML5 visual player-only settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['soundcloudplayer']['visual_player']['visual_player_height'] = array(
      '#type' => 'select',
      '#title' => t('Size of the visual player (height):'),
      '#default_value' => empty($settings['soundcloudplayer']['visual_player']['visual_player_height']) ? SOUNDCLOUDFIELD_DEFAULT_VISUAL_PLAYER_HEIGHT : $settings['soundcloudplayer']['visual_player']['visual_player_height'],
      '#options' => array(
        300 => '300px',
        450 => '450px',
        600 => '600px',
      ),
      '#description' => t('Height of the "new" HTML5 visual player.'),
    );

    // Common settings.
    $form['soundcloudplayer']['autoplay'] = array(
      '#type' => 'checkbox',
      '#title' => t('Autoplay'),
      '#default_value' => empty($settings['soundcloudplayer']['autoplay']) ? FALSE : $settings['soundcloudplayer']['autoplay'],
      '#description' => t('Autoplay track or set.'),
    );
    $form['soundcloudplayer']['showplaycount'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show play count'),
      '#default_value' => empty($settings['soundcloudplayer']['showplaycount']) ? FALSE : $settings['soundcloudplayer']['showplaycount'],
      '#description' => t('Show play count in player.'),
    );
    $form['soundcloudplayer']['showartwork'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show artwork'),
      '#default_value' => empty($settings['soundcloudplayer']['showartwork']) ? FALSE : $settings['soundcloudplayer']['showartwork'],
      '#description' => t('Show artwork in player. Has no effect when using the visual player.'),
    );
    $form['soundcloudplayer']['color'] = array(
      '#type' => module_exists('jquery_colorpicker') ? 'jquery_colorpicker' : 'textfield',
      '#title' => t('Player color'),
      '#default_value' => empty($settings['soundcloudplayer']['color']) ? 'ff7700' : $settings['soundcloudplayer']['color'],
      '#required' => TRUE,
      '#description' => t('Player color in hexadecimal format. Default is ff7700. Turn on the jQuery Colorpicker module if available.'),
    );
  }
  return $form;
}