You are here

function rate_preprocess_rate_template_thumbs_up_down in Rate 7

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

Preprocess function for the thumbs_up_down template.

File

./rate.module, line 1271
Rate module

Code

function rate_preprocess_rate_template_thumbs_up_down(&$variables) {
  extract($variables);
  $up_classes = 'rate-thumbs-up-down-btn-up';
  $down_classes = 'rate-thumbs-up-down-btn-down';
  if (isset($results['user_vote'])) {
    switch ($results['user_vote']) {
      case $links[0]['value']:
        $up_classes .= ' rate-voted';
        break;
      case $links[1]['value']:
        $down_classes .= ' rate-voted';
        break;
    }
  }
  $variables['up_button'] = theme('rate_button', array(
    'text' => $links[0]['text'],
    'href' => $links[0]['href'],
    'class' => $up_classes,
  ));
  $variables['down_button'] = theme('rate_button', array(
    'text' => $links[1]['text'],
    'href' => $links[1]['href'],
    'class' => $down_classes,
  ));
  $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' => $results['user_vote'] == 1 ? $links[0]['text'] : $links[1]['text'],
      ));
    }
  }
  $variables['info'] = implode(' ', $info);
}