r99368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99367‎ | r99368 | r99369 >
Date:19:33, 9 October 2011
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
added rating stuff
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -169,6 +169,8 @@
170170 'contest-contestant-submit' => 'Save changes',
171171 'contest-contestant-comment-by' => 'Comment by $1',
172172 'contest-contestant-rate' => 'Rate this contestant',
 173+ 'contest-contestant-not-voted' => 'You have not voted on this participant yet.',
 174+ 'contest-contestant-voted' => 'Your current vote is $1.',
173175 );
174176
175177 /** Message documentation (Message documentation)
Index: trunk/extensions/Contest/specials/SpecialContestant.php
@@ -78,8 +78,19 @@
7979 }
8080 }
8181
82 - if ( $success ) {
83 - // TODO: rating shizzle
 82+ if ( $success && !is_null( $this->getRequest()->getVal( 'contestant-rating' ) ) ) {
 83+ $attribs = array(
 84+ 'value' => $this->getRequest()->getInt( 'contestant-rating' ),
 85+ 'contestant_id' => $contestant->getId(),
 86+ 'user_id' => $this->getUser()->getId()
 87+ );
 88+
 89+ if ( !is_null( $this->getRequest()->getVal( 'contestant-vote-id' ) ) ) {
 90+ $attribs['id'] = $this->getRequest()->getInt( 'contestant-vote-id' );
 91+ }
 92+
 93+ $vote = new ContestVote( $attribs );
 94+ $success = $vote->writeToDB() && $success;
8495 }
8596
8697 return $success;
@@ -204,7 +215,51 @@
205216
206217 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'contest-contestant-rate' ) ) );
207218
 219+ $vote = ContestVote::s()->selectRow(
 220+ array( 'value', 'id' ),
 221+ array( 'user_id' => $this->getUser()->getId(), 'contestant_id' => $contestant->getId() )
 222+ );
208223
 224+ if ( $vote === false ) {
 225+ $message = wfMsg( 'contest-contestant-not-voted' );
 226+ }
 227+ else {
 228+ $message = wfMsgExt(
 229+ 'contest-contestant-voted',
 230+ 'parsemag',
 231+ $this->getLang()->formatNum( $vote->getField( 'value' ) )
 232+ );
 233+
 234+ $out->addHTML( Html::hidden( 'contestant-vote-id', $vote->getId() ) );
 235+ }
 236+
 237+ $out->addHTML( Html::element( 'p', array(), $message ) );
 238+
 239+ foreach ( ContestSettings::get( 'votevalues' ) as $value ) {
 240+ $attribs = array(
 241+ 'type' => 'radio',
 242+ 'value' => $value,
 243+ 'name' => 'contestant-rating',
 244+ 'id' => 'contestant-rating-' . $value
 245+ );
 246+
 247+ if ( $vote !== false && $value == $vote->getField( 'value' ) ) {
 248+ $attribs['checked'] = 'checked';
 249+ }
 250+
 251+ $out->addHTML(
 252+ Html::element(
 253+ 'input',
 254+ $attribs
 255+ ) .
 256+ Html::element(
 257+ 'label',
 258+ array( 'for' => 'contestant-rating-' . $value ),
 259+ $this->getLang()->formatNum( $value )
 260+ )
 261+ );
 262+ }
 263+
209264 }
210265
211266 /**

Comments

#Comment by Nikerabbit (talk | contribs)   21:37, 9 October 2011

You're not adding message documentation anymore?

#Comment by Jeroen De Dauw (talk | contribs)   21:46, 9 October 2011

If I have to do that in between everything else, it'll take a lot more time then when documenting it all in one go. I will document the messages once the extension reaches initial feature completeness. Since no one is translating this yet, I see no issues with this.

#Comment by Nikerabbit (talk | contribs)   22:13, 9 October 2011

You already have the file open, so I don't see what would take more time in it, considering that you need more time to remember or checkup what to write there afterwards.

#Comment by Nikerabbit (talk | contribs)   18:29, 11 October 2011

And then I (or anybody else) can review the commits as a whole and don't need to hunt them later.

#Comment by Jeroen De Dauw (talk | contribs)   18:45, 11 October 2011

Or you can ignore the message docs until I commit them all and then review :)

Status & tagging log