/[drupal]/contributions/modules/fivestar/fivestar.module
ViewVC logotype

Diff of /contributions/modules/fivestar/fivestar.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.13.2.65, Wed Jul 1 03:02:11 2009 UTC revision 1.13.2.66, Wed Jul 1 03:27:22 2009 UTC
# Line 1  Line 1 
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
# Line 1627  function fivestar_validate($element, &$f Line 1627  function fivestar_validate($element, &$f
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') {
# Line 1663  function fivestar_views_value_display_ha Line 1670  function fivestar_views_value_display_ha
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.

Legend:
Removed from v.1.13.2.65  
changed lines
  Added in v.1.13.2.66

  ViewVC Help
Powered by ViewVC 1.1.2