r102490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102489‎ | r102490 | r102491 >
Date:04:05, 9 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
address bug 32261
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestPage.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSignup.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestWelcome.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialEditContest.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialMyContests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -113,8 +113,9 @@
114114 'contest-welcome-signup' => 'Signup now',
115115 'contest-welcome-js-off' => 'The contest user interface uses JavaScript. Your browser does not support JavaScript or JavaScript is disabled.',
116116 'contest-welcome-accept-challenge' => 'Challenge accepted',
117 -
118117 'contest-welcome-select-header' => 'Select your challenge:',
 118+ 'contest-welcome-active-contests' => 'These are the currently active contests:',
 119+ 'contest-welcome-no-contests-active' => 'There are currently no active contests.',
119120
120121 // Special:ContestSignup & Special:ContestSubmission
121122 'contest-signup-unknown' => 'There is no contest with the provided name.',
@@ -131,6 +132,7 @@
132133 'contest-signup-draft' => 'This contest has not yet started. Please be patient.',
133134 'contest-signup-country' => 'Your country',
134135 'contest-signup-emailwarn' => 'Warning: You are changing your accounts e-mail address, which will require your confirming the new address.',
 136+
135137
136138 'contest-signup-require-rules' => 'You must agree to the contest rules.',
137139 'contest-signup-require-country' => 'You must provide your country of residence.',
Index: trunk/extensions/Contest/specials/SpecialMyContests.php
@@ -222,7 +222,6 @@
223223
224224 if ( $contest === false ) {
225225 $this->showError( 'contest-submission-unknown' );
226 - $out->addHTML( '<br /><br /><br /><br />' );
227226 $out->returnToMain();
228227 }
229228 else {
@@ -233,7 +232,6 @@
234233 case Contest::STATUS_FINISHED:
235234 case Contest::STATUS_EXPIRED:
236235 $this->showWarning( 'contest-submission-finished' );
237 - $out->addHTML( '<br /><br /><br /><br />' );
238236 $out->returnToMain();
239237 break;
240238 }
Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php
@@ -44,24 +44,67 @@
4545 $contest = Contest::s()->selectRow( null, array( 'name' => $subPage ) );
4646
4747 if ( $contest === false ) {
48 - $this->showError( 'contest-welcome-unknown' );
49 - $out->addHTML( '<br /><br /><br /><br />' );
50 - $out->returnToMain();
 48+ $this->showNoSuchContest( $subPage );
5149 }
5250 else if ( ( $contest->getStatus() == Contest::STATUS_FINISHED ) ||
5351 ( $contest->getStatus() == Contest::STATUS_EXPIRED ) ) {
5452 $this->showWarning( 'contest-signup-finished' );
55 - $out->addHTML( '<br /><br /><br /><br />' );
5653 $out->returnToMain();
5754 } else if ( $contest->getStatus() == Contest::STATUS_DRAFT ) {
5855 $this->showWarning( 'contest-signup-draft' );
59 - $out->addHTML( '<br /><br /><br /><br />' );
6056 $out->returnToMain();
6157 }
6258 else {
6359 $this->showEnabledPage( $contest );
6460 }
6561 }
 62+
 63+ protected function showNoSuchContest( $subPage ) {
 64+ $out = $this->getOutput();
 65+
 66+ $c = Contest::s()->select( array( 'name', 'status', 'end' ), array( 'status' => Contest::STATUS_ACTIVE ) );
 67+ $contests = array();
 68+
 69+ // It can also be expired, but this is stored as active in the db, so matches the selection.
 70+ // It'd be better to get rid of this special behaviour so this kind of code is not needed.
 71+ foreach ( $c as /* Contest */ $contest ) {
 72+ if ( $contest->getStatus() == Contest::STATUS_ACTIVE ) {
 73+ $contests[] = $contest;
 74+ }
 75+ }
 76+
 77+ if ( count( $contests ) == 1 ) {
 78+ $out->redirect( $this->getTitle( $contests[0]->getField( 'name' ) )->getLocalURL() );
 79+ }
 80+ else {
 81+ if ( !is_null( $subPage ) && trim( $subPage ) !== '' ) {
 82+ $this->showError( 'contest-welcome-unknown' );
 83+ }
 84+
 85+ if ( count( $contests ) == 0 ) {
 86+ $out->addWikiMsg( 'contest-welcome-no-contests-active' );
 87+ }
 88+ else {
 89+ $items = array();
 90+
 91+ foreach ( $contests as /* Contest */ $contest ) {
 92+ $items[] = '<li>' . Html::element(
 93+ 'a',
 94+ array(
 95+ 'href' => $this->getTitle( $contest->getField( 'name' ) )->getLocalURL()
 96+ ),
 97+ $contest->getField( 'name' )
 98+ ) . '</li>';
 99+ }
 100+
 101+ $out->addWikiMsg( 'contest-welcome-active-contests' );
 102+
 103+ $out->addHTML( Html::rawElement( 'ul', array(), implode( "\n", $items ) ) );
 104+ }
 105+ }
 106+
 107+ $out->returnToMain();
 108+ }
66109
67110 protected function showEnabledPage( Contest $contest ) {
68111 $out = $this->getOutput();
Index: trunk/extensions/Contest/specials/SpecialContestPage.php
@@ -70,6 +70,7 @@
7171 protected function showError( $message ) {
7272 $this->getOutput()->addHTML(
7373 '<p class="visualClear errorbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>'
 74+ . '<hr style="display: block; clear: both; visibility: hidden;" />'
7475 );
7576 }
7677
@@ -83,6 +84,7 @@
8485 protected function showWarning( $message ) {
8586 $this->getOutput()->addHTML(
8687 '<p class="visualClear warningbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>'
 88+ . '<hr style="display: block; clear: both; visibility: hidden;" />'
8789 );
8890 }
8991
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php
@@ -110,7 +110,6 @@
111111
112112 if ( $contest === false ) {
113113 $this->showError( 'contest-signup-unknown' );
114 - $out->addHTML( '<br /><br /><br /><br />' );
115114 $out->returnToMain();
116115 return;
117116 }
@@ -120,13 +119,11 @@
121120 break;
122121 case Contest::STATUS_DRAFT:
123122 $this->showWarning( 'contest-signup-draft' );
124 - $out->addHTML( '<br /><br /><br /><br />' );
125123 $out->returnToMain();
126124 break;
127125 case Contest::STATUS_FINISHED:
128126 case Contest::STATUS_EXPIRED:
129127 $this->showWarning( 'contest-signup-finished' );
130 - $out->addHTML( '<br /><br /><br /><br />' );
131128 $out->returnToMain();
132129 break;
133130 }
Index: trunk/extensions/Contest/specials/SpecialEditContest.php
@@ -393,6 +393,7 @@
394394 protected function showWarning( $message ) {
395395 $this->getOutput()->addHTML(
396396 '<p class="visualClear warningbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>'
 397+ . '<hr style="display: block; clear: both; visibility: hidden;" />'
397398 );
398399 }
399400

Follow-up revisions

RevisionCommit summaryAuthorDate
r102491Follow up to r102490;jeroendedauw04:13, 9 November 2011

Status & tagging log