You are here

function swftools_flowplayer3_scheme_form in SWF Tools 6.3

Helper function to produce the color scheme form for the flowplayer

1 call to swftools_flowplayer3_scheme_form()
swftools_flowplayer3_profile_form in flowplayer3/swftools_flowplayer3.admin.inc
1 string reference to 'swftools_flowplayer3_scheme_form'
swftools_flowplayer3_profile_form in flowplayer3/swftools_flowplayer3.admin.inc

File

flowplayer3/swftools_flowplayer3.admin.inc, line 298
Configuration settings for Flowplayer 3.

Code

function swftools_flowplayer3_scheme_form(&$form_state, $profile = '') {

  // Get path to the flowplayer3 module
  $base = drupal_get_path('module', 'swftools_flowplayer3');

  // Add Farbtastic color picker
  drupal_add_css('misc/farbtastic/farbtastic.css');
  drupal_add_js('misc/farbtastic/farbtastic.js');

  // Add custom CSS/JS
  drupal_add_css($base . '/swftools_flowplayer3.colorpicker.css');
  drupal_add_js($base . '/swftools_flowplayer3.colorpicker.js');
  drupal_add_js(array(
    'color' => array(
      'reference' => swftools_flowplayer3_get_palette(SWFTOOLS_FLOWPLAYER3_DEFAULT_PALETTE, $profile),
    ),
  ), 'setting');

  // Get info about the current theme color scheme
  $info = swftools_flowplayer3_get_info();

  // See if we're using a predefined scheme
  // The variable is empty if using the default, or an array of key/value pairs otherwise
  $current = implode(',', swftools_variable_get('swftools_flowplayer3_palette', array(), $profile));

  // Note: we use the original theme when the default scheme is chosen.
  $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : '');

  // Add custom to scheme selector options
  $info['schemes'][''] = t('Custom');

  // Add scheme selector to form (the value is a comma separated string of hex colors)
  $form['swftools_flowplayer3_scheme'] = array(
    '#type' => 'select',
    '#title' => t('Color set'),
    '#options' => $info['schemes'],
    '#default_value' => $current,
  );

  // Get current palette as an array
  $palette = swftools_flowplayer3_get_palette(SWFTOOLS_FLOWPLAYER3_CURRENT_PALETTE, $profile);

  // Build an array of titles to be used for each palette element
  $names = array(
    'backgroundColor' => array(
      '#title' => t('Background color'),
    ),
    'controlbarbackgroundColor' => array(
      '#title' => t('Control bar background color'),
    ),
    'timeColor' => array(
      '#title' => t('Elapsed time font color'),
    ),
    'durationColor' => array(
      '#title' => t('Total time font color'),
    ),
    'progressColor' => array(
      '#title' => t('Progress bar color'),
    ),
    'bufferColor' => array(
      '#title' => t('Buffer color'),
    ),
    'sliderColor' => array(
      '#title' => t('Slider color'),
    ),
    'buttonColor' => array(
      '#title' => t('Button color'),
    ),
    'buttonOverColor' => array(
      '#title' => t('Button over color'),
    ),
    'volumeSliderColor' => array(
      '#title' => t('Volume slider color'),
    ),
    'timeBgColor' => array(
      '#title' => t('Time background color'),
    ),
  );

  // Form elements to be part of a tree
  $form['swftools_flowplayer3_palette']['#tree'] = true;

  // Cycle through each palette element
  foreach ($palette as $name => $value) {
    $form['swftools_flowplayer3_palette'][$name] = array(
      '#type' => 'textfield',
      '#title' => $names[$name]['#title'],
      '#default_value' => $value,
      '#size' => 8,
    );
  }

  // Return the form
  return $form;
}