function theme_fivestar_summary in Fivestar 5
Same name and namespace in other branches
- 6.2 fivestar.module \theme_fivestar_summary()
- 6 fivestar.module \theme_fivestar_summary()
- 7.2 includes/fivestar.theme.inc \theme_fivestar_summary()
3 theme calls to theme_fivestar_summary()
- fivestar_custom_widget in ./
fivestar.module - fivestar_static in ./
fivestar.module - fivestar_vote in ./
fivestar.module - Callback function for fivestar/vote.
File
- ./
fivestar.module, line 1359 - A simple n-star voting widget, usable in other forms.
Code
function theme_fivestar_summary($user_rating, $average_rating, $votes, $stars = 5, $feedback = TRUE) {
$output = '';
$div_class = '';
if (isset($user_rating)) {
$div_class = isset($votes) ? 'user-count' : 'user';
$user_stars = round($user_rating * $stars / 100, 1);
$output .= '<span class="user-rating">' . t('Your rating: <span>!stars</span>', array(
'!stars' => $user_rating ? $user_stars : t('None'),
)) . '</span>';
}
if (isset($user_rating) && isset($average_rating)) {
$output .= ' ';
}
if (isset($average_rating)) {
$div_class = isset($votes) ? 'average-count' : 'average';
$average_stars = round($average_rating * $stars / 100, 1);
$output .= '<span class="average-rating">' . t('Average: <span>!stars</span>', array(
'!stars' => $average_stars,
)) . '</span>';
}
if (isset($user_rating) && isset($average_rating)) {
$div_class = 'combo';
}
if (isset($votes) && !(isset($user_rating) || isset($average_rating))) {
$output .= ' <span class="total-votes">' . format_plural($votes, '<span>@count</span> vote', '<span>@count</span> votes') . '</span>';
$div_class = 'count';
}
elseif (isset($votes)) {
$output .= ' <span class="total-votes">(' . format_plural($votes, '<span>@count</span> vote', '<span>@count</span> votes') . ')</span>';
}
if ($votes === 0) {
$output = '<span class="empty">' . t('No votes yet') . '</span>';
}
$output = '<div class="fivestar-summary fivestar-summary-' . $div_class . ($feedback ? ' fivestar-feedback-enabled' : '') . '">' . $output . '</div>';
return $output;
}