You are here

function theme_fivestar_settings in Fivestar 6

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

File

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

Code

function theme_fivestar_settings($form) {
  drupal_add_css(drupal_get_path('module', 'fivestar') . '/css/fivestar-admin.css', 'module', 'all', FALSE);
  drupal_set_title(t('Fivestar Settings'));

  // Default preview.
  $form['widget']['fivestar_widget']['default']['#description'] = 'Default ' . t('Preview') . ':<br />' . theme('fivestar_preview_widget', 'default');

  // Preview for each classic widget.
  foreach (element_children($form['widget']['fivestar_widget']) as $widget_key) {
    if ($widget_key != 'default') {
      $form['widget']['fivestar_widget'][$widget_key]['#description'] = $form['widget']['fivestar_widget'][$widget_key]['#title'] . ' ' . t('Preview') . ':<br />' . theme('fivestar_preview_widget', $widget_key);
    }
  }

  // Preview for each color-enabled widget.
  foreach (element_children($form['widget']['fivestar_color_widget']) as $widget_key) {
    $form['widget']['fivestar_color_widget'][$widget_key] = $form['widget']['fivestar_widget'][$widget_key];
    $form['widget']['fivestar_color_widget'][$widget_key]['#description'] = $form['widget']['fivestar_color_widget'][$widget_key]['#title'] . ' ' . t('Preview') . ':<br />' . theme('fivestar_preview_widget', $widget_key);
    unset($form['widget']['fivestar_widget'][$widget_key]);
  }

  // Add the new styles to the page.
  drupal_set_html_head("<style type=\"text/css\" media=\"all\">\n" . fivestar_get_inline_css() . "</style>");
  $form['widget']['fivestar_widget']['#attributes']['class'] .= ' clear-block';
  $form['widget']['fivestar_color_widget']['#attributes']['class'] .= ' fivestar-color-widgets clear-block';
  return drupal_render($form);
}