function rate_preprocess_rate_template_fivestar in Rate 6.2
Same name and namespace in other branches
- 7 rate.module \rate_preprocess_rate_template_fivestar()
Preprocess function for the fivestar template.
File
- ./
rate.module, line 1032 - 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', $links[$i]['text'], $links[$i]['href'], $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);
}