You are here

function fivestar_settings in Fivestar 6

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_settings()
  2. 6.2 includes/fivestar.admin.inc \fivestar_settings()
  3. 7.2 includes/fivestar.admin.inc \fivestar_settings()

Callback function for admin/settings/fivestar. Display the settings form.

1 string reference to 'fivestar_settings'
fivestar_menu in ./fivestar.module
Implementation of hook_menu().

File

./fivestar.module, line 438
A simple n-star voting widget, usable in other forms.

Code

function fivestar_settings() {
  $form = array();
  $form['widget'] = array(
    '#tree' => FALSE,
    '#type' => 'fieldset',
    '#title' => t('Widget display'),
    '#description' => t('Choose a widget set to be used on your site. Widgets supporting custom colors can be further customized by adjusting the color scheme.'),
    '#weight' => -2,
  );
  $widgets = module_invoke_all('fivestar_widgets');
  $classic_widgets = array();
  $color_widgets = array();
  foreach ($widgets as $path => $name) {
    $directory = dirname($path);
    $matches = file_scan_directory($directory, '-template.');
    if (empty($matches)) {
      $classic_widgets[$path] = $name;
    }
    else {
      $color_widgets[$path] = $name;
    }
  }

  // If using a color widget, set the default value to the original path.
  $default_value = variable_get('fivestar_widget', 'default');
  foreach ($color_widgets as $path => $name) {
    if (basename($path) == basename($default_value)) {
      $default_value = $path;
    }
  }
  $form['widget']['fivestar_widget'] = array(
    '#type' => 'radios',
    '#options' => array(
      'default' => t('Default'),
    ) + $classic_widgets + $color_widgets,
    '#default_value' => $default_value,
    '#attributes' => array(
      'class' => 'fivestar-widgets',
    ),
  );
  $form['widget']['fivestar_color_widget'] = array(
    '#type' => 'radios',
    '#title' => t('Custom color widgets'),
    '#options' => $color_widgets,
    '#attributes' => array(
      'class' => 'fivestar-widgets',
    ),
  );
  $form['color'] = fivestar_color_form();
  $form['#validate'][] = 'fivestar_color_form_validate';
  $form['#submit'][] = 'fivestar_color_form_submit';
  $form['#submit'][] = 'fivestar_settings_submit';
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
    '#weight' => 45,
  );
  return $form;
}