function fivestar_views_value_text_handler in Fivestar 6
Same name and namespace in other branches
- 6.2 fivestar.module \fivestar_views_value_text_handler()
VotingAPI Views formatter for displaying number of stars as text.
File
- ./
fivestar.module, line 1690 - A simple n-star voting widget, usable in other forms.
Code
function fivestar_views_value_text_handler($value, $field, $columns) {
// Get the number of stars for this node type.
$node_type = isset($columns->node_type) ? $columns->node_type : db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid));
$stars = variable_get('fivestar_stars_' . $node_type, 5);
// If displaying a user's vote, always display a whole value.
if ($field->table == 'votingapi_vote') {
return ceil($value / 100 * $stars);
}
else {
if ($field->options['set_precision']) {
return round($value / 100 * $stars, $field->options['precision']);
}
return $value / 100 * $stars;
}
}