function fivestar_views_value_display_handler in Fivestar 6
Same name and namespace in other branches
- 5 fivestar.module \fivestar_views_value_display_handler()
- 6.2 fivestar.module \fivestar_views_value_display_handler()
VotingAPI Views formatter for displaying static stars.
1 call to fivestar_views_value_display_handler()
- fivestar_views_widget_handler in ./
fivestar.module - Generic VotingAPI Views formatter for displaying rating widget.
File
- ./
fivestar.module, line 1661 - A simple n-star voting widget, usable in other forms.
Code
function fivestar_views_value_display_handler($value, $field, $columns) {
// Determine number of stars to display
if ($field->view->base_table == 'node') {
if (isset($columns->node_type)) {
$stars = variable_get('fivestar_stars_' . $columns->node_type, 5);
}
else {
$node_type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid));
$stars = variable_get('fivestar_stars_' . (!isset($node_type) ? 'default' : $node_type), 5);
}
// Find the VotingAPI tag for this field.
foreach ($field->query->table_queue[$field->relationship]['join']->extra as $votingapi_setting) {
if ($votingapi_setting['field'] == 'tag') {
$tag = $votingapi_setting['value'];
}
}
}
else {
$stars = 5;
$tag = 'vote';
}
return theme('fivestar_static', $value, $stars, $tag);
}