You are here

function rate_preprocess_rate_widget in Rate 7

Same name and namespace in other branches
  1. 6.2 rate.module \rate_preprocess_rate_widget()

Preprocess function for the emotion template.

File

./rate.module, line 1181
Rate module

Code

function rate_preprocess_rate_widget(&$variables) {
  extract($variables);
  $buttons = array();
  foreach ($links as $link) {
    $classes = 'rate-btn';
    if (isset($results['user_vote']) && $results['user_vote'] == $link['value']) {
      $classes .= ' user-voted';
    }
    $button = theme('rate_button', array(
      'text' => $link['text'],
      'href' => $link['href'],
      'class' => $classes,
    ));
    $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'])) {
      $info[] = t('You voted \'@option\'.', array(
        '@option' => t($results['user_vote']),
      ));
    }
  }
  $variables['info'] = implode(' ', $info);
}