Index: trunk/extensions/Nuke/SpecialNuke_body.php |
— | — | @@ -21,6 +21,13 @@ |
22 | 22 | $this->outputHeader(); |
23 | 23 | |
24 | 24 | $target = $wgRequest->getText( 'target', $par ); |
| 25 | + |
| 26 | + // Normalise name |
| 27 | + if ( $target !== '' ) { |
| 28 | + $user = User::newFromName( $target ); |
| 29 | + if ( $user ) $target = $user->getName(); |
| 30 | + } |
| 31 | + |
25 | 32 | $reason = $wgRequest->getText( 'wpReason', |
26 | 33 | wfMsgForContent( 'nuke-defaultreason', $target ) ); |
27 | 34 | $posted = $wgRequest->wasPosted() && |
— | — | @@ -39,22 +46,18 @@ |
40 | 47 | } |
41 | 48 | |
42 | 49 | function promptForm() { |
43 | | - global $wgUser, $wgOut; |
44 | | - $sk =& $wgUser->getSkin(); |
| 50 | + global $wgOut; |
45 | 51 | |
46 | | - $nuke = Title::makeTitle( NS_SPECIAL, 'Nuke' ); |
47 | | - $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-user' ) ) ); |
| 52 | + $input = Xml::input( 'target', 40 ); |
| 53 | + $submit = Xml::submitButton( wfMsg( 'nuke-submit-user' ) ); |
48 | 54 | |
49 | | - $wgOut->addWikiText( wfMsg( 'nuke-tools' ) ); |
50 | | - $wgOut->addHTML( Xml::element( 'form', array( |
51 | | - 'action' => $nuke->getLocalURL( 'action=submit' ), |
52 | | - 'method' => 'post' ), |
53 | | - null ) . |
54 | | - Xml::element( 'input', array( |
55 | | - 'type' => 'text', |
56 | | - 'size' => 40, |
57 | | - 'name' => 'target' ) ) . |
58 | | - "\n$submit\n" ); |
| 55 | + $wgOut->addWikiMsg( 'nuke-tools' ); |
| 56 | + $wgOut->addHTML( |
| 57 | + Xml::openElement( 'form', array( |
| 58 | + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), |
| 59 | + 'method' => 'post' ) |
| 60 | + ) . "$input\n$submit\n" |
| 61 | + ); |
59 | 62 | |
60 | 63 | $wgOut->addHTML( "</form>" ); |
61 | 64 | } |
— | — | @@ -63,54 +66,54 @@ |
64 | 67 | global $wgUser, $wgOut, $wgLang; |
65 | 68 | |
66 | 69 | $pages = $this->getNewPages( $username ); |
67 | | - $escapedName = wfEscapeWikiText( $username ); |
| 70 | + |
68 | 71 | if( count( $pages ) == 0 ) { |
69 | | - $wgOut->addWikiText( wfMsg( 'nuke-nopages', $escapedName ) ); |
| 72 | + $wgOut->addWikiMsg( 'nuke-nopages', $username ); |
70 | 73 | return $this->promptForm(); |
71 | 74 | } |
72 | | - $wgOut->addWikiText( wfMsg( 'nuke-list', $escapedName ) ); |
| 75 | + $wgOut->addWikiMsg( 'nuke-list', $username ); |
73 | 76 | |
74 | 77 | $nuke = $this->getTitle(); |
75 | | - $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-delete' ) ) ); |
| 78 | + $submit = Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ); |
76 | 79 | |
77 | | - $wgOut->addHTML( Xml::element( 'form', array( |
78 | | - 'action' => $nuke->getLocalURL( 'action=delete' ), |
79 | | - 'method' => 'post' ), |
80 | | - null ) . |
81 | | - "\n<div>" . |
82 | | - wfMsgHtml( 'deletecomment' ) . ' ' . |
83 | | - Xml::element( 'input', array( |
84 | | - 'name' => 'wpReason', |
85 | | - 'value' => $reason, |
86 | | - 'size' => 60 ) ) . |
87 | | - "</div><br />" . |
88 | | - $submit . |
89 | | - Xml::element( 'input', array( |
90 | | - 'type' => 'hidden', |
91 | | - 'name' => 'wpEditToken', |
92 | | - 'value' => $wgUser->editToken() ) ) . |
93 | | - "\n<ul>\n" ); |
| 80 | + $wgOut->addHTML( |
| 81 | + Xml::openElement( 'form', array( |
| 82 | + 'action' => $nuke->getLocalURL( 'action=delete' ), |
| 83 | + 'method' => 'post' ) |
| 84 | + ) . |
| 85 | + Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 86 | + Xml::inputLabel( |
| 87 | + wfMsg( 'deletecomment' ), 'wpReason', 'wpReason', 60, $reason |
| 88 | + ) . '<br /><br />' . |
| 89 | + Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) |
| 90 | + ); |
94 | 91 | |
95 | | - $sk =& $wgUser->getSkin(); |
| 92 | + $wgOut->addHTML( '<ul>' ); |
| 93 | + |
| 94 | + $sk = $wgUser->getSkin(); |
96 | 95 | foreach( $pages as $info ) { |
97 | 96 | list( $title, $edits ) = $info; |
98 | 97 | $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false; |
99 | 98 | $thumb = $image && $image->exists() ? $image->getThumbnail( 120, 120 ) : false; |
| 99 | + |
| 100 | + $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) ); |
100 | 101 | |
101 | 102 | $wgOut->addHTML( '<li>' . |
102 | | - Xml::element( 'input', array( |
103 | | - 'type' => 'checkbox', |
104 | | - 'name' => "pages[]", |
105 | | - 'value' => $title->getPrefixedDbKey(), |
106 | | - 'checked' => 'checked' ) ) . |
| 103 | + Xml::check( 'pages[]', true, |
| 104 | + array( 'value' => $title->getPrefixedDbKey() ) |
| 105 | + ) . |
107 | 106 | ' ' . |
108 | 107 | ( $thumb ? $thumb->toHtml( array( 'desc-link' => true ) ) : '' ) . |
109 | 108 | $sk->makeKnownLinkObj( $title ) . |
110 | 109 | ' (' . |
111 | | - $sk->makeKnownLinkObj( $title, wfMsgExt( 'nchanges', array( 'parsemag' ), $wgLang->formatNum( $edits ) ), 'action=history' ) . |
| 110 | + $sk->makeKnownLinkObj( $title, $changes, 'action=history' ) . |
112 | 111 | ")</li>\n" ); |
113 | 112 | } |
114 | | - $wgOut->addHTML( "</ul>\n$submit</form>" ); |
| 113 | + $wgOut->addHTML( |
| 114 | + "</ul>\n" . |
| 115 | + Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) . |
| 116 | + "</form>" |
| 117 | + ); |
115 | 118 | } |
116 | 119 | |
117 | 120 | function getNewPages( $username ) { |