r99192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99191‎ | r99192 | r99193 >
Date:04:40, 7 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added challenge field to summary on contestant page
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestChallenge.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -154,6 +154,7 @@
155155 'contest-contestant-title' => 'Contestant $1 ($2)',
156156 'contest-contestant-header-id' => 'Contestant ID',
157157 'contest-contestant-header-contest' => 'Contest name',
 158+ 'contest-contestant-header-challenge' => 'Challenge name',
158159 'contest-contestant-header-submission' => 'Submission link',
159160 'contest-contestant-header-country' => 'Contestant country',
160161 'contest-contestant-header-wmf' => 'Interested in WMF job',
Index: trunk/extensions/Contest/specials/SpecialContestant.php
@@ -105,6 +105,9 @@
106106 $stats['id'] = htmlspecialchars( $contestant->getField( 'id' ) );
107107 $stats['contest'] = htmlspecialchars( $contestant->getContest()->getField( 'name' ) );
108108
 109+ $challengeTitles = ContestChallenge::getTitlesForIds( $contestant->getField( 'challenge_id' ) );
 110+ $stats['challenge'] = htmlspecialchars( $challengeTitles[$contestant->getField( 'challenge_id' )] );
 111+
109112 if ( $contestant->getField( 'submission' ) === '' ) {
110113 $stats['submission'] = wfMsg( 'contest-contestant-notsubmitted' );
111114 }
Index: trunk/extensions/Contest/includes/ContestChallenge.php
@@ -104,4 +104,23 @@
105105 );
106106 }
107107
 108+ /**
 109+ * Returns an array with challenge IDs (keys) and their associated titles (values)
 110+ * for the provided list of IDs.
 111+ *
 112+ * @param array|integer $ids
 113+ *
 114+ * @return array( id => title )
 115+ */
 116+ public static function getTitlesForIds( $ids ) {
 117+ $challenges = self::s()->select( array( 'id', 'title' ), array( 'id' => $ids ) );
 118+ $results = array();
 119+
 120+ foreach ( $challenges as /* ContestChallenge */ $challenge ) {
 121+ $results[$challenge->getId()] = $challenge->getField( 'title' );
 122+ }
 123+
 124+ return $results;
 125+ }
 126+
108127 }

Status & tagging log