You are here

function rate_slider_preprocess_rate_template_slider in Rate 7

Preprocess function for the slider template.

File

slider/rate_slider.module, line 49

Code

function rate_slider_preprocess_rate_template_slider(&$variables) {
  extract($variables);
  drupal_add_library('system', 'ui.slider');

  // Calculate start value for slider.
  if ($variables['results']['count'] == 0) {
    $variables['value'] = 50;
  }
  else {
    $variables['value'] = (int) $variables['results']['rating'];
  }
  $buttons = array();
  foreach ($links as $link) {
    $button = theme('rate_button', array(
      'text' => $link['text'],
      'href' => $link['href'],
      'class' => '',
    ));
    $buttons[] = $button;
  }
  $variables['buttons'] = $buttons;
  $info = array();
  if ($mode == RATE_CLOSED) {
    $info[] = t('Voting is closed.');
  }
  if ($mode != RATE_COMPACT && $mode != RATE_COMPACT_DISABLED) {
    if (isset($results['user_vote'])) {
      $vote = $results['user_vote'];
      $info[] = t('You voted !vote.', array(
        '!vote' => number_format($vote / 10, 2),
      ));
    }
    $info[] = t('Total votes: !count', array(
      '!count' => $results['count'],
    ));
  }
  $variables['info'] = implode(' ', $info);
}