Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -112,6 +112,12 @@ |
113 | 113 | 'contest-signup-draft' => 'This contest has not started yet. Please be patient.', |
114 | 114 | 'contest-signup-country' => 'Your country', |
115 | 115 | |
| 116 | + 'contest-signup-require-rules' => 'You need to agree to the contest rules.', |
| 117 | + 'contest-signup-require-country' => 'You need to provide your country of residence.', |
| 118 | + 'contest-signup-invalid-email' => 'The email address you provided is not valid.', |
| 119 | + 'contest-signup-invalid-name' => 'The name you provided is to short.', |
| 120 | + 'contest-signup-require-challange' => 'You must select a challange.', |
| 121 | + |
116 | 122 | // Special:ContestSubmission |
117 | 123 | 'contest-submission-submit' => 'Submit', |
118 | 124 | 'contest-submission-unknown' => 'There is no contest with the provided name.', |
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php |
— | — | @@ -225,6 +225,7 @@ |
226 | 226 | 'label-message' => 'contest-signup-challange', |
227 | 227 | 'options' => $this->getChallangesList( $contest ), |
228 | 228 | 'required' => true, |
| 229 | + 'validation-callback' => array( __CLASS__, 'validateChallangeField' ) |
229 | 230 | ); |
230 | 231 | |
231 | 232 | if ( $challangeId !== false ) { |
— | — | @@ -247,6 +248,7 @@ |
248 | 249 | 'type' => 'check', |
249 | 250 | 'default' => '0', |
250 | 251 | 'label-message' => array( 'contest-signup-readrules', $contest->getField( 'rules_page' ) ), |
| 252 | + 'validation-callback' => array( __CLASS__, 'validateRulesField' ) |
251 | 253 | ); |
252 | 254 | |
253 | 255 | return $fields; |
— | — | @@ -284,7 +286,11 @@ |
285 | 287 | * @return true|string |
286 | 288 | */ |
287 | 289 | public static function validateNameField( $value, $alldata = null ) { |
288 | | - return strlen( $value ) > 1; |
| 290 | + if ( strlen( $value ) < 2 ) { |
| 291 | + return wfMsg( 'contest-signup-invalid-name' ); |
| 292 | + } |
| 293 | + |
| 294 | + return true; |
289 | 295 | } |
290 | 296 | |
291 | 297 | /** |
— | — | @@ -298,7 +304,11 @@ |
299 | 305 | * @return true|string |
300 | 306 | */ |
301 | 307 | public static function validateEmailField( $value, $alldata = null ) { |
302 | | - return Sanitizer::validateEmail( $value ); |
| 308 | + if ( !Sanitizer::validateEmail( $value ) ) { |
| 309 | + return wfMsg( 'contest-signup-invalid-email' ); |
| 310 | + } |
| 311 | + |
| 312 | + return true; |
303 | 313 | } |
304 | 314 | |
305 | 315 | /** |
— | — | @@ -312,6 +322,47 @@ |
313 | 323 | * @return true|string |
314 | 324 | */ |
315 | 325 | public static function validateCountryField( $value, $alldata = null ) { |
316 | | - return $value !== ''; |
| 326 | + if ( $value === '' ) { |
| 327 | + return wfMsg( 'contest-signup-require-country' ); |
| 328 | + } |
| 329 | + |
| 330 | + return true; |
317 | 331 | } |
| 332 | + |
| 333 | + /** |
| 334 | + * HTMLForm field validation-callback for rules field. |
| 335 | + * |
| 336 | + * @since 0.1 |
| 337 | + * |
| 338 | + * @param $value String |
| 339 | + * @param $alldata Array |
| 340 | + * |
| 341 | + * @return true|string |
| 342 | + */ |
| 343 | + public static function validateRulesField( $value, $alldata = null ) { |
| 344 | + if ( !$value ) { |
| 345 | + return wfMsg( 'contest-signup-require-rules' ); |
| 346 | + } |
| 347 | + |
| 348 | + return true; |
| 349 | + } |
| 350 | + |
| 351 | + /** |
| 352 | + * HTMLForm field validation-callback for challange field. |
| 353 | + * |
| 354 | + * @since 0.1 |
| 355 | + * |
| 356 | + * @param $value String |
| 357 | + * @param $alldata Array |
| 358 | + * |
| 359 | + * @return true|string |
| 360 | + */ |
| 361 | + public static function validateChallangeField( $value, $alldata = null ) { |
| 362 | + if ( is_null( $value ) ) { |
| 363 | + return wfMsg( 'contest-signup-require-challange' ); |
| 364 | + } |
| 365 | + |
| 366 | + return true; |
| 367 | + } |
| 368 | + |
318 | 369 | } |
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | ); |
97 | 97 | |
98 | 98 | if ( $contestant === false ) { |
99 | | - $out->redirect( SpecialPage::getTitleFor( 'ContestSignup', $contest->getField( 'name' ) )->getLocalURL() ); |
| 99 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'ContestSignup', $contest->getField( 'name' ) )->getLocalURL() ); |
100 | 100 | } |
101 | 101 | else { |
102 | 102 | $contestant->setContest( $contest ); |
— | — | @@ -219,7 +219,11 @@ |
220 | 220 | * @return true|string |
221 | 221 | */ |
222 | 222 | public static function validateNameField( $value, $alldata = null ) { |
223 | | - return strlen( $value ) > 1; |
| 223 | + if ( strlen( $value ) < 2 ) { |
| 224 | + return wfMsg( 'contest-signup-invalid-name' ); |
| 225 | + } |
| 226 | + |
| 227 | + return true; |
224 | 228 | } |
225 | 229 | |
226 | 230 | /** |
— | — | @@ -233,7 +237,11 @@ |
234 | 238 | * @return true|string |
235 | 239 | */ |
236 | 240 | public static function validateEmailField( $value, $alldata = null ) { |
237 | | - return Sanitizer::validateEmail( $value ); |
| 241 | + if ( !Sanitizer::validateEmail( $value ) ) { |
| 242 | + return wfMsg( 'contest-signup-invalid-email' ); |
| 243 | + } |
| 244 | + |
| 245 | + return true; |
238 | 246 | } |
239 | 247 | |
240 | 248 | } |