r98372 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98371‎ | r98372 | r98373 >
Date:21:41, 28 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on contests page
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSignup.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -71,6 +71,9 @@
7272 // Special:ContestWelcome
7373 'contest-welcome-unknown' => 'There is no contest with the provided name.',
7474
 75+ // Special:ContestSignup
 76+ 'contest-signup-unknown' => 'There is no contest with the provided name.',
 77+
7578 // Special:Contest
7679 'contest-contest-title' => 'Contest: $1',
7780 'contest-contest-no-results' => 'There are no contestants to list.',
Index: trunk/extensions/Contest/specials/SpecialContests.php
@@ -124,11 +124,13 @@
125125 Html::element( 'th', array(), wfMsg( 'contest-special-submissioncount' ) )
126126 );
127127
128 - if ( $user->isAllowed( 'contestadmin' ) ) {
129 - $headers[] = Html::element( 'th', array( 'class' => 'unsortable' ), wfMsg( 'contest-special-edit' ) );
130 - $headers[] = Html::element( 'th', array( 'class' => 'unsortable' ), wfMsg( 'contest-special-delete' ) );
131 - }
 128+ $headers[] = Html::element( 'th', array( 'class' => 'unsortable' ) );
132129
 130+// if ( $user->isAllowed( 'contestadmin' ) ) {
 131+// $headers[] = Html::element( 'th', array( 'class' => 'unsortable' ), wfMsg( 'contest-special-edit' ) );
 132+// $headers[] = Html::element( 'th', array( 'class' => 'unsortable' ), wfMsg( 'contest-special-delete' ) );
 133+// }
 134+
133135 $out->addHTML( '<thead><tr>' . implode( '', $headers ) . '</tr></thead>' );
134136
135137 $out->addHTML( '<tbody>' );
@@ -167,35 +169,63 @@
168170 $this->getLang()->formatNum( $contest->getField( 'submission_count' ) )
169171 );
170172
 173+ $links = array();
 174+
 175+ if ( $user->isAllowed( 'contestjudge' ) ) {
 176+ $links[] = Html::element(
 177+ 'a',
 178+ array(
 179+ 'href' => SpecialPage::getTitleFor( 'Contest', $contest->getField( 'name' ) )->getLocalURL()
 180+ ),
 181+ wfMsg( 'contest-nav-contest' )
 182+ );
 183+ }
 184+
171185 if ( $user->isAllowed( 'contestadmin' ) ) {
172 - $fields[] = Html::rawElement(
173 - 'td',
174 - array(),
175 - Html::element(
176 - 'a',
177 - array(
178 - 'href' => SpecialPage::getTitleFor( 'EditContest', $contest->getField( 'name' ) )->getLocalURL()
179 - ),
180 - wfMsg( 'contest-special-edit' )
181 - )
 186+ $links[] = Html::element(
 187+ 'a',
 188+ array(
 189+ 'href' => SpecialPage::getTitleFor( 'EditContest', $contest->getField( 'name' ) )->getLocalURL()
 190+ ),
 191+ wfMsg( 'contest-special-edit' )
182192 );
183193
184 - $fields[] = Html::rawElement(
185 - 'td',
186 - array(),
187 - Html::element(
188 - 'a',
189 - array(
190 - 'href' => '#',
191 - 'class' => 'contest-delete',
192 - 'data-contest-id' => $contest->getId(),
193 - 'data-contest-token' => $this->getUser()->editToken( 'deletecontest' . $contest->getId() )
194 - ),
195 - wfMsg( 'contest-special-delete' )
196 - )
 194+ $links[] = Html::element(
 195+ 'a',
 196+ array(
 197+ 'href' => '#',
 198+ 'class' => 'contest-delete',
 199+ 'data-contest-id' => $contest->getId(),
 200+ 'data-contest-token' => $this->getUser()->editToken( 'deletecontest' . $contest->getId() )
 201+ ),
 202+ wfMsg( 'contest-special-delete' )
197203 );
198204 }
199205
 206+ $links[] = Html::element(
 207+ 'a',
 208+ array(
 209+ 'href' => SpecialPage::getTitleFor( 'ContestWelcome', $contest->getField( 'name' ) )->getLocalURL()
 210+ ),
 211+ wfMsg( 'contest-nav-contestwelcome' )
 212+ );
 213+
 214+ if ( $user->isAllowed( 'contestparticipant' ) ) {
 215+ $links[] = Html::element(
 216+ 'a',
 217+ array(
 218+ 'href' => SpecialPage::getTitleFor( 'ContestSignup', $contest->getField( 'name' ) )->getLocalURL()
 219+ ),
 220+ wfMsg( 'contest-nav-contestsignup' )
 221+ );
 222+ }
 223+
 224+ $fields[] = Html::rawElement(
 225+ 'td',
 226+ array(),
 227+ $this->getLang()->pipeList( $links )
 228+ );
 229+
200230 $out->addHTML( '<tr>' . implode( '', $fields ) . '</tr>' );
201231 }
202232
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php
@@ -34,7 +34,21 @@
3535 return;
3636 }
3737
 38+ $out = $this->getOutput();
3839
 40+ $contest = Contest::s()->selectRow( null, array( 'name' => $subPage ) );
 41+
 42+ if ( $contest === false ) {
 43+ $this->showError( 'contest-signup-unknown' );
 44+ $out->addHTML( '<br /><br /><br /><br />' );
 45+ $out->returnToMain();
 46+ }
 47+ else {
 48+ // TODO: we might want to have a title field here
 49+ $out->setPageTitle( $contest->getField( 'name' ) );
 50+
 51+
 52+ }
3953 }
4054
41 -}
\ No newline at end of file
 55+}

Status & tagging log