cvs: pearweb /include pear-voter.php /templates election-showresults.tpl.php
| From: | Greg Beaver | Date: | Mon, 06 Nov 2006 21:34:52 +0000 |
| Subject: | cvs: pearweb /include pear-voter.php /templates election-showresults.tpl.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-5156@lists.php.net to get a copy of this message | ||
cellog Mon Nov 6 21:34:52 2006 UTC
Modified files:
/pearweb/include pear-voter.php
/pearweb/templates election-showresults.tpl.php
Log:
show voting abstentions
highlight winners of elections
# now to create the administrative backend
http://cvs.php.net/viewvc.cgi/pearweb/include/pear-voter.php?r1=1.1&r2=1.2&diff_format=u
Index: pearweb/include/pear-voter.php
diff -u pearweb/include/pear-voter.php:1.1 pearweb/include/pear-voter.php:1.2
--- pearweb/include/pear-voter.php:1.1 Mon Nov 6 05:54:53 2006
+++ pearweb/include/pear-voter.php Mon Nov 6 21:34:51 2006
@@ -166,6 +166,23 @@
c.choice = e.choice
ORDER BY e.votepercent DESC
', array($id), DB_FETCHMODE_ASSOC);
+ $abstain = $this->dbh->getOne('
+ SELECT COUNT(*) FROM election_votes_abstain
+ WHERE election_id=?
+ ', array($id));
+ if ($info['maximum_choices'] > 1) {
+ $total = $this->dbh->getOne('
+ SELECT COUNT(*) FROM election_votes_multiple WHERE
+ election_id=?
+ ', array($id));
+ } else {
+ $total = $this->dbh->getOne('
+ SELECT COUNT(*) FROM election_votes_single WHERE
+ election_id=?
+ ', array($id));
+ }
+ // percentage of abstaining voters
+ $info['abstain'] = $abstain / ($total + $abstain);
return $info;
}
http://cvs.php.net/viewvc.cgi/pearweb/templates/election-showresults.tpl.php?r1=1.1&r2=1.2&diff_format=u
Index: pearweb/templates/election-showresults.tpl.php
diff -u pearweb/templates/election-showresults.tpl.php:1.1
pearweb/templates/election-showresults.tpl.php:1.2
--- pearweb/templates/election-showresults.tpl.php:1.1 Mon Nov 6 05:54:53 2006
+++ pearweb/templates/election-showresults.tpl.php Mon Nov 6 21:34:51 2006
@@ -13,12 +13,26 @@
<tr>
<th class="form-label_left">Results</th>
<td class="form-input">
- <table><?php
- foreach ($info['results'] as $result) {
- echo '<tr><td>' . number_format($result['votepercent'] * 100,
2) . '%</td><td><a href="' . $result['summary_link'] .
'">' . htmlspecialchars($result['summary']) .
- '</a></td></tr>';
+ <table>
+ <tr><td class="vote-winner">Winners</td><td
class="vote-winner"><?php echo $info['maximum_choices']
?></td></tr>
+ <?php
+ $winners = array();
+ foreach ($info['results'] as $i => $result) {
+ $winners[number_format($result['votepercent'] * 100, 2)] = 1;
+ if (count($winners) <= $info['maximum_choices']) {
+ echo '<tr><td class="vote-winner">' .
number_format($result['votepercent'] * 100, 2) .
+ '%</td><td class="vote-winner"><a href="' .
$result['summary_link'] . '">' .
+ htmlspecialchars($result['summary']) .
+ '</a></td></tr>';
+ } else {
+ echo '<tr><td>' . number_format($result['votepercent'] *
100, 2) .
+ '%</td><td><a href="' .
$result['summary_link'] . '">' .
+ htmlspecialchars($result['summary']) .
+ '</a></td></tr>';
+ }
}
?>
+ <tr><td><?php echo number_format($info['abstain'] * 100, 2)
?>%</td><td>Abstained</td></tr>
</table>
</td>
</tr>