function rate_preprocess_rate_template_fivestar in Rate 7
Same name and namespace in other branches
- 6.2 rate.module \rate_preprocess_rate_template_fivestar()
Preprocess function for the fivestar template.
File
- ./
rate.module, line 1236 - Rate module
Code
function rate_preprocess_rate_template_fivestar(&$variables) {
extract($variables);
$stars = array();
$count = count($links);
$percent_per_star = 100 / ($count - 1);
for ($i = 0; $i < $count; $i++) {
if (round($results['rating'] / $percent_per_star) >= $i && !$results['empty']) {
$class = 'rate-fivestar-btn-filled';
}
else {
$class = 'rate-fivestar-btn-empty';
}
$class .= ' rate-fivestar-' . ($i + 1);
$stars[] = theme('rate_button', array(
'text' => $links[$i]['text'],
'href' => $links[$i]['href'],
'class' => $class,
));
}
$variables['stars'] = $stars;
$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 = round($results['user_vote'] / 25) + 1;
$info[] = t('You voted !vote.', array(
'!vote' => $vote,
));
}
$info[] = t('Total votes: !count', array(
'!count' => $results['count'],
));
}
$variables['info'] = implode(' ', $info);
}