function fivestar_views_value_display_handler in Fivestar 6.2
Same name and namespace in other branches
- 5 fivestar.module \fivestar_views_value_display_handler()
- 6 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 1351 - 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') {
// Find the VotingAPI tag for this field.
foreach ($field->query->table_queue as $table) {
if (!empty($table['join']->extra)) {
foreach ($table['join']->extra as $extra) {
if ($extra['field'] == 'tag') {
$tag = $extra['value'];
}
}
}
}
if (!isset($columns->node_type)) {
$node_type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid));
}
else {
$node_type = $columns->node_type;
}
$settings = fivestar_get_settings($node_type, $tag);
$stars = $settings['stars'];
}
else {
$stars = 5;
$tag = 'vote';
}
return theme('fivestar_static', $value, $stars, $tag);
}