Index: trunk/extensions/Nuke/Nuke_body.php |
— | — | @@ -7,9 +7,7 @@ |
8 | 8 | } |
9 | 9 | |
10 | 10 | public function execute( $par ){ |
11 | | - global $wgUser, $wgRequest; |
12 | | - |
13 | | - if( !$this->userCanExecute( $wgUser ) ){ |
| 11 | + if( !$this->userCanExecute( $this->getUser() ) ){ |
14 | 12 | $this->displayRestrictionError(); |
15 | 13 | return; |
16 | 14 | } |
— | — | @@ -17,15 +15,17 @@ |
18 | 16 | $this->setHeaders(); |
19 | 17 | $this->outputHeader(); |
20 | 18 | |
21 | | - $target = trim( $wgRequest->getText( 'target', $par ) ); |
| 19 | + $req = $this->getRequest(); |
22 | 20 | |
| 21 | + $target = trim( $req->getText( 'target', $par ) ); |
| 22 | + |
23 | 23 | // Normalise name |
24 | 24 | if ( $target !== '' ) { |
25 | 25 | $user = User::newFromName( $target ); |
26 | 26 | if ( $user ) $target = $user->getName(); |
27 | 27 | } |
28 | 28 | |
29 | | - $reason = $wgRequest->getText( |
| 29 | + $reason = $req->getText( |
30 | 30 | 'wpReason', |
31 | 31 | wfMsgForContent( |
32 | 32 | 'nuke-defaultreason', |
— | — | @@ -33,19 +33,18 @@ |
34 | 34 | ) |
35 | 35 | ); |
36 | 36 | |
37 | | - if( $wgRequest->wasPosted() |
38 | | - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 37 | + if( $req->wasPosted() |
| 38 | + && $this->getUser()->matchEditToken( $req->getVal( 'wpEditToken' ) ) ) { |
39 | 39 | |
40 | | - |
41 | | - if ( $wgRequest->getVal( 'action' ) == 'delete' ) { |
42 | | - $pages = $wgRequest->getArray( 'pages' ); |
| 40 | + if ( $req->getVal( 'action' ) == 'delete' ) { |
| 41 | + $pages = $req->getArray( 'pages' ); |
43 | 42 | |
44 | 43 | if( $pages ) { |
45 | 44 | return $this->doDelete( $pages, $reason ); |
46 | 45 | } |
47 | 46 | } |
48 | | - else if ( $wgRequest->getVal( 'action' ) == 'submit' ) { |
49 | | - $this->listForm( $target, $reason, $wgRequest->getInt( 'limit', 500 ) ); |
| 47 | + else if ( $req->getVal( 'action' ) == 'submit' ) { |
| 48 | + $this->listForm( $target, $reason, $req->getInt( 'limit', 500 ) ); |
50 | 49 | } |
51 | 50 | else { |
52 | 51 | $this->promptForm(); |
— | — | @@ -55,7 +54,7 @@ |
56 | 55 | $this->promptForm(); |
57 | 56 | } |
58 | 57 | else { |
59 | | - $this->listForm( $target, $reason, $wgRequest->getInt( 'limit', 500 ) ); |
| 58 | + $this->listForm( $target, $reason, $req->getInt( 'limit', 500 ) ); |
60 | 59 | } |
61 | 60 | } |
62 | 61 | |
— | — | @@ -63,11 +62,11 @@ |
64 | 63 | * Prompt for a username or IP address. |
65 | 64 | */ |
66 | 65 | protected function promptForm( $userName = '' ) { |
67 | | - global $wgOut, $wgUser; |
| 66 | + $out = $this->getOutput(); |
| 67 | + |
| 68 | + $out->addWikiMsg( 'nuke-tools' ); |
68 | 69 | |
69 | | - $wgOut->addWikiMsg( 'nuke-tools' ); |
70 | | - |
71 | | - $wgOut->addHTML( |
| 70 | + $out->addHTML( |
72 | 71 | Xml::openElement( |
73 | 72 | 'form', |
74 | 73 | array( |
— | — | @@ -88,7 +87,7 @@ |
89 | 88 | . '<td></td>' |
90 | 89 | . '<td>' . Xml::submitButton( wfMsg( 'nuke-submit-user' ) ) . '</td>' |
91 | 90 | .'</tr></table>' |
92 | | - . Html::hidden( 'wpEditToken', $wgUser->editToken() ) |
| 91 | + . Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) |
93 | 92 | . Xml::closeElement( 'form' ) |
94 | 93 | ); |
95 | 94 | } |
— | — | @@ -101,25 +100,25 @@ |
102 | 101 | * @param integer $limit |
103 | 102 | */ |
104 | 103 | protected function listForm( $username, $reason, $limit ) { |
105 | | - global $wgUser, $wgOut, $wgLang; |
106 | | - |
| 104 | + $out = $this->getOutput(); |
| 105 | + |
107 | 106 | $pages = $this->getNewPages( $username, $limit ); |
108 | 107 | |
109 | 108 | if( count( $pages ) == 0 ) { |
110 | 109 | if ( $username === '' ) { |
111 | | - $wgOut->addWikiMsg( 'nuke-nopages-global' ); |
| 110 | + $out->addWikiMsg( 'nuke-nopages-global' ); |
112 | 111 | } |
113 | 112 | else { |
114 | | - $wgOut->addWikiMsg( 'nuke-nopages', $username ); |
| 113 | + $out->addWikiMsg( 'nuke-nopages', $username ); |
115 | 114 | } |
116 | 115 | |
117 | 116 | return $this->promptForm( $username ); |
118 | 117 | } |
119 | 118 | |
120 | 119 | if ( $username === '' ) { |
121 | | - $wgOut->addWikiMsg( 'nuke-list-multiple' ); |
| 120 | + $out->addWikiMsg( 'nuke-list-multiple' ); |
122 | 121 | } else { |
123 | | - $wgOut->addWikiMsg( 'nuke-list', $username ); |
| 122 | + $out->addWikiMsg( 'nuke-list', $username ); |
124 | 123 | } |
125 | 124 | |
126 | 125 | $nuke = $this->getTitle(); |
— | — | @@ -136,15 +135,15 @@ |
137 | 136 | } |
138 | 137 | </script> |
139 | 138 | JAVASCRIPT; |
140 | | - $wgOut->addScript( $script ); |
| 139 | + $out->addScript( $script ); |
141 | 140 | |
142 | | - $wgOut->addHTML( |
| 141 | + $out->addHTML( |
143 | 142 | Xml::openElement( 'form', array( |
144 | 143 | 'action' => $nuke->getLocalURL( 'action=delete' ), |
145 | 144 | 'method' => 'post', |
146 | 145 | 'name' => 'nukelist') |
147 | 146 | ) . |
148 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 147 | + Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) . |
149 | 148 | Xml::tags( 'p', |
150 | 149 | null, |
151 | 150 | Xml::inputLabel( |
— | — | @@ -159,28 +158,28 @@ |
160 | 159 | wfMsg( 'powersearch-toggleall' ) . '</a>'; |
161 | 160 | $links[] = '<a href="#" onclick="selectPages( false ); return false;">' . |
162 | 161 | wfMsg( 'powersearch-togglenone' ) . '</a>'; |
163 | | - $wgOut->addHTML( |
| 162 | + $out->addHTML( |
164 | 163 | Xml::tags( 'p', |
165 | 164 | null, |
166 | | - wfMsg( 'nuke-select', $wgLang->commaList( $links ) ) |
| 165 | + wfMsg( 'nuke-select', $this->getLang()->commaList( $links ) ) |
167 | 166 | ) |
168 | 167 | ); |
169 | 168 | |
170 | 169 | // Delete button |
171 | | - $wgOut->addHTML( |
| 170 | + $out->addHTML( |
172 | 171 | Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) |
173 | 172 | ); |
174 | 173 | |
175 | | - $wgOut->addHTML( '<ul>' ); |
| 174 | + $out->addHTML( '<ul>' ); |
176 | 175 | |
177 | 176 | foreach( $pages as $info ) { |
178 | 177 | list( $title, $edits, $userName ) = $info; |
179 | 178 | $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false; |
180 | 179 | $thumb = $image && $image->exists() ? $image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false; |
181 | 180 | |
182 | | - $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) ); |
| 181 | + $changes = wfMsgExt( 'nchanges', 'parsemag', $this->getLang()->formatNum( $edits ) ); |
183 | 182 | |
184 | | - $wgOut->addHTML( '<li>' . |
| 183 | + $out->addHTML( '<li>' . |
185 | 184 | Xml::check( 'pages[]', true, |
186 | 185 | array( 'value' => $title->getPrefixedDbKey() ) |
187 | 186 | ) . |
— | — | @@ -193,7 +192,7 @@ |
194 | 193 | ")</li>\n" ); |
195 | 194 | } |
196 | 195 | |
197 | | - $wgOut->addHTML( |
| 196 | + $out->addHTML( |
198 | 197 | "</ul>\n" . |
199 | 198 | Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) . |
200 | 199 | "</form>" |
— | — | @@ -262,9 +261,8 @@ |
263 | 262 | * @param string $reason |
264 | 263 | */ |
265 | 264 | protected function doDelete( array $pages, $reason ) { |
266 | | - global $wgOut; |
267 | | - |
268 | 265 | $res = array(); |
| 266 | + |
269 | 267 | foreach( $pages as $page ) { |
270 | 268 | $title = Title::newFromURL( $page ); |
271 | 269 | $file = $title->getNamespace() == NS_FILE ? wfLocalFile( $title ) : false; |
— | — | @@ -282,9 +280,9 @@ |
283 | 281 | } |
284 | 282 | } |
285 | 283 | |
286 | | - $wgOut->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $res ) . "</li>\n</ul>\n" ); |
| 284 | + $this->getOutput()->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $res ) . "</li>\n</ul>\n" ); |
287 | 285 | |
288 | | - $wgOut->addWikiMsg( 'nuke-delete-more' ); |
| 286 | + $this->getOutput()->addWikiMsg( 'nuke-delete-more' ); |
289 | 287 | } |
290 | 288 | |
291 | 289 | } |