Same name and namespace in other branches
  1. 5.x modules/color/color.module \color_scheme_form()
  2. 7.x modules/color/color.module \color_scheme_form()
  3. 8.9.x core/modules/color/color.module \color_scheme_form()
  4. 9 core/modules/color/color.module \color_scheme_form()

Form callback. Returns the configuration form.

File

modules/color/color.module, line 150

Code

function color_scheme_form(&$form_state, $theme) {
  $base = drupal_get_path('module', 'color');
  $info = color_get_info($theme);

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

  // Add custom CSS/JS
  drupal_add_css($base . '/color.css', 'module', 'all', FALSE);
  drupal_add_js($base . '/color.js');
  drupal_add_js(array(
    'color' => array(
      'reference' => color_get_palette($theme, true),
    ),
  ), 'setting');

  // See if we're using a predefined scheme
  $current = implode(',', variable_get('color_' . $theme . '_palette', array()));

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

  // Add scheme selector
  $info['schemes'][''] = t('Custom');
  $form['scheme'] = array(
    '#type' => 'select',
    '#title' => t('Color set'),
    '#options' => $info['schemes'],
    '#default_value' => $current,
  );

  // Add palette fields
  $palette = color_get_palette($theme);
  $names = array(
    'base' => t('Base color'),
    'link' => t('Link color'),
    'top' => t('Header top'),
    'bottom' => t('Header bottom'),
    'text' => t('Text color'),
  );
  $form['palette']['#tree'] = true;
  foreach ($palette as $name => $value) {
    $form['palette'][$name] = array(
      '#type' => 'textfield',
      '#title' => $names[$name],
      '#default_value' => $value,
      '#size' => 8,
    );
  }
  $form['theme'] = array(
    '#type' => 'value',
    '#value' => arg(4),
  );
  $form['info'] = array(
    '#type' => 'value',
    '#value' => $info,
  );
  return $form;
}