poll_view_results

Versions
4.6 – 6
poll_view_results(&$node, $teaser, $page, $block)
7
poll_view_results($node, $build_mode, $block = FALSE)

Generates a graphical representation of the results of a poll.

Code

modules/poll/poll.module, line 408

<?php
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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.