Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -113,8 +113,9 @@ |
114 | 114 | 'contest-welcome-signup' => 'Signup now', |
115 | 115 | 'contest-welcome-js-off' => 'The contest user interface uses JavaScript. Your browser does not support JavaScript or JavaScript is disabled.', |
116 | 116 | 'contest-welcome-accept-challenge' => 'Challenge accepted', |
117 | | - |
118 | 117 | '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.', |
119 | 120 | |
120 | 121 | // Special:ContestSignup & Special:ContestSubmission |
121 | 122 | 'contest-signup-unknown' => 'There is no contest with the provided name.', |
— | — | @@ -131,6 +132,7 @@ |
132 | 133 | 'contest-signup-draft' => 'This contest has not yet started. Please be patient.', |
133 | 134 | 'contest-signup-country' => 'Your country', |
134 | 135 | 'contest-signup-emailwarn' => 'Warning: You are changing your accounts e-mail address, which will require your confirming the new address.', |
| 136 | + |
135 | 137 | |
136 | 138 | 'contest-signup-require-rules' => 'You must agree to the contest rules.', |
137 | 139 | 'contest-signup-require-country' => 'You must provide your country of residence.', |
Index: trunk/extensions/Contest/specials/SpecialMyContests.php |
— | — | @@ -222,7 +222,6 @@ |
223 | 223 | |
224 | 224 | if ( $contest === false ) { |
225 | 225 | $this->showError( 'contest-submission-unknown' ); |
226 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
227 | 226 | $out->returnToMain(); |
228 | 227 | } |
229 | 228 | else { |
— | — | @@ -233,7 +232,6 @@ |
234 | 233 | case Contest::STATUS_FINISHED: |
235 | 234 | case Contest::STATUS_EXPIRED: |
236 | 235 | $this->showWarning( 'contest-submission-finished' ); |
237 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
238 | 236 | $out->returnToMain(); |
239 | 237 | break; |
240 | 238 | } |
Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php |
— | — | @@ -44,24 +44,67 @@ |
45 | 45 | $contest = Contest::s()->selectRow( null, array( 'name' => $subPage ) ); |
46 | 46 | |
47 | 47 | if ( $contest === false ) { |
48 | | - $this->showError( 'contest-welcome-unknown' ); |
49 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
50 | | - $out->returnToMain(); |
| 48 | + $this->showNoSuchContest( $subPage ); |
51 | 49 | } |
52 | 50 | else if ( ( $contest->getStatus() == Contest::STATUS_FINISHED ) || |
53 | 51 | ( $contest->getStatus() == Contest::STATUS_EXPIRED ) ) { |
54 | 52 | $this->showWarning( 'contest-signup-finished' ); |
55 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
56 | 53 | $out->returnToMain(); |
57 | 54 | } else if ( $contest->getStatus() == Contest::STATUS_DRAFT ) { |
58 | 55 | $this->showWarning( 'contest-signup-draft' ); |
59 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
60 | 56 | $out->returnToMain(); |
61 | 57 | } |
62 | 58 | else { |
63 | 59 | $this->showEnabledPage( $contest ); |
64 | 60 | } |
65 | 61 | } |
| 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 | + } |
66 | 109 | |
67 | 110 | protected function showEnabledPage( Contest $contest ) { |
68 | 111 | $out = $this->getOutput(); |
Index: trunk/extensions/Contest/specials/SpecialContestPage.php |
— | — | @@ -70,6 +70,7 @@ |
71 | 71 | protected function showError( $message ) { |
72 | 72 | $this->getOutput()->addHTML( |
73 | 73 | '<p class="visualClear errorbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>' |
| 74 | + . '<hr style="display: block; clear: both; visibility: hidden;" />' |
74 | 75 | ); |
75 | 76 | } |
76 | 77 | |
— | — | @@ -83,6 +84,7 @@ |
84 | 85 | protected function showWarning( $message ) { |
85 | 86 | $this->getOutput()->addHTML( |
86 | 87 | '<p class="visualClear warningbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>' |
| 88 | + . '<hr style="display: block; clear: both; visibility: hidden;" />' |
87 | 89 | ); |
88 | 90 | } |
89 | 91 | |
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php |
— | — | @@ -110,7 +110,6 @@ |
111 | 111 | |
112 | 112 | if ( $contest === false ) { |
113 | 113 | $this->showError( 'contest-signup-unknown' ); |
114 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
115 | 114 | $out->returnToMain(); |
116 | 115 | return; |
117 | 116 | } |
— | — | @@ -120,13 +119,11 @@ |
121 | 120 | break; |
122 | 121 | case Contest::STATUS_DRAFT: |
123 | 122 | $this->showWarning( 'contest-signup-draft' ); |
124 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
125 | 123 | $out->returnToMain(); |
126 | 124 | break; |
127 | 125 | case Contest::STATUS_FINISHED: |
128 | 126 | case Contest::STATUS_EXPIRED: |
129 | 127 | $this->showWarning( 'contest-signup-finished' ); |
130 | | - $out->addHTML( '<br /><br /><br /><br />' ); |
131 | 128 | $out->returnToMain(); |
132 | 129 | break; |
133 | 130 | } |
Index: trunk/extensions/Contest/specials/SpecialEditContest.php |
— | — | @@ -393,6 +393,7 @@ |
394 | 394 | protected function showWarning( $message ) { |
395 | 395 | $this->getOutput()->addHTML( |
396 | 396 | '<p class="visualClear warningbox">' . wfMsgExt( $message, 'parseinline' ) . '</p>' |
| 397 | + . '<hr style="display: block; clear: both; visibility: hidden;" />' |
397 | 398 | ); |
398 | 399 | } |
399 | 400 | |