| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.module,v 1.13.2.64 2009/07/01 02:43:31 quicksketch Exp $ |
// $Id: fivestar.module,v 1.13.2.65 2009/07/01 03:02:11 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1627 |
} |
} |
| 1628 |
} |
} |
| 1629 |
|
|
| 1630 |
|
/** |
| 1631 |
|
* Implementation of hook_votingapi_views_formatters(). |
| 1632 |
|
*/ |
| 1633 |
function fivestar_votingapi_views_formatters($details = array()) { |
function fivestar_votingapi_views_formatters($details = array()) { |
| 1634 |
if ($details->field == 'value') { |
if ($details->field == 'value') { |
| 1635 |
return array( |
return array( |
| 1636 |
'fivestar_views_value_display_handler' => t('Fivestar Stars (display only)'), |
'fivestar_views_value_display_handler' => t('Fivestar Stars (display only)'), |
| 1637 |
|
'fivestar_views_value_text_handler' => t('Fivestar Stars (text star count)'), |
| 1638 |
'fivestar_views_widget_compact_handler' => t('Fivestar Stars (clickable, no text)'), |
'fivestar_views_widget_compact_handler' => t('Fivestar Stars (clickable, no text)'), |
| 1639 |
'fivestar_views_widget_normal_handler' => t('Fivestar Stars (clickable, with text)'), |
'fivestar_views_widget_normal_handler' => t('Fivestar Stars (clickable, with text)'), |
| 1640 |
); |
); |
| 1641 |
} |
} |
| 1642 |
} |
} |
| 1643 |
|
|
| 1644 |
|
/** |
| 1645 |
|
* VotingAPI Views formatter for displaying static stars. |
| 1646 |
|
*/ |
| 1647 |
function fivestar_views_value_display_handler($value, $field, $columns) { |
function fivestar_views_value_display_handler($value, $field, $columns) { |
| 1648 |
// Determine number of stars to display |
// Determine number of stars to display |
| 1649 |
if ($field->view->base_table == 'node') { |
if ($field->view->base_table == 'node') { |
| 1670 |
return theme('fivestar_static', $value, $stars, $tag); |
return theme('fivestar_static', $value, $stars, $tag); |
| 1671 |
} |
} |
| 1672 |
|
|
| 1673 |
|
/** |
| 1674 |
|
* VotingAPI Views formatter for displaying number of stars as text. |
| 1675 |
|
*/ |
| 1676 |
|
function fivestar_views_value_text_handler($value, $field, $columns) { |
| 1677 |
|
// Get the number of stars for this node type. |
| 1678 |
|
$node_type = isset($columns->node_type) ? $columns->node_type : db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid)); |
| 1679 |
|
$stars = variable_get('fivestar_stars_'. $node_type, 5); |
| 1680 |
|
|
| 1681 |
|
// If displaying a user's vote, always display a whole value. |
| 1682 |
|
if ($field->table == 'votingapi_vote') { |
| 1683 |
|
return ceil(($value / 100) * $stars); |
| 1684 |
|
} |
| 1685 |
|
else { |
| 1686 |
|
return round(($value / 100) * $stars, 1); |
| 1687 |
|
} |
| 1688 |
|
} |
| 1689 |
|
|
| 1690 |
|
/** |
| 1691 |
|
* VotingAPI Views formatter for displaying rating widget without text. |
| 1692 |
|
*/ |
| 1693 |
function fivestar_views_widget_compact_handler($value, $field, $columns) { |
function fivestar_views_widget_compact_handler($value, $field, $columns) { |
| 1694 |
return fivestar_views_widget_handler($value, $field, $columns, FALSE); |
return fivestar_views_widget_handler($value, $field, $columns, FALSE); |
| 1695 |
} |
} |
| 1696 |
|
|
| 1697 |
|
/** |
| 1698 |
|
* VotingAPI Views formatter for displaying rating widget with text. |
| 1699 |
|
*/ |
| 1700 |
function fivestar_views_widget_normal_handler($value, $field, $columns) { |
function fivestar_views_widget_normal_handler($value, $field, $columns) { |
| 1701 |
return fivestar_views_widget_handler($value, $field, $columns, TRUE); |
return fivestar_views_widget_handler($value, $field, $columns, TRUE); |
| 1702 |
} |
} |
| 1703 |
|
|
| 1704 |
|
/** |
| 1705 |
|
* Generic VotingAPI Views formatter for displaying rating widget. |
| 1706 |
|
*/ |
| 1707 |
function fivestar_views_widget_handler($value, $field, $columns, $summary) { |
function fivestar_views_widget_handler($value, $field, $columns, $summary) { |
| 1708 |
|
|
| 1709 |
// If the user can't rate, use the display handler. |
// If the user can't rate, use the display handler. |