r9747 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9746‎ | r9747 | r9748 >
Date:16:42, 28 June 2005
Author:timstarling
Status:old
Tags:
Comment:
updated
Modified paths:
  • /trunk/extensions/BoardVote/tally.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BoardVote/tally.php
@@ -15,8 +15,7 @@
1616 }
1717 $entries = explode( $end, $contents );
1818
19 -$ctally = array();
20 -$vtally = array();
 19+$tally = array();
2120 $infile = tempnam( "/tmp", "gpg" );
2221 $outfile = tempnam( "/tmp", "gpg" );
2322
@@ -30,40 +29,26 @@
3130 $file = fopen( $infile, "w" );
3231 fwrite( $file, trim( $entry ) . "\n" );
3332 fclose( $file );
34 - `gpg --batch --yes -do $outfile $infile`;
 33+ `gpg -q --batch --yes -do $outfile $infile`;
3534 $lines = file( $outfile );
36 - $cset = process_line( $lines[0] );
37 - $vset = process_line( $lines[1] );
38 - foreach ( $cset as $c ) {
39 - if ( !array_key_exists( $c, $ctally ) ) {
40 - $ctally[$c] = 0;
 35+ $set = process_line( $lines[0] );
 36+ foreach ( $set as $c ) {
 37+ if ( !array_key_exists( $c, $tally ) ) {
 38+ $tally[$c] = 0;
4139 }
42 - $ctally[$c]++;
 40+ $tally[$c]++;
4341 }
44 - foreach ( $vset as $v ) {
45 - if ( !array_key_exists( $v, $vtally ) ) {
46 - $vtally[$v] = 0;
47 - }
48 -
49 - $vtally[$v]++;
50 - }
5142 }
5243
5344 unlink( $infile );
5445 unlink( $outfile );
5546
56 -arsort( $ctally );
57 -arsort( $vtally );
 47+arsort( $tally );
5848
59 -print "Contributing representative\n";
60 -foreach ( $ctally as $candidate => $tally ) {
61 - printf( "%-30s%d\n", $candidate, $tally );
 49+foreach ( $tally as $candidate => $count ) {
 50+ printf( "%-30s%d\n", $candidate, $count );
6251 }
6352
64 -print "\nVolunteer representative\n";
65 -foreach ( $vtally as $candidate => $tally ) {
66 - printf( "%-30s%d\n", $candidate, $tally );
67 -}
6853
6954 #-----------------------------------------------------------
7055

Status & tagging log