Index: trunk/extensions/Notificator/Notificator.body.php |
— | — | @@ -22,29 +22,52 @@ |
23 | 23 | return array( $output, 'noparse' => true, 'isHTML' => true ); |
24 | 24 | } |
25 | 25 | |
| 26 | + // The rendering is different, depending on whether a valid e-mail address |
| 27 | + // has been provided, or not - the differing part of the HTML form is being |
| 28 | + // built here |
26 | 29 | if ( Notificator::receiverIsValid( $receiver ) ) { |
27 | | - // Valid e-mail address available, so just show a button |
28 | | - $output = '<form action="' . $wgScript . |
29 | | - '/Special:Notificator" method="post" enctype="multipart/form-data"> |
30 | | -<input type="hidden" name="pageId" value="' . $wgTitle->getArticleID() . '" /> |
31 | | -<input type="hidden" name="revId" value="' . $wgTitle->getLatestRevID() . '" /> |
32 | | -<input type="hidden" name="receiver" value="' . $receiver . '" /> |
33 | | -<input type="submit" value="' . |
34 | | -wfMsg( 'notificator-notify-address-or-name', htmlspecialchars( $receiverLabel ) ) . '" /> |
35 | | -</form>'; |
| 30 | + // Valid e-mail address available, so build a hidden input with that address |
| 31 | + // set, and a button |
| 32 | + $receiverInputAndSubmitButton = Html::hidden( receiver, $receiver ) . |
| 33 | + Html::element( |
| 34 | + 'input', |
| 35 | + array( 'type' => 'submit', |
| 36 | + 'value' => wfMsg( 'notificator-notify-address-or-name', $receiverLabel ) |
| 37 | + ) |
| 38 | + ); |
36 | 39 | } else { |
37 | | - // No valid e-mail address available, show text entry field and button |
38 | | - $output = '<form action="' . $wgScript . |
39 | | - '/Special:Notificator" method="post" enctype="multipart/form-data"> |
40 | | -<input type="hidden" name="pageId" value="' . $wgTitle->getArticleID() . '" /> |
41 | | -<input type="hidden" name="revId" value="' . $wgTitle->getLatestRevID() . '" /> |
42 | | -<input type="text" name="receiver" value="' . wfMsg( 'notificator-e-mail-address' ) . |
43 | | -'" onfocus="if (this.value == \'' . wfMsg( 'notificator-e-mail-address' ) . |
44 | | -'\') {this.value=\'\'}" /> |
45 | | -<input type="submit" value="' . wfMsg( 'notificator-notify' ) . '" /> |
46 | | -</form>'; |
| 40 | + // No (valid) e-mail address available, build a text input and a button |
| 41 | + $receiverInputAndSubmitButton = Html::element( |
| 42 | + 'input', |
| 43 | + array( 'type' => 'text', |
| 44 | + 'name' => 'receiver', |
| 45 | + 'value' => wfMsg( 'notificator-e-mail-address' ), |
| 46 | + 'onfocus' => 'if (this.value == \'' . |
| 47 | + wfMsg( 'notificator-e-mail-address' ) . |
| 48 | + '\') {this.value=\'\'}' |
| 49 | + ) |
| 50 | + ) . |
| 51 | + Html::element( |
| 52 | + 'input', |
| 53 | + array( 'type' => 'submit', |
| 54 | + 'value' => wfMsg( 'notificator-notify' ) |
| 55 | + ) |
| 56 | + ); |
47 | 57 | } |
48 | 58 | |
| 59 | + // Now we assemble the form, consisting of two hidden inputs for page ID and rev ID, |
| 60 | + // as well as the $receiverInputAndSubmitButton built above |
| 61 | + $output = Html::rawElement( |
| 62 | + 'form', |
| 63 | + array( 'action' => SpecialPage::getTitleFor( 'Notificator' )->getLocalURL(), |
| 64 | + 'method' => 'post', |
| 65 | + 'enctype' => 'multipart/form-data' |
| 66 | + ), |
| 67 | + Html::hidden( pageId, $wgTitle->getArticleID() ) . |
| 68 | + Html::hidden( revId, $wgTitle->getLatestRevID() ) . |
| 69 | + $receiverInputAndSubmitButton |
| 70 | + ); |
| 71 | + |
49 | 72 | return $parser->insertStripItem( $output, $parser->mStripState ); |
50 | 73 | } |
51 | 74 | |