function rate_preprocess_rate_template_number_up_down in Rate 7
Preprocess function for the number_up_down template.
File
- ./
rate.module, line 1305 - Rate module
Code
function rate_preprocess_rate_template_number_up_down(&$variables) {
extract($variables);
$up_classes = 'rate-number-up-down-btn-up';
$down_classes = 'rate-number-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,
));
if ($results['rating'] > 0) {
$score = '+' . $results['rating'];
$score_class = 'positive';
}
elseif ($results['rating'] < 0) {
$score = $results['rating'];
$score_class = 'negative';
}
else {
$score = 0;
$score_class = 'neutral';
}
$variables['score'] = $score;
$variables['score_class'] = $score_class;
$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);
}