Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | 'contest-welcome-signup' => 'Signup now', |
103 | 103 | 'contest-welcome-js-off' => 'Contest uses JavaScript for an improved interface. Your browser either does not support JavaScript or has JavaScript turned off.', |
104 | 104 | |
105 | | - 'contest-welcome-select-header' => 'Select your challange:', |
| 105 | + 'contest-welcome-select-header' => 'Select your challenge:', |
106 | 106 | |
107 | 107 | // Special:ContestSignup & Special:ContestSubmission |
108 | 108 | 'contest-signup-unknown' => 'There is no contest with the provided name.', |
— | — | @@ -141,6 +141,7 @@ |
142 | 142 | |
143 | 143 | // Contestant pager |
144 | 144 | 'contest-contestant-id' => 'ID', |
| 145 | + 'contest-contestant-challenge-name' => 'Challenge name', |
145 | 146 | 'contest-contestant-volunteer' => 'Volunteer', |
146 | 147 | 'contest-contestant-wmf' => 'WMF', |
147 | 148 | 'contest-contestant-no' => 'No', |
Index: trunk/extensions/Contest/specials/SpecialContestPage.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | */ |
16 | 16 | abstract class SpecialContestPage extends SpecialPage { |
17 | 17 | |
18 | | - protected $subPage; |
| 18 | + public $subPage; |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @see SpecialPage::getDescription |
Index: trunk/extensions/Contest/specials/SpecialContest.php |
— | — | @@ -32,6 +32,11 @@ |
33 | 33 | public function execute( $subPage ) { |
34 | 34 | $subPage = str_replace( '_', ' ', $subPage ); |
35 | 35 | |
| 36 | + $subPage = explode( '/', $subPage, 2 ); |
| 37 | + $challengeTitle = count( $subPage ) > 1 ? $subPage[1] : false; |
| 38 | + |
| 39 | + $subPage = $subPage[0]; |
| 40 | + |
36 | 41 | if ( !parent::execute( $subPage ) ) { |
37 | 42 | return; |
38 | 43 | } |
— | — | @@ -47,7 +52,7 @@ |
48 | 53 | $out->setPageTitle( wfMsgExt( 'contest-contest-title', 'parseinline', $contest->getField( 'name' ) ) ); |
49 | 54 | $this->displayNavigation(); |
50 | 55 | $this->showGeneralInfo( $contest ); |
51 | | - $this->showContestants( $contest ); |
| 56 | + $this->showContestants( $contest, $challengeTitle ); |
52 | 57 | } |
53 | 58 | } |
54 | 59 | |
— | — | @@ -109,10 +114,9 @@ |
110 | 115 | * @since 0.1 |
111 | 116 | * |
112 | 117 | * @param Contest $contest |
113 | | - * |
114 | | - * TODO: list scores and comment counts as well |
| 118 | + * @param string|false $challengeTitle |
115 | 119 | */ |
116 | | - protected function showContestants( Contest $contest ) { |
| 120 | + protected function showContestants( Contest $contest, $challengeTitle ) { |
117 | 121 | $out = $this->getOutput(); |
118 | 122 | |
119 | 123 | $out->addHTML( Html::element( 'h3', array(), wfMsg( 'contest-contest-contestants' ) ) ); |
— | — | @@ -121,6 +125,14 @@ |
122 | 126 | 'contestant_contest_id' => $contest->getId() |
123 | 127 | ); |
124 | 128 | |
| 129 | + if ( $challengeTitle !== false ) { |
| 130 | + $challenge = ContestChallenge::s()->selectRow( 'id', array( 'title' => $challengeTitle ) ); |
| 131 | + |
| 132 | + if ( $challenge !== false ) { |
| 133 | + $conds['contestant_challenge_id'] = $challenge->getField( 'id' ); |
| 134 | + } |
| 135 | + } |
| 136 | + |
125 | 137 | $pager = new ContestantPager( $this, $conds ); |
126 | 138 | |
127 | 139 | if ( $pager->getNumRows() ) { |
Index: trunk/extensions/Contest/includes/ContestantPager.php |
— | — | @@ -14,18 +14,52 @@ |
15 | 15 | class ContestantPager extends TablePager { |
16 | 16 | |
17 | 17 | protected $conds; |
| 18 | + |
| 19 | + /** |
| 20 | + * @var SpecialContestPage |
| 21 | + */ |
18 | 22 | protected $page; |
| 23 | + |
| 24 | + protected $challengeTitles = array(); |
19 | 25 | |
20 | 26 | public function __construct( $page, $conds ) { |
21 | 27 | $this->page = $page; |
22 | 28 | $this->conds = $conds; |
23 | 29 | $this->mDefaultDirection = true; |
24 | 30 | |
| 31 | + $this->queryChallengeTitles( $conds ); |
| 32 | + |
| 33 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
25 | 34 | parent::__construct(); |
26 | 35 | |
27 | 36 | $this->getOutput()->addModules( 'contest.contestant.pager' ); |
28 | 37 | } |
29 | 38 | |
| 39 | + protected function queryChallengeTitles( $allConds ) { |
| 40 | + $conds = array(); |
| 41 | + |
| 42 | + if ( array_key_exists( 'contestant_contest_id', $allConds ) ) { |
| 43 | + $conds['contest_id'] = $allConds['contestant_contest_id']; |
| 44 | + } |
| 45 | + |
| 46 | + if ( array_key_exists( 'contestant_challenge_id', $allConds ) ) { |
| 47 | + $conds['id'] = $allConds['contestant_challenge_id']; |
| 48 | + } |
| 49 | + |
| 50 | + foreach ( ContestChallenge::s()->select( array( 'id', 'title' ), $conds ) as /* ContestChallenge */ $challenge ) { |
| 51 | + $this->challengeTitles[$challenge->getId()] = $challenge->getField( 'title' ); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + protected function getChallengeTitle( $challengeId ) { |
| 56 | + if ( array_key_exists( $challengeId, $this->challengeTitles ) ) { |
| 57 | + return $this->challengeTitles[$challengeId]; |
| 58 | + } |
| 59 | + else { |
| 60 | + throw new MWException( 'Attempt to get non-set challenge title' ); |
| 61 | + } |
| 62 | + } |
| 63 | + |
30 | 64 | /** |
31 | 65 | * Get the OutputPage being used for this instance. |
32 | 66 | * IndexPager extends ContextSource as of 1.19. |
— | — | @@ -56,6 +90,7 @@ |
57 | 91 | if ( is_null( $headers ) ) { |
58 | 92 | $headers = array( |
59 | 93 | 'contestant_id' => 'contest-contestant-id', |
| 94 | + 'contestant_challenge_id' => 'contest-contestant-challenge-name', |
60 | 95 | 'contestant_volunteer' => 'contest-contestant-volunteer', |
61 | 96 | 'contestant_wmf' => 'contest-contestant-wmf', |
62 | 97 | 'contestant_comments' => 'contest-contestant-commentcount', |
— | — | @@ -108,6 +143,19 @@ |
109 | 144 | $value |
110 | 145 | ); |
111 | 146 | break; |
| 147 | + case 'contestant_challenge_id': |
| 148 | + $value = Html::element( |
| 149 | + 'a', |
| 150 | + array( |
| 151 | + 'href' => |
| 152 | + SpecialPage::getTitleFor( |
| 153 | + 'Contest', |
| 154 | + $this->page->subPage . '/' . $this->getChallengeTitle( $value ) |
| 155 | + )->getLocalURL() |
| 156 | + ), |
| 157 | + $this->getChallengeTitle( $value ) |
| 158 | + ); |
| 159 | + break; |
112 | 160 | case 'contestant_volunteer': case 'contestant_wmf': |
113 | 161 | $value = wfMsg( 'contest-contestant-' . ( $value === '1' ? 'yes' : 'no' ) ); |
114 | 162 | break; |
— | — | @@ -132,6 +180,7 @@ |
133 | 181 | 'tables' => array( 'contest_contestants' ), |
134 | 182 | 'fields' => array( |
135 | 183 | 'contestant_id', |
| 184 | + 'contestant_challenge_id', |
136 | 185 | 'contestant_volunteer', |
137 | 186 | 'contestant_wmf', |
138 | 187 | 'contestant_comments', |
— | — | @@ -161,6 +210,7 @@ |
162 | 211 | $name, |
163 | 212 | array( |
164 | 213 | 'contestant_id', |
| 214 | + 'contestant_challenge_id', |
165 | 215 | 'contestant_volunteer', |
166 | 216 | 'contestant_wmf', |
167 | 217 | 'contestant_comments', |