Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -3129,6 +3129,7 @@ |
3130 | 3130 | 'htmlform-float-invalid', |
3131 | 3131 | 'htmlform-int-toolow', |
3132 | 3132 | 'htmlform-int-toohigh', |
| 3133 | + 'htmlform-required', |
3133 | 3134 | 'htmlform-submit', |
3134 | 3135 | 'htmlform-reset', |
3135 | 3136 | 'htmlform-selectorother-other', |
Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -84,6 +84,7 @@ |
85 | 85 | |
86 | 86 | protected $mPre = ''; |
87 | 87 | protected $mHeader = ''; |
| 88 | + protected $mFooter = ''; |
88 | 89 | protected $mPost = ''; |
89 | 90 | protected $mId; |
90 | 91 | |
— | — | @@ -286,6 +287,12 @@ |
287 | 288 | function addHeaderText( $msg ) { $this->mHeader .= $msg; } |
288 | 289 | |
289 | 290 | /** |
| 291 | + * Add footer text, inside the form. |
| 292 | + * @param $msg String complete text of message to display |
| 293 | + */ |
| 294 | + function addFooterText( $msg ) { $this->mFooter .= $msg; } |
| 295 | + |
| 296 | + /** |
290 | 297 | * Add text to the end of the display. |
291 | 298 | * @param $msg String complete text of message to display |
292 | 299 | */ |
— | — | @@ -313,15 +320,13 @@ |
314 | 321 | function displayForm( $submitResult ) { |
315 | 322 | global $wgOut; |
316 | 323 | |
317 | | - if ( $submitResult !== false ) { |
318 | | - $this->displayErrors( $submitResult ); |
319 | | - } |
320 | | - |
321 | 324 | $html = '' |
| 325 | + . $this->getErrors( $submitResult ) |
322 | 326 | . $this->mHeader |
323 | 327 | . $this->getBody() |
324 | 328 | . $this->getHiddenFields() |
325 | 329 | . $this->getButtons() |
| 330 | + . $this->mFooter |
326 | 331 | ; |
327 | 332 | |
328 | 333 | $html = $this->wrapForm( $html ); |
— | — | @@ -438,18 +443,18 @@ |
439 | 444 | /** |
440 | 445 | * Format and display an error message stack. |
441 | 446 | * @param $errors Mixed String or Array of message keys |
| 447 | + * @return String |
442 | 448 | */ |
443 | | - function displayErrors( $errors ) { |
| 449 | + function getErrors( $errors ) { |
444 | 450 | if ( is_array( $errors ) ) { |
445 | 451 | $errorstr = $this->formatErrors( $errors ); |
446 | 452 | } else { |
447 | 453 | $errorstr = $errors; |
448 | 454 | } |
449 | 455 | |
450 | | - $errorstr = Html::rawElement( 'div', array( 'class' => 'error' ), $errorstr ); |
451 | | - |
452 | | - global $wgOut; |
453 | | - $wgOut->addHTML( $errorstr ); |
| 456 | + return $errorstr |
| 457 | + ? Html::rawElement( 'div', array( 'class' => 'error' ), $errorstr ) |
| 458 | + : ''; |
454 | 459 | } |
455 | 460 | |
456 | 461 | /** |
— | — | @@ -996,6 +1001,16 @@ |
997 | 1002 | |
998 | 1003 | return Html::element( 'textarea', $attribs, $value ); |
999 | 1004 | } |
| 1005 | + |
| 1006 | + public function validate( $value, $alldata ){ |
| 1007 | + $p = parent::validate( $value, $alldata ); |
| 1008 | + if( $p !== true ) return $p; |
| 1009 | + |
| 1010 | + if( isset( $this->mParams['required'] ) && $value === '' ){ |
| 1011 | + return wfMsgExt( 'htmlform-required', 'parseinline' ); |
| 1012 | + } |
| 1013 | + return true; |
| 1014 | + } |
1000 | 1015 | } |
1001 | 1016 | |
1002 | 1017 | /** |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2559,29 +2559,31 @@ |
2560 | 2560 | 'listgrouprights-removegroup-self-all' => 'Remove all groups from own account', |
2561 | 2561 | |
2562 | 2562 | # E-mail user |
2563 | | -'mailnologin' => 'No send address', |
2564 | | -'mailnologintext' => 'You must be [[Special:UserLogin|logged in]] and have a valid e-mail address in your [[Special:Preferences|preferences]] to send e-mail to other users.', |
2565 | | -'emailuser' => 'E-mail this user', |
2566 | | -'emailpage' => 'E-mail user', |
2567 | | -'emailpagetext' => 'You can use the form below to send an e-mail message to this user. |
| 2563 | +'mailnologin' => 'No send address', |
| 2564 | +'mailnologintext' => 'You must be [[Special:UserLogin|logged in]] and have a valid e-mail address in your [[Special:Preferences|preferences]] to send e-mail to other users.', |
| 2565 | +'emailuser' => 'E-mail this user', |
| 2566 | +'emailpage' => 'E-mail user', |
| 2567 | +'emailpagetext' => 'You can use the form below to send an e-mail message to this user. |
2568 | 2568 | The e-mail address you entered in [[Special:Preferences|your user preferences]] will appear as the "From" address of the e-mail, so the recipient will be able to reply directly to you.', |
2569 | | -'usermailererror' => 'Mail object returned error:', |
2570 | | -'defemailsubject' => '{{SITENAME}} e-mail', |
2571 | | -'noemailtitle' => 'No e-mail address', |
2572 | | -'noemailtext' => 'This user has not specified a valid e-mail address.', |
2573 | | -'nowikiemailtitle' => 'No e-mail allowed', |
2574 | | -'nowikiemailtext' => 'This user has chosen not to receive e-mail from other users.', |
2575 | | -'email-legend' => 'Send an e-mail to another {{SITENAME}} user', |
2576 | | -'emailfrom' => 'From:', |
2577 | | -'emailto' => 'To:', |
2578 | | -'emailsubject' => 'Subject:', |
2579 | | -'emailmessage' => 'Message:', |
2580 | | -'emailsend' => 'Send', |
2581 | | -'emailccme' => 'E-mail me a copy of my message.', |
2582 | | -'emailccsubject' => 'Copy of your message to $1: $2', |
2583 | | -'emailsent' => 'E-mail sent', |
2584 | | -'emailsenttext' => 'Your e-mail message has been sent.', |
2585 | | -'emailuserfooter' => 'This e-mail was sent by $1 to $2 by the "E-mail user" function at {{SITENAME}}.', |
| 2569 | +'usermailererror' => 'Mail object returned error:', |
| 2570 | +'defemailsubject' => '{{SITENAME}} e-mail', |
| 2571 | +'usermaildisabled' => 'User email disabled', |
| 2572 | +'usermaildisabledtext' => 'You cannot send email to other users on this wiki', |
| 2573 | +'noemailtitle' => 'No e-mail address', |
| 2574 | +'noemailtext' => 'This user has not specified a valid e-mail address.', |
| 2575 | +'nowikiemailtitle' => 'No e-mail allowed', |
| 2576 | +'nowikiemailtext' => 'This user has chosen not to receive e-mail from other users.', |
| 2577 | +'email-legend' => 'Send an e-mail to another {{SITENAME}} user', |
| 2578 | +'emailfrom' => 'From:', |
| 2579 | +'emailto' => 'To:', |
| 2580 | +'emailsubject' => 'Subject:', |
| 2581 | +'emailmessage' => 'Message:', |
| 2582 | +'emailsend' => 'Send', |
| 2583 | +'emailccme' => 'E-mail me a copy of my message.', |
| 2584 | +'emailccsubject' => 'Copy of your message to $1: $2', |
| 2585 | +'emailsent' => 'E-mail sent', |
| 2586 | +'emailsenttext' => 'Your e-mail message has been sent.', |
| 2587 | +'emailuserfooter' => 'This e-mail was sent by $1 to $2 by the "E-mail user" function at {{SITENAME}}.', |
2586 | 2588 | |
2587 | 2589 | # Watchlist |
2588 | 2590 | 'watchlist' => 'My watchlist', |
— | — | @@ -4238,6 +4240,7 @@ |
4239 | 4241 | 'htmlform-float-invalid' => 'The value you specified is not a number.', |
4240 | 4242 | 'htmlform-int-toolow' => 'The value you specified is below the minimum of $1', |
4241 | 4243 | 'htmlform-int-toohigh' => 'The value you specified is above the maximum of $1', |
| 4244 | +'htmlform-required' => 'This value is required', |
4242 | 4245 | 'htmlform-submit' => 'Submit', |
4243 | 4246 | 'htmlform-reset' => 'Undo changes', |
4244 | 4247 | 'htmlform-selectorother-other' => 'Other', |