You are here

function poll_view_results in Drupal 5

Same name and namespace in other branches
  1. 4 modules/poll.module \poll_view_results()
  2. 6 modules/poll/poll.module \poll_view_results()
  3. 7 modules/poll/poll.module \poll_view_results()

Generates a graphical representation of the results of a poll.

1 call to poll_view_results()
poll_view in modules/poll/poll.module
Implementation of hook_view().

File

modules/poll/poll.module, line 408
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function poll_view_results(&$node, $teaser, $page, $block) {

  // Count the votes and find the maximum
  foreach ($node->choice as $choice) {
    $total_votes += $choice['chvotes'];
    $max_votes = max($max_votes, $choice['chvotes']);
  }
  foreach ($node->choice as $i => $choice) {
    if ($choice['chtext'] != '') {
      $poll_results .= theme('poll_bar', check_plain($choice['chtext']), round($choice['chvotes'] * 100 / max($total_votes, 1)), format_plural($choice['chvotes'], '1 vote', '@count votes'), $block);
    }
  }
  $output .= theme('poll_results', check_plain($node->title), $poll_results, $total_votes, $node->links, $block, $node->nid, $node->vote);
  return $output;
}