You are here

function theme_fivestar_formatter_default in Fivestar 8

Same name and namespace in other branches
  1. 6.2 includes/fivestar.field.inc \theme_fivestar_formatter_default()
  2. 6 fivestar_field.inc \theme_fivestar_formatter_default()
  3. 7.2 includes/fivestar.theme.inc \theme_fivestar_formatter_default()

Theme function for 'default' fivestar field formatter.

This themes static stars. That is, pairs of stars where neither set of stars is "exposed". Exposed stars are clickable and displayed in a form. Theming of exposed stars is handled by the form array (and calls the same theme functions called at the end of this function).

1 string reference to 'theme_fivestar_formatter_default'
fivestar_theme in ./fivestar.module
Implements hook_theme().

File

includes/fivestar.theme.inc, line 120
Provides the theming functions for fivestar.

Code

function theme_fivestar_formatter_default($variables) {
  $element = $variables['element'];
  if (empty($element['#instance_settings']['stars'])) {
    $element['#instance_settings']['stars'] = 5;
  }

  // Add CSS and JS.
  $path = drupal_get_path('module', 'fivestar');
  drupal_add_js($path . '/js/fivestar.js');
  drupal_add_css($path . '/css/fivestar.css');
  $variables = [
    'rating' => $element['#rating'],
    'stars' => $element['#instance_settings']['stars'],
    'widget' => $element['#widget'],
  ];
  $star_display = theme('fivestar_static', $variables);
  return theme('fivestar_static_element', [
    'description' => $element['#description'],
    'star_display' => $star_display,
    'is_form' => FALSE,
  ]);
}