You are here

function swftools_wpaudio_profile_form in SWF Tools 6.3

Returns a form definition for use by the profile system.

1 call to swftools_wpaudio_profile_form()
swftools_wpaudio_admin_form in wpaudio/swftools_wpaudio.admin.inc
@file Configuration settings for WordPress audio player.
1 string reference to 'swftools_wpaudio_profile_form'
swftools_wpaudio_swftools_methods in wpaudio/swftools_wpaudio.module
Implementation of hook_swftools_methods().

File

wpaudio/swftools_wpaudio.admin.inc, line 127
Configuration settings for WordPress audio player.

Code

function swftools_wpaudio_profile_form($profile = '') {

  // Get saved settings
  $saved_settings = _swftools_wpaudio_settings($profile);

  // Convert yes/no back to 1/0
  swftools_wpaudio_admin_boolean_settings($saved_settings['player'], SWFTOOLS_ADMIN_RETRIEVE);

  // Put the # back in front of colors
  swftools_wpaudio_admin_colors_submit($saved_settings['colors'], SWFTOOLS_ADMIN_RETRIEVE);

  // See if colorpicker 2 is loaded
  $can_pick = function_exists('colorpicker_2_or_later');
  $form['swftools_wpaudio']['player'] = array(
    '#type' => 'fieldset',
    '#title' => t('Player'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['swftools_wpaudio']['player']['height'] = array(
    '#type' => 'textfield',
    '#default_value' => $saved_settings['player']['height'],
    '#title' => t('Height'),
    '#description' => t('The height of the player in pixels.'),
    '#size' => 8,
  );
  $form['swftools_wpaudio']['player']['width'] = array(
    '#type' => 'textfield',
    '#default_value' => $saved_settings['player']['width'],
    '#title' => t('Width'),
    '#description' => t('The width of the player in pixels.'),
    '#size' => 8,
  );
  $form['swftools_wpaudio']['player']['autostart'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['autostart'],
    '#title' => t('Autostart'),
    '#description' => t('Automatically start playing the MP3. (<em>autostart</em>)'),
  );
  $form['swftools_wpaudio']['player']['loop'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['loop'],
    '#title' => t('Loop'),
    '#description' => t('Loop the sound file back to the beginning when done. (<em>loop</em>)'),
  );
  $form['swftools_wpaudio']['player']['animation'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['animation'],
    '#title' => t('Animated player'),
    '#description' => t('Start with the player closed and animate it when it opens. (<em>animation</em>)'),
  );
  $form['swftools_wpaudio']['player']['remaining'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['remaining'],
    '#title' => t('Time remaining'),
    '#description' => t('Display time remaining in player window. (<em>remaining</em>)'),
  );
  $form['swftools_wpaudio']['player']['noinfo'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['noinfo'],
    '#title' => t('Hide info'),
    '#description' => t('Don\'t show track information in the player. (<em>noinfo</em>)'),
  );
  $form['swftools_wpaudio']['player']['initialvolume'] = array(
    '#type' => 'textfield',
    '#default_value' => $saved_settings['player']['initialvolume'],
    '#title' => t('Initial volume'),
    '#description' => t('The initial volume of the player. (<em>initialvolume</em>)'),
    '#size' => 8,
  );
  $form['swftools_wpaudio']['player']['buffer'] = array(
    '#type' => 'textfield',
    '#default_value' => $saved_settings['player']['buffer'],
    '#title' => t('Buffer'),
    '#description' => t('The size of the player buffer, in seconds. (<em>buffer</em>)'),
    '#size' => 8,
  );
  $form['swftools_wpaudio']['player']['encode'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['encode'],
    '#title' => t('Encoded filenames'),
    '#description' => t('When checked indicates that filenames are encoded. (<em>encoded</em>)'),
  );
  $form['swftools_wpaudio']['player']['checkpolicy'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['checkpolicy'],
    '#title' => t('Use policy file'),
    '#description' => t('When checked allows Flash to use a policy file to access remote ID3 tags. (<em>checkpolicy</em>)'),
  );
  $form['swftools_wpaudio']['player']['rtl'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['rtl'],
    '#title' => t('Use RTL layout'),
    '#description' => t('When checked indicates that right-to-left layout should be used. (<em>rtl</em>)'),
  );
  $form['swftools_wpaudio']['player']['transparentpagebg'] = array(
    '#type' => 'checkbox',
    '#default_value' => $saved_settings['player']['transparentpagebg'],
    '#title' => t('Transparent player'),
    '#description' => t('When checked the player has a transparent background. (<em>transparentpagebg</em>)'),
  );

  //  $form['swftools_wpaudio']['map'] = array(
  //    '#value' => '<img src="http://www.1pixelout.net/wp-content/plugins/audio-player/map.gif" alt="Player Map" />',
  //  );
  $form['swftools_wpaudio']['colors'] = array(
    '#type' => 'fieldset',
    '#title' => t('Colors'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  // Iterate over color settings
  foreach ($saved_settings['colors'] as $key => $color) {
    $form['swftools_wpaudio']['colors'][$key] = array(
      '#type' => ($can_pick ? 'colorpicker_' : '') . 'textfield',
      '#default_value' => $color,
      '#size' => 8,
      '#maxlength' => 8,
      '#title' => t($key . ' color'),
      '#description' => t('Hexadecimal color of the format #RRGGBB'),
    );
  }
  $form['swftools_wpaudio']['accessibility'] = array(
    '#type' => 'fieldset',
    '#title' => t('Accessibility'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['swftools_wpaudio']['accessibility']['accessible'] = array(
    '#type' => 'radios',
    '#options' => array(
      SWFTOOLS_ACCESSIBLE_DISABLED => t('Disabled'),
      SWFTOOLS_ACCESSIBLE_HIDDEN => t('Enabled and hidden'),
      SWFTOOLS_ACCESSIBLE_VISIBLE => t('Enabled and visible'),
    ),
    '#default_value' => $saved_settings['accessibility']['accessible'],
    '#title' => t('Accessible controls'),
    '#description' => t('This option can be used to enable accessible controls to allow the player to operated via accessible links. The links can be enabled but hidden (but they will be accessible to screen readers), or they can be enabled and displayed below the player.'),
  );

  // Initialise tree as we want to store arrays
  $form['swftools_wpaudio']['#tree'] = TRUE;

  // Add custom form handler to convert 1/0 to yes/no, and to store colors without leading #
  $form['#submit'][] = 'swftools_wpaudio_admin_form_submit';

  // Return finished form
  return $form;
}