r50527 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50526‎ | r50527 | r50528 >
Date:18:00, 12 May 2009
Author:jan
Status:deferred
Tags:
Comment:
Add form for vote
Modified paths:
  • /trunk/extensions/Poll/Poll_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Poll/Poll_body.php
@@ -20,7 +20,7 @@
2121 }
2222
2323 if ( $action == "vote" ) {
24 - $this->vote();
 24+ $this->vote( $id );
2525 }
2626
2727 if ( $action == "submit" ) {
@@ -57,8 +57,8 @@
5858 }
5959 }
6060
61 - public function vote() {
62 - global $wgRequest, $wgOut, $wgUser;
 61+ public function vote( $vid ) {
 62+ global $wgRequest, $wgOut, $wgUser, $wgTitle;
6363
6464 $wgOut->setPagetitle( wfMsg( 'poll-title-vote' ) );
6565
@@ -71,7 +71,31 @@
7272 $wgOut->addWikiMsg( 'poll-vote-block-error' );
7373 }
7474 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' ) );
76100 }
77101 }
78102

Status & tagging log