Index: trunk/extensions/Poll/Poll_body.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | } |
22 | 22 | |
23 | 23 | if ( $action == "vote" ) { |
24 | | - $this->vote(); |
| 24 | + $this->vote( $id ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | if ( $action == "submit" ) { |
— | — | @@ -57,8 +57,8 @@ |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | | - public function vote() { |
62 | | - global $wgRequest, $wgOut, $wgUser; |
| 61 | + public function vote( $vid ) { |
| 62 | + global $wgRequest, $wgOut, $wgUser, $wgTitle; |
63 | 63 | |
64 | 64 | $wgOut->setPagetitle( wfMsg( 'poll-title-vote' ) ); |
65 | 65 | |
— | — | @@ -71,7 +71,31 @@ |
72 | 72 | $wgOut->addWikiMsg( 'poll-vote-block-error' ); |
73 | 73 | } |
74 | 74 | else { |
75 | | - |
| 75 | + $dbr = wfGetDB( DB_SLAVE ); |
| 76 | + $query = $dbr->select( 'poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6', 'id = ' . $vid); |
| 77 | + |
| 78 | + while( $row = $dbr->fetchObject( $query ) ) { |
| 79 | + $question = $row->question; |
| 80 | + $alternative_1 = htmlentities( $row->alternative_1 ); |
| 81 | + $alternative_2 = htmlentities( $row->alternative_2 ); |
| 82 | + $alternative_3 = htmlentities( $row->alternative_3 ); |
| 83 | + $alternative_4 = htmlentities( $row->alternative_4 ); |
| 84 | + $alternative_5 = htmlentities( $row->alternative_5 ); |
| 85 | + $alternative_6 = htmlentities( $row->alternative_6 ); |
| 86 | + } |
| 87 | + |
| 88 | + $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit') ) ) ); |
| 89 | + $wgOut->addHtml( Xml::openElement( 'table' ) ); |
| 90 | + $wgOut->addHtml( '<tr><th>'.$question.'</th></tr>' ); |
| 91 | + $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '1').':</td><td>'.$alternative_1.'</td></tr>' ); |
| 92 | + $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '2').':</td><td>'.$alternative_2.'</td></tr>' ); |
| 93 | + if($alternative_3 != "") { $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '3').':</td><td>'.$alternative_3.'</td></tr>' ) } |
| 94 | + if($alternative_4 != "") { $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '4').':</td><td>'.$alternative_4.'</td></tr>' ) } |
| 95 | + if($alternative_5 != "") { $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '5').':</td><td>'.$alternative_5.'</td></tr>' ) } |
| 96 | + if($alternative_6 != "") { $wgOut->addHtml( '<tr><td>'.Xml::radio('vote', '6').':</td><td>'.$alternative_6.'</td></tr>' ) } |
| 97 | + $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).''.Xml::hidden('type', 'vote').'</td></tr>' ); |
| 98 | + $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
| 99 | + $wgOut->addHtml( Xml::closeElement( 'form' ) ); |
76 | 100 | } |
77 | 101 | } |
78 | 102 | |