Index: trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php |
— | — | @@ -22,32 +22,33 @@ |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function execute( $parameter ) { |
26 | | - global $wgUser, $wgOut, $wgRequest; |
| 26 | + $out = $this->getOutput(); |
| 27 | + $request = $this->getRequest(); |
27 | 28 | |
28 | | - AbuseFilter::addNavigationLinks( $wgOut, $wgUser->getSkin(), 'log' ); |
| 29 | + AbuseFilter::addNavigationLinks( $out, $this->getSkin(), 'log' ); |
29 | 30 | |
30 | 31 | $this->setHeaders(); |
31 | 32 | $this->outputHeader( 'abusefilter-log-summary' ); |
32 | 33 | $this->loadParameters(); |
33 | 34 | |
34 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-log' ) ); |
35 | | - $wgOut->setRobotPolicy( "noindex,nofollow" ); |
36 | | - $wgOut->setArticleRelated( false ); |
37 | | - $wgOut->enableClientCache( false ); |
| 35 | + $out->setPageTitle( $this->msg( 'abusefilter-log' ) ); |
| 36 | + $out->setRobotPolicy( "noindex,nofollow" ); |
| 37 | + $out->setArticleRelated( false ); |
| 38 | + $out->enableClientCache( false ); |
38 | 39 | |
39 | | - $wgOut->addModuleStyles( 'ext.abuseFilter' ); |
| 40 | + $out->addModuleStyles( 'ext.abuseFilter' ); |
40 | 41 | |
41 | 42 | // Are we allowed? |
42 | 43 | $errors = $this->getTitle()->getUserPermissionsErrors( |
43 | | - 'abusefilter-log', $wgUser, true, array( 'ns-specialprotected' ) ); |
| 44 | + 'abusefilter-log', $this->getUser(), true, array( 'ns-specialprotected' ) ); |
44 | 45 | if ( count( $errors ) ) { |
45 | 46 | // Go away. |
46 | | - $wgOut->showPermissionsErrorPage( $errors, 'abusefilter-log' ); |
| 47 | + $out->showPermissionsErrorPage( $errors, 'abusefilter-log' ); |
47 | 48 | return; |
48 | 49 | } |
49 | 50 | |
50 | | - $detailsid = $wgRequest->getIntOrNull( 'details' ); |
51 | | - $hideid = $wgRequest->getIntOrNull( 'hide' ); |
| 51 | + $detailsid = $request->getIntOrNull( 'details' ); |
| 52 | + $hideid = $request->getIntOrNull( 'hide' ); |
52 | 53 | |
53 | 54 | if ( $parameter ) { |
54 | 55 | $detailsid = $parameter; |
— | — | @@ -67,9 +68,9 @@ |
68 | 69 | } |
69 | 70 | |
70 | 71 | function loadParameters() { |
71 | | - global $wgRequest; |
| 72 | + $request = $this->getRequest(); |
72 | 73 | |
73 | | - $this->mSearchUser = $wgRequest->getText( 'wpSearchUser' ); |
| 74 | + $this->mSearchUser = $request->getText( 'wpSearchUser' ); |
74 | 75 | |
75 | 76 | $t = Title::newFromText( trim( $this->mSearchUser ) ); |
76 | 77 | if ( $t ) { |
— | — | @@ -78,23 +79,21 @@ |
79 | 80 | $this->mSearchUser = null; |
80 | 81 | } |
81 | 82 | |
82 | | - $this->mSearchTitle = $wgRequest->getText( 'wpSearchTitle' ); |
| 83 | + $this->mSearchTitle = $request->getText( 'wpSearchTitle' ); |
83 | 84 | $this->mSearchFilter = null; |
84 | | - if ( self::canSeeDetails() ) { |
85 | | - $this->mSearchFilter = $wgRequest->getIntOrNull( 'wpSearchFilter' ); |
| 85 | + if ( self::canSeeDetails( $this->getUser() ) ) { |
| 86 | + $this->mSearchFilter = $request->getIntOrNull( 'wpSearchFilter' ); |
86 | 87 | } |
87 | 88 | } |
88 | 89 | |
89 | 90 | function searchForm() { |
90 | | - global $wgOut; |
91 | | - |
92 | 91 | $output = Xml::element( 'legend', null, wfMsg( 'abusefilter-log-search' ) ); |
93 | 92 | $fields = array(); |
94 | 93 | |
95 | 94 | // Search conditions |
96 | 95 | $fields['abusefilter-log-search-user'] = |
97 | 96 | Xml::input( 'wpSearchUser', 45, $this->mSearchUser ); |
98 | | - if ( self::canSeeDetails() ) { |
| 97 | + if ( self::canSeeDetails( $this->getUser() ) ) { |
99 | 98 | $fields['abusefilter-log-search-filter'] = |
100 | 99 | Xml::input( 'wpSearchFilter', 45, $this->mSearchFilter ); |
101 | 100 | } |
— | — | @@ -109,14 +108,12 @@ |
110 | 109 | $form ); |
111 | 110 | $output = Xml::tags( 'fieldset', null, $output ); |
112 | 111 | |
113 | | - $wgOut->addHTML( $output ); |
| 112 | + $this->getOutput()->addHTML( $output ); |
114 | 113 | } |
115 | 114 | |
116 | 115 | function showHideForm( $id ) { |
117 | | - global $wgOut, $wgUser; |
118 | | - |
119 | | - if ( !$wgUser->isAllowed( 'abusefilter-hide-log' ) ) { |
120 | | - $wgOut->addWikiMsg( 'abusefilter-log-hide-forbidden' ); |
| 116 | + if ( !$this->getUser()->isAllowed( 'abusefilter-hide-log' ) ) { |
| 117 | + $this->getOutput()->addWikiMsg( 'abusefilter-log-hide-forbidden' ); |
121 | 118 | return; |
122 | 119 | } |
123 | 120 | |
— | — | @@ -152,7 +149,7 @@ |
153 | 150 | ), |
154 | 151 | ); |
155 | 152 | |
156 | | - $form = new HTMLForm( $formInfo ); |
| 153 | + $form = new HTMLForm( $formInfo, $this->getContext() ); |
157 | 154 | $form->setTitle( $this->getTitle() ); |
158 | 155 | $form->setWrapperLegend( wfMsgExt( 'abusefilter-log-hide-legend', 'parsemag' ) ); |
159 | 156 | $form->addHiddenField( 'hide', $id ); |
— | — | @@ -161,8 +158,7 @@ |
162 | 159 | } |
163 | 160 | |
164 | 161 | function saveHideForm( $fields ) { |
165 | | - global $wgRequest, $wgOut; |
166 | | - $logid = $wgRequest->getVal( 'hide' ); |
| 162 | + $logid = $this->getRequest()->getVal( 'hide' ); |
167 | 163 | |
168 | 164 | $dbw = wfGetDB( DB_MASTER ); |
169 | 165 | |
— | — | @@ -178,13 +174,13 @@ |
179 | 175 | |
180 | 176 | $logPage->addEntry( $action, $this->getTitle( $logid ), $fields['reason'] ); |
181 | 177 | |
182 | | - $wgOut->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() ); |
| 178 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() ); |
183 | 179 | |
184 | 180 | return true; |
185 | 181 | } |
186 | 182 | |
187 | 183 | function showList() { |
188 | | - global $wgOut; |
| 184 | + $out = $this->getOutput(); |
189 | 185 | |
190 | 186 | // Generate conditions list. |
191 | 187 | $conds = array(); |
— | — | @@ -216,16 +212,17 @@ |
217 | 213 | $pager->doQuery(); |
218 | 214 | $result = $pager->getResult(); |
219 | 215 | if( $result && $result->numRows() !== 0 ) { |
220 | | - $wgOut->addHTML( $pager->getNavigationBar() . |
| 216 | + $out->addHTML( $pager->getNavigationBar() . |
221 | 217 | Xml::tags( 'ul', null, $pager->getBody() ) . |
222 | 218 | $pager->getNavigationBar() ); |
223 | 219 | } else { |
224 | | - $wgOut->addWikiMsg( 'abusefilter-log-noresults' ); |
| 220 | + $out->addWikiMsg( 'abusefilter-log-noresults' ); |
225 | 221 | } |
226 | 222 | } |
227 | 223 | |
228 | 224 | function showDetails( $id ) { |
229 | | - if ( !self::canSeeDetails() ) { |
| 225 | + $out = $this->getOutput(); |
| 226 | + if ( !self::canSeeDetails( $this->getUser() ) ) { |
230 | 227 | return; |
231 | 228 | } |
232 | 229 | |
— | — | @@ -244,9 +241,8 @@ |
245 | 242 | return; |
246 | 243 | } |
247 | 244 | |
248 | | - if ( $row->afl_deleted && !self::canSeeHidden() ) { |
249 | | - global $wgOut; |
250 | | - $wgOut->addWikiMsg( 'abusefilter-log-details-hidden' ); |
| 245 | + if ( $row->afl_deleted && !self::canSeeHidden( $this->getUser() ) ) { |
| 246 | + $out->addWikiMsg( 'abusefilter-log-details-hidden' ); |
251 | 247 | return; |
252 | 248 | } |
253 | 249 | |
— | — | @@ -291,7 +287,7 @@ |
292 | 288 | // Build a table. |
293 | 289 | $output .= AbuseFilter::buildVarDumpTable( $vars ); |
294 | 290 | |
295 | | - if ( self::canSeePrivate() ) { |
| 291 | + if ( self::canSeePrivate( $this->getUser() ) ) { |
296 | 292 | // Private stuff, like IPs. |
297 | 293 | $header = |
298 | 294 | Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-var' ) ) . |
— | — | @@ -322,46 +318,42 @@ |
323 | 319 | |
324 | 320 | $output = Xml::tags( 'fieldset', null, $output ); |
325 | 321 | |
326 | | - global $wgOut; |
327 | | - $wgOut->addHTML( $output ); |
| 322 | + $out->addHTML( $output ); |
328 | 323 | } |
329 | 324 | |
330 | 325 | /** |
| 326 | + * @param $user User |
331 | 327 | * @return bool |
332 | 328 | */ |
333 | | - static function canSeeDetails() { |
334 | | - global $wgUser; |
335 | | - return $wgUser->isAllowed( 'abusefilter-log-detail' ); |
| 329 | + static function canSeeDetails( User $user ) { |
| 330 | + return $user->isAllowed( 'abusefilter-log-detail' ); |
336 | 331 | } |
337 | 332 | |
338 | 333 | /** |
| 334 | + * @param $user User |
339 | 335 | * @return bool |
340 | 336 | */ |
341 | | - static function canSeePrivate() { |
| 337 | + static function canSeePrivate( User $user ) { |
342 | 338 | global $wgUser; |
343 | 339 | return $wgUser->isAllowed( 'abusefilter-private' ); |
344 | 340 | } |
345 | 341 | |
346 | 342 | /** |
| 343 | + * @param $user User |
347 | 344 | * @return bool |
348 | 345 | */ |
349 | | - static function canSeeHidden() { |
| 346 | + static function canSeeHidden( User $user ) { |
350 | 347 | global $wgUser; |
351 | 348 | return $wgUser->isAllowed( 'abusefilter-hidden-log' ); |
352 | 349 | } |
353 | 350 | |
354 | 351 | function formatRow( $row, $li = true ) { |
355 | | - global $wgLang, $wgUser; |
| 352 | + $user = $this->getUser(); |
| 353 | + $sk = $this->getSkin(); |
| 354 | + $lang = $this->getLang(); |
356 | 355 | |
357 | | - # One-time setup |
358 | | - static $sk = null; |
359 | | - |
360 | 356 | $actionLinks = array(); |
361 | 357 | |
362 | | - if ( is_null( $sk ) ) { |
363 | | - $sk = $wgUser->getSkin(); |
364 | | - } |
365 | | - |
366 | 358 | $title = Title::makeTitle( $row->afl_namespace, $row->afl_title ); |
367 | 359 | |
368 | 360 | if ( !$row->afl_wiki ) { |
— | — | @@ -372,14 +364,14 @@ |
373 | 365 | |
374 | 366 | if ( !$row->afl_wiki ) { |
375 | 367 | // Local user |
376 | | - $user = $sk->userLink( $row->afl_user, $row->afl_user_text ) . |
| 368 | + $userLink = $sk->userLink( $row->afl_user, $row->afl_user_text ) . |
377 | 369 | $sk->userToolLinks( $row->afl_user, $row->afl_user_text ); |
378 | 370 | } else { |
379 | | - $user = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text ); |
380 | | - $user .= ' (' . WikiMap::getWikiName( $row->afl_wiki ) . ')'; |
| 371 | + $userLink = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text ); |
| 372 | + $userLink .= ' (' . WikiMap::getWikiName( $row->afl_wiki ) . ')'; |
381 | 373 | } |
382 | 374 | |
383 | | - $timestamp = $wgLang->timeanddate( $row->afl_timestamp, true ); |
| 375 | + $timestamp = $lang->timeanddate( $row->afl_timestamp, true ); |
384 | 376 | |
385 | 377 | $actions_taken = $row->afl_actions; |
386 | 378 | if ( !strlen( trim( $actions_taken ) ) ) { |
— | — | @@ -391,7 +383,7 @@ |
392 | 384 | foreach ( $actions as $action ) { |
393 | 385 | $displayActions[] = AbuseFilter::getActionDisplay( $action ); |
394 | 386 | } |
395 | | - $actions_taken = $wgLang->commaList( $displayActions ); |
| 387 | + $actions_taken = $lang->commaList( $displayActions ); |
396 | 388 | } |
397 | 389 | |
398 | 390 | $globalIndex = AbuseFilter::decodeGlobalName( $row->afl_filter ); |
— | — | @@ -405,7 +397,7 @@ |
406 | 398 | $parsed_comments = $wgOut->parseInline( $row->af_public_comments ); |
407 | 399 | } |
408 | 400 | |
409 | | - if ( self::canSeeDetails() ) { |
| 401 | + if ( self::canSeeDetails( $user ) ) { |
410 | 402 | $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id ); |
411 | 403 | $detailsLink = $sk->makeKnownLinkObj( |
412 | 404 | $this->getTitle($row->afl_id), |
— | — | @@ -420,7 +412,7 @@ |
421 | 413 | $actionLinks[] = $detailsLink; |
422 | 414 | $actionLinks[] = $examineLink; |
423 | 415 | |
424 | | - if ( $wgUser->isAllowed( 'abusefilter-hide-log' ) ) { |
| 416 | + if ( $user->isAllowed( 'abusefilter-hide-log' ) ) { |
425 | 417 | $hideLink = $sk->link( |
426 | 418 | $this->getTitle(), |
427 | 419 | wfMsg( 'abusefilter-log-hidelink' ), |
— | — | @@ -448,13 +440,13 @@ |
449 | 441 | array( 'parseinline', 'replaceafter' ), |
450 | 442 | array( |
451 | 443 | $timestamp, |
452 | | - $user, |
| 444 | + $userLink, |
453 | 445 | $filterLink, |
454 | 446 | $row->afl_action, |
455 | 447 | $pageLink, |
456 | 448 | $actions_taken, |
457 | 449 | $parsed_comments, |
458 | | - $wgLang->pipeList( $actionLinks ), |
| 450 | + $lang->pipeList( $actionLinks ), |
459 | 451 | ) |
460 | 452 | ); |
461 | 453 | } else { |
— | — | @@ -463,7 +455,7 @@ |
464 | 456 | array( 'parseinline', 'replaceafter' ), |
465 | 457 | array( |
466 | 458 | $timestamp, |
467 | | - $user, |
| 459 | + $userLink, |
468 | 460 | $row->afl_action, |
469 | 461 | $sk->link( $title ), |
470 | 462 | $actions_taken, |
Index: trunk/extensions/AbuseFilter/special/SpecialAbuseFilter.php |
— | — | @@ -4,37 +4,32 @@ |
5 | 5 | } |
6 | 6 | |
7 | 7 | class SpecialAbuseFilter extends SpecialPage { |
8 | | - var $mSkin; |
9 | | - |
10 | 8 | public function __construct() { |
11 | 9 | parent::__construct( 'AbuseFilter', 'abusefilter-view' ); |
12 | 10 | } |
13 | 11 | |
14 | 12 | public function execute( $subpage ) { |
15 | | - global $wgUser, $wgOut, $wgRequest; |
| 13 | + $out = $this->getOutput(); |
| 14 | + $request = $this->getRequest(); |
16 | 15 | |
17 | | - $wgOut->addModuleStyles( 'ext.abuseFilter' ); |
| 16 | + $out->addModuleStyles( 'ext.abuseFilter' ); |
18 | 17 | $view = 'AbuseFilterViewList'; |
19 | 18 | |
20 | 19 | $this->setHeaders(); |
21 | 20 | |
22 | 21 | $this->loadParameters( $subpage ); |
23 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-management' ) ); |
| 22 | + $out->setPageTitle( $this->msg( 'abusefilter-management' ) ); |
24 | 23 | |
25 | 24 | // Are we allowed? |
26 | | - if ( !$wgUser->isAllowed( 'abusefilter-view' ) ) { |
27 | | - $this->displayRestrictionError(); |
28 | | - return; |
29 | | - } |
| 25 | + $this->checkPermissions(); |
30 | 26 | |
31 | | - if ( $wgRequest->getVal( 'result' ) == 'success' ) { |
32 | | - $wgOut->setSubtitle( wfMsg( 'abusefilter-edit-done-subtitle' ) ); |
33 | | - $changedFilter = intval( $wgRequest->getVal( 'changedfilter' ) ); |
34 | | - $wgOut->wrapWikiMsg( '<p class="success">$1</p>', |
| 27 | + if ( $request->getVal( 'result' ) == 'success' ) { |
| 28 | + $out->setSubtitle( wfMsg( 'abusefilter-edit-done-subtitle' ) ); |
| 29 | + $changedFilter = intval( $request->getVal( 'changedfilter' ) ); |
| 30 | + $out->wrapWikiMsg( '<p class="success">$1</p>', |
35 | 31 | array( 'abusefilter-edit-done', $changedFilter ) ); |
36 | 32 | } |
37 | 33 | |
38 | | - $this->mSkin = $wgUser->getSkin(); |
39 | 34 | $this->mHistoryID = null; |
40 | 35 | $pageType = 'home'; |
41 | 36 | |
— | — | @@ -100,19 +95,17 @@ |
101 | 96 | } |
102 | 97 | |
103 | 98 | // Links at the top |
104 | | - AbuseFilter::addNavigationLinks( $wgOut, $this->mSkin, $pageType ); |
| 99 | + AbuseFilter::addNavigationLinks( $out, $this->getSkin(), $pageType ); |
105 | 100 | |
106 | 101 | $v = new $view( $this, $params ); |
107 | 102 | $v->show(); |
108 | 103 | } |
109 | 104 | |
110 | 105 | function loadParameters( $subpage ) { |
111 | | - global $wgRequest; |
112 | | - |
113 | 106 | $filter = $subpage; |
114 | 107 | |
115 | 108 | if ( !is_numeric( $filter ) && $filter != 'new' ) { |
116 | | - $filter = $wgRequest->getIntOrNull( 'wpFilter' ); |
| 109 | + $filter = $this->getRequest()->getIntOrNull( 'wpFilter' ); |
117 | 110 | } |
118 | 111 | $this->mFilter = $filter; |
119 | 112 | } |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewDiff.php |
— | — | @@ -10,9 +10,8 @@ |
11 | 11 | |
12 | 12 | function show() { |
13 | 13 | $show = $this->loadData(); |
| 14 | + $out = $this->getOutput(); |
14 | 15 | |
15 | | - global $wgOut, $wgLang; |
16 | | - |
17 | 16 | $links = array(); |
18 | 17 | if ( $this->mFilter ) { |
19 | 18 | $links['abusefilter-history-backedit'] = $this->getTitle( $this->mFilter ); |
— | — | @@ -23,24 +22,22 @@ |
24 | 23 | $links[$msg] = Linker::link( $title, wfMsgExt( $msg, 'parseinline' ) ); |
25 | 24 | } |
26 | 25 | |
27 | | - $backlinks = $wgLang->pipeList( $links ); |
28 | | - $wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
| 26 | + $backlinks = $this->getLang()->pipeList( $links ); |
| 27 | + $out->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
29 | 28 | |
30 | 29 | if ( $show ) { |
31 | | - $wgOut->addHTML( $this->formatDiff() ); |
| 30 | + $out->addHTML( $this->formatDiff() ); |
32 | 31 | } |
33 | 32 | } |
34 | 33 | |
35 | 34 | function loadData() { |
36 | | - global $wgUser; |
37 | 35 | $oldSpec = $this->mParams[3]; |
38 | 36 | $newSpec = $this->mParams[4]; |
39 | 37 | $this->mFilter = $this->mParams[1]; |
40 | 38 | |
41 | 39 | if ( AbuseFilter::filterHidden( $this->mFilter ) && |
42 | | - !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
43 | | - global $wgOut; |
44 | | - $wgOut->addWikiMsg( 'abusefilter-history-error-hidden' ); |
| 40 | + !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
| 41 | + $this->getOutput()->addWikiMsg( 'abusefilter-history-error-hidden' ); |
45 | 42 | return false; |
46 | 43 | } |
47 | 44 | |
— | — | @@ -48,8 +45,7 @@ |
49 | 46 | $this->mNewVersion = $this->loadSpec( $newSpec, $oldSpec ); |
50 | 47 | |
51 | 48 | if ( is_null( $this->mOldVersion ) || is_null( $this->mNewVersion ) ) { |
52 | | - global $wgOut; |
53 | | - $wgOut->addWikiMsg( 'abusefilter-diff-invalid' ); |
| 49 | + $this->getOutput()->addWikiMsg( 'abusefilter-diff-invalid' ); |
54 | 50 | return false; |
55 | 51 | } |
56 | 52 | |
— | — | @@ -153,10 +149,8 @@ |
154 | 150 | } |
155 | 151 | |
156 | 152 | function formatVersionLink( $timestamp, $history_id ) { |
157 | | - global $wgLang; |
158 | | - |
159 | 153 | $filter = $this->mFilter; |
160 | | - $text = $wgLang->timeanddate( $timestamp, true ); |
| 154 | + $text = $this->getLang()->timeanddate( $timestamp, true ); |
161 | 155 | $title = $this->getTitle( "history/$filter/item/$history_id" ); |
162 | 156 | |
163 | 157 | $link = Linker::link( $title, $text ); |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewImport.php |
— | — | @@ -2,13 +2,13 @@ |
3 | 3 | class AbuseFilterViewImport extends AbuseFilterView { |
4 | 4 | |
5 | 5 | function show() { |
6 | | - global $wgOut, $wgUser; |
7 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
8 | | - $wgOut->addWikiMsg( 'abusefilter-edit-notallowed' ); |
| 6 | + $out = $this->getOutput(); |
| 7 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
| 8 | + $out->addWikiMsg( 'abusefilter-edit-notallowed' ); |
9 | 9 | return; |
10 | 10 | } |
11 | 11 | |
12 | | - $wgOut->addWikiMsg( 'abusefilter-import-intro' ); |
| 12 | + $out->addWikiMsg( 'abusefilter-import-intro' ); |
13 | 13 | |
14 | 14 | $html = Xml::textarea( 'wpImportText', '', 40, 20 ); |
15 | 15 | $html .= Xml::submitButton( |
— | — | @@ -19,6 +19,6 @@ |
20 | 20 | |
21 | 21 | $html = Xml::tags( 'form', array( 'method' => 'post', 'action' => $url ), $html ); |
22 | 22 | |
23 | | - $wgOut->addHTML( $html ); |
| 23 | + $out->addHTML( $html ); |
24 | 24 | } |
25 | 25 | } |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php |
— | — | @@ -2,25 +2,26 @@ |
3 | 3 | |
4 | 4 | class AbuseFilterViewList extends AbuseFilterView { |
5 | 5 | function show() { |
6 | | - global $wgOut, $wgRequest; |
| 6 | + $out = $this->getOutput(); |
| 7 | + $request = $this->getRequest(); |
7 | 8 | |
8 | 9 | // Status info... |
9 | 10 | $this->showStatus(); |
10 | 11 | |
11 | | - $wgOut->addWikiMsg( 'abusefilter-intro' ); |
| 12 | + $out->addWikiMsg( 'abusefilter-intro' ); |
12 | 13 | |
13 | 14 | // New filter button |
14 | 15 | if ( $this->canEdit() ) { |
15 | 16 | $title = $this->getTitle( 'new' ); |
16 | 17 | $link = Linker::link( $title, wfMsg( 'abusefilter-new' ) ); |
17 | 18 | $links = Xml::tags( 'p', null, $link ) . "\n"; |
18 | | - $wgOut->addHTML( $links ); |
| 19 | + $out->addHTML( $links ); |
19 | 20 | } |
20 | 21 | |
21 | 22 | // Options. |
22 | 23 | $conds = array(); |
23 | | - $deleted = $wgRequest->getVal( 'deletedfilters' ); |
24 | | - $hidedisabled = $wgRequest->getBool( 'hidedisabled' ); |
| 24 | + $deleted = $request->getVal( 'deletedfilters' ); |
| 25 | + $hidedisabled = $request->getBool( 'hidedisabled' ); |
25 | 26 | if ( $deleted == 'show' ) { |
26 | 27 | # Nothing |
27 | 28 | } elseif ( $deleted == 'only' ) { |
— | — | @@ -38,8 +39,6 @@ |
39 | 40 | } |
40 | 41 | |
41 | 42 | function showList( $conds = array( 'af_deleted' => 0 ), $optarray = array() ) { |
42 | | - global $wgOut; |
43 | | - |
44 | 43 | $output = ''; |
45 | 44 | $output .= Xml::element( 'h2', null, |
46 | 45 | wfMsgExt( 'abusefilter-list', array( 'parseinline' ) ) ); |
— | — | @@ -100,11 +99,11 @@ |
101 | 100 | $pager->getBody() . |
102 | 101 | $pager->getNavigationBar(); |
103 | 102 | |
104 | | - $wgOut->addHTML( $output ); |
| 103 | + $this->getOutput()->addHTML( $output ); |
105 | 104 | } |
106 | 105 | |
107 | 106 | function showStatus() { |
108 | | - global $wgMemc, $wgAbuseFilterConditionLimit, $wgOut, $wgLang; |
| 107 | + global $wgMemc, $wgAbuseFilterConditionLimit; |
109 | 108 | |
110 | 109 | $overflow_count = (int)$wgMemc->get( AbuseFilter::filterLimitReachedKey() ); |
111 | 110 | $match_count = (int) $wgMemc->get( AbuseFilter::filterMatchesKey() ); |
— | — | @@ -114,17 +113,18 @@ |
115 | 114 | $overflow_percent = sprintf( "%.2f", 100 * $overflow_count / $total_count ); |
116 | 115 | $match_percent = sprintf( "%.2f", 100 * $match_count / $total_count ); |
117 | 116 | |
| 117 | + $lang = $this->getLang(); |
118 | 118 | $status = wfMsgExt( 'abusefilter-status', array( 'parseinline' ), |
119 | | - $wgLang->formatNum( $total_count ), |
120 | | - $wgLang->formatNum( $overflow_count ), |
121 | | - $wgLang->formatNum( $overflow_percent ), |
122 | | - $wgLang->formatNum( $wgAbuseFilterConditionLimit ), |
123 | | - $wgLang->formatNum( $match_count ), |
124 | | - $wgLang->formatNum( $match_percent ) |
| 119 | + $lang->formatNum( $total_count ), |
| 120 | + $lang->formatNum( $overflow_count ), |
| 121 | + $lang->formatNum( $overflow_percent ), |
| 122 | + $lang->formatNum( $wgAbuseFilterConditionLimit ), |
| 123 | + $lang->formatNum( $match_count ), |
| 124 | + $lang->formatNum( $match_percent ) |
125 | 125 | ); |
126 | 126 | |
127 | 127 | $status = Xml::tags( 'div', array( 'class' => 'mw-abusefilter-status' ), $status ); |
128 | | - $wgOut->addHTML( $status ); |
| 128 | + $this->getOutput()->addHTML( $status ); |
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | function __construct( $page, $conds ) { |
136 | 136 | $this->mPage = $page; |
137 | 137 | $this->mConds = $conds; |
138 | | - parent::__construct(); |
| 138 | + parent::__construct( $this->mPage->getContext() ); |
139 | 139 | } |
140 | 140 | |
141 | 141 | function getQueryInfo() { |
— | — | @@ -180,18 +180,17 @@ |
181 | 181 | } |
182 | 182 | |
183 | 183 | function formatValue( $name, $value ) { |
184 | | - global $wgOut, $wgLang; |
185 | | - |
| 184 | + $lang = $this->getLang(); |
186 | 185 | $row = $this->mCurrentRow; |
187 | 186 | |
188 | 187 | switch( $name ) { |
189 | 188 | case 'af_id': |
190 | 189 | return Linker::link( |
191 | | - SpecialPage::getTitleFor( 'AbuseFilter', intval( $value ) ), $wgLang->formatNum( intval( $value ) ) ); |
| 190 | + SpecialPage::getTitleFor( 'AbuseFilter', intval( $value ) ), $lang->formatNum( intval( $value ) ) ); |
192 | 191 | case 'af_public_comments': |
193 | 192 | return Linker::link( |
194 | 193 | SpecialPage::getTitleFor( 'AbuseFilter', intval( $row->af_id ) ), |
195 | | - $wgOut->parseInline( $value ) |
| 194 | + $this->getOutput()->parseInline( $value ) |
196 | 195 | ); |
197 | 196 | case 'af_actions': |
198 | 197 | $actions = explode( ',', $value ); |
— | — | @@ -199,7 +198,7 @@ |
200 | 199 | foreach ( $actions as $action ) { |
201 | 200 | $displayActions[] = AbuseFilter::getActionDisplay( $action ); |
202 | 201 | } |
203 | | - return htmlspecialchars( $wgLang->commaList( $displayActions ) ); |
| 202 | + return htmlspecialchars( $lang->commaList( $displayActions ) ); |
204 | 203 | case 'af_enabled': |
205 | 204 | $statuses = array(); |
206 | 205 | if ( $row->af_deleted ) { |
— | — | @@ -215,7 +214,7 @@ |
216 | 215 | $statuses[] = wfMsgExt( 'abusefilter-status-global', 'parseinline' ); |
217 | 216 | } |
218 | 217 | |
219 | | - return $wgLang->commaList( $statuses ); |
| 218 | + return $lang->commaList( $statuses ); |
220 | 219 | case 'af_hidden': |
221 | 220 | $msg = $value ? 'abusefilter-hidden' : 'abusefilter-unhidden'; |
222 | 221 | return wfMsgExt( $msg, 'parseinline' ); |
— | — | @@ -223,7 +222,7 @@ |
224 | 223 | $count_display = wfMsgExt( |
225 | 224 | 'abusefilter-hitcount', |
226 | 225 | array( 'parseinline' ), |
227 | | - $wgLang->formatNum( $value ) |
| 226 | + $lang->formatNum( $value ) |
228 | 227 | ); |
229 | 228 | // @todo FIXME: makeKnownLinkObj() is deprecated. |
230 | 229 | $link = Linker::makeKnownLinkObj( |
— | — | @@ -246,10 +245,10 @@ |
247 | 246 | return wfMsgExt( |
248 | 247 | 'abusefilter-edit-lastmod-text', |
249 | 248 | array( 'replaceafter', 'parseinline' ), |
250 | | - array( $wgLang->timeanddate( $value, true ), |
| 249 | + array( $lang->timeanddate( $value, true ), |
251 | 250 | $userLink, |
252 | | - $wgLang->date( $value, true ), |
253 | | - $wgLang->time( $value, true ), |
| 251 | + $lang->date( $value, true ), |
| 252 | + $lang->time( $value, true ), |
254 | 253 | $user ) |
255 | 254 | ); |
256 | 255 | default: |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php |
— | — | @@ -1,9 +1,14 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -abstract class AbuseFilterView { |
| 4 | +abstract class AbuseFilterView extends ContextSource { |
| 5 | + /** |
| 6 | + * @param $page SpecialPage |
| 7 | + * @param $params array |
| 8 | + */ |
5 | 9 | function __construct( $page, $params ) { |
6 | 10 | $this->mPage = $page; |
7 | 11 | $this->mParams = $params; |
| 12 | + $this->setContext( $this->mPage->getContext() ); |
8 | 13 | } |
9 | 14 | |
10 | 15 | /** |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewTools.php |
— | — | @@ -4,17 +4,18 @@ |
5 | 5 | |
6 | 6 | class AbuseFilterViewTools extends AbuseFilterView { |
7 | 7 | function show() { |
8 | | - global $wgOut, $wgUser; |
| 8 | + $out = $this->getOutput(); |
| 9 | + $user = $this->getUser(); |
9 | 10 | |
10 | 11 | // Header |
11 | | - $wgOut->addWikiMsg( 'abusefilter-tools-text' ); |
| 12 | + $out->addWikiMsg( 'abusefilter-tools-text' ); |
12 | 13 | |
13 | 14 | // Expression evaluator |
14 | 15 | $eval = ''; |
15 | 16 | $eval .= AbuseFilter::buildEditBox( '', 'wpTestExpr' ); |
16 | 17 | |
17 | 18 | // Only let users with permission actually test it |
18 | | - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 19 | + if ( $user->isAllowed( 'abusefilter-modify' ) ) { |
19 | 20 | $eval .= Xml::tags( 'p', null, |
20 | 21 | Xml::element( 'input', |
21 | 22 | array( |
— | — | @@ -26,11 +27,11 @@ |
27 | 28 | $eval .= Xml::element( 'p', array( 'id' => 'mw-abusefilter-expr-result' ), ' ' ); |
28 | 29 | } |
29 | 30 | $eval = Xml::fieldset( wfMsg( 'abusefilter-tools-expr' ), $eval ); |
30 | | - $wgOut->addHTML( $eval ); |
| 31 | + $out->addHTML( $eval ); |
31 | 32 | |
32 | | - $wgOut->addModules( 'ext.abuseFilter.tools' ); |
| 33 | + $out->addModules( 'ext.abuseFilter.tools' ); |
33 | 34 | |
34 | | - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 35 | + if ( $user->isAllowed( 'abusefilter-modify' ) ) { |
35 | 36 | // Hacky little box to re-enable autoconfirmed if it got disabled |
36 | 37 | $rac = ''; |
37 | 38 | $rac .= Xml::inputLabel( |
— | — | @@ -49,7 +50,7 @@ |
50 | 51 | ) |
51 | 52 | ); |
52 | 53 | $rac = Xml::fieldset( wfMsg( 'abusefilter-tools-reautoconfirm' ), $rac ); |
53 | | - $wgOut->addHTML( $rac ); |
| 54 | + $out->addHTML( $rac ); |
54 | 55 | } |
55 | 56 | } |
56 | 57 | } |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php |
— | — | @@ -10,26 +10,25 @@ |
11 | 11 | } |
12 | 12 | |
13 | 13 | function show() { |
14 | | - global $wgRequest, $wgOut, $wgLang, $wgUser; |
15 | | - |
| 14 | + $out = $this->getOutput(); |
16 | 15 | $filter = $this->mFilter; |
17 | 16 | |
18 | 17 | if ( $filter ) { |
19 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) ); |
| 18 | + $out->setPageTitle( wfMsg( 'abusefilter-history', $filter ) ); |
20 | 19 | } else { |
21 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-filter-log' ) ); |
| 20 | + $out->setPageTitle( wfMsg( 'abusefilter-filter-log' ) ); |
22 | 21 | } |
23 | 22 | |
24 | 23 | # Check perms |
25 | 24 | if ( $filter && |
26 | | - !$wgUser->isAllowed( 'abusefilter-modify' ) && |
| 25 | + !$this->getUser()->isAllowed( 'abusefilter-modify' ) && |
27 | 26 | AbuseFilter::filterHidden( $filter ) ) { |
28 | | - $wgOut->addWikiMsg( 'abusefilter-history-error-hidden' ); |
| 27 | + $out->addWikiMsg( 'abusefilter-history-error-hidden' ); |
29 | 28 | return; |
30 | 29 | } |
31 | 30 | |
32 | 31 | # Useful links |
33 | | - $sk = $wgUser->getSkin(); |
| 32 | + $sk = $this->getSkin(); |
34 | 33 | $links = array(); |
35 | 34 | if ( $filter ) { |
36 | 35 | $links['abusefilter-history-backedit'] = $this->getTitle( $filter ); |
— | — | @@ -39,13 +38,13 @@ |
40 | 39 | $links[$msg] = $sk->link( $title, wfMsgExt( $msg, 'parseinline' ) ); |
41 | 40 | } |
42 | 41 | |
43 | | - $backlinks = $wgLang->pipeList( $links ); |
44 | | - $wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
| 42 | + $backlinks = $this->getLang()->pipeList( $links ); |
| 43 | + $out->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
45 | 44 | |
46 | 45 | # For user |
47 | | - $user = $wgRequest->getText( 'user' ); |
| 46 | + $user = $this->getRequest()->getText( 'user' ); |
48 | 47 | if ( $user ) { |
49 | | - $wgOut->setSubtitle( |
| 48 | + $out->setSubtitle( |
50 | 49 | wfMsg( |
51 | 50 | 'abusefilter-history-foruser', |
52 | 51 | $sk->userLink( 1 /* We don't really need to get a user ID */, $user ), |
— | — | @@ -67,12 +66,12 @@ |
68 | 67 | $filterForm |
69 | 68 | ); |
70 | 69 | $filterForm = Xml::fieldset( wfMsg( 'abusefilter-history-select-legend' ), $filterForm ); |
71 | | - $wgOut->addHTML( $filterForm ); |
| 70 | + $out->addHTML( $filterForm ); |
72 | 71 | |
73 | 72 | $pager = new AbuseFilterHistoryPager( $filter, $this, $user ); |
74 | 73 | $table = $pager->getBody(); |
75 | 74 | |
76 | | - $wgOut->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() ); |
| 75 | + $out->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() ); |
77 | 76 | } |
78 | 77 | } |
79 | 78 | |
— | — | @@ -88,7 +87,7 @@ |
89 | 88 | $this->mPage = $page; |
90 | 89 | $this->mUser = $user; |
91 | 90 | $this->mDefaultDirection = true; |
92 | | - parent::__construct(); |
| 91 | + parent::__construct( $this->mPage->getContext() ); |
93 | 92 | } |
94 | 93 | |
95 | 94 | function getFieldNames() { |
— | — | @@ -119,25 +118,19 @@ |
120 | 119 | } |
121 | 120 | |
122 | 121 | function formatValue( $name, $value ) { |
123 | | - global $wgOut, $wgLang; |
| 122 | + $sk = $this->getSkin(); |
| 123 | + $lang = $this->getLang(); |
124 | 124 | |
125 | | - static $sk = null; |
126 | | - |
127 | | - if ( empty( $sk ) ) { |
128 | | - global $wgUser; |
129 | | - $sk = $wgUser->getSkin(); |
130 | | - } |
131 | | - |
132 | 125 | $row = $this->mCurrentRow; |
133 | 126 | |
134 | 127 | switch( $name ) { |
135 | 128 | case 'afh_filter': |
136 | | - $formatted = $wgLang->formatNum ( $row->afh_filter ); |
| 129 | + $formatted = $lang->formatNum ( $row->afh_filter ); |
137 | 130 | break; |
138 | 131 | case 'afh_timestamp': |
139 | 132 | $title = SpecialPage::getTitleFor( 'AbuseFilter', |
140 | 133 | 'history/' . $row->afh_filter . '/item/' . $row->afh_id ); |
141 | | - $formatted = $sk->link( $title, $wgLang->timeanddate( $row->afh_timestamp, true ) ); |
| 134 | + $formatted = $sk->link( $title, $lang->timeanddate( $row->afh_timestamp, true ) ); |
142 | 135 | break; |
143 | 136 | case 'afh_user_text': |
144 | 137 | $formatted = |
— | — | @@ -145,7 +138,7 @@ |
146 | 139 | $sk->userToolLinks( $row->afh_user, $row->afh_user_text ); |
147 | 140 | break; |
148 | 141 | case 'afh_public_comments': |
149 | | - $formatted = $wgOut->parse( $value ); |
| 142 | + $formatted = $this->getOutput()->parse( $value ); |
150 | 143 | break; |
151 | 144 | case 'afh_flags': |
152 | 145 | $formatted = AbuseFilter::formatFlags( $value ); |
— | — | @@ -231,8 +224,6 @@ |
232 | 225 | ), |
233 | 226 | ); |
234 | 227 | |
235 | | - global $wgUser; |
236 | | - |
237 | 228 | if ( $this->mUser ) { |
238 | 229 | $info['conds']['afh_user_text'] = $this->mUser; |
239 | 230 | } |
— | — | @@ -241,7 +232,7 @@ |
242 | 233 | $info['conds']['afh_filter'] = $this->mFilter; |
243 | 234 | } |
244 | 235 | |
245 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 236 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
246 | 237 | // Hide data the user can't see. |
247 | 238 | $info['conds']['af_hidden'] = 0; |
248 | 239 | } |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewTestBatch.php |
— | — | @@ -8,19 +8,19 @@ |
9 | 9 | static $mChangeLimit = 100; |
10 | 10 | |
11 | 11 | function show() { |
12 | | - global $wgOut, $wgUser, $wgRequest; |
| 12 | + $out = $this->getOutput(); |
13 | 13 | |
14 | 14 | AbuseFilter::disableConditionLimit(); |
15 | 15 | |
16 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
17 | | - $wgOut->addWikiMsg( 'abusefilter-mustbeeditor' ); |
| 16 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
| 17 | + $out->addWikiMsg( 'abusefilter-mustbeeditor' ); |
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | 21 | $this->loadParameters(); |
22 | 22 | |
23 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-test' ) ); |
24 | | - $wgOut->addWikiMsg( 'abusefilter-test-intro', self::$mChangeLimit ); |
| 23 | + $out->setPageTitle( wfMsg( 'abusefilter-test' ) ); |
| 24 | + $out->addWikiMsg( 'abusefilter-test-intro', self::$mChangeLimit ); |
25 | 25 | |
26 | 26 | $output = ''; |
27 | 27 | $output .= AbuseFilter::buildEditBox( $this->mFilter, 'wpTestFilter' ) . "\n"; |
— | — | @@ -68,19 +68,19 @@ |
69 | 69 | |
70 | 70 | $output = Xml::fieldset( wfMsg( 'abusefilter-test-legend' ), $output ); |
71 | 71 | |
72 | | - $wgOut->addHTML( $output ); |
| 72 | + $out->addHTML( $output ); |
73 | 73 | |
74 | | - if ( $wgRequest->wasPosted() ) { |
| 74 | + if ( $this->getRequest()->wasPosted() ) { |
75 | 75 | $this->doTest(); |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | function doTest() { |
80 | 80 | // Quick syntax check. |
81 | | - global $wgUser, $wgOut; |
| 81 | + $out = $this->getOutput(); |
82 | 82 | $result = AbuseFilter::checkSyntax( $this->mFilter ); |
83 | 83 | if ( $result !== true ) { |
84 | | - $wgOut->addWikiMsg( 'abusefilter-test-syntaxerr' ); |
| 84 | + $out->addWikiMsg( 'abusefilter-test-syntaxerr' ); |
85 | 85 | return; |
86 | 86 | } |
87 | 87 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Get our ChangesList |
106 | | - $changesList = new AbuseFilterChangesList( $wgUser->getSkin() ); |
| 106 | + $changesList = new AbuseFilterChangesList( $this->getSkin() ); |
107 | 107 | $output = $changesList->beginRecentChangesList(); |
108 | 108 | |
109 | 109 | $res = $dbr->select( |
— | — | @@ -136,18 +136,18 @@ |
137 | 137 | |
138 | 138 | $output .= $changesList->endRecentChangesList(); |
139 | 139 | |
140 | | - $wgOut->addHTML( $output ); |
| 140 | + $out->addHTML( $output ); |
141 | 141 | } |
142 | 142 | |
143 | 143 | function loadParameters() { |
144 | | - global $wgRequest; |
| 144 | + $request = $this->getRequest(); |
145 | 145 | |
146 | | - $this->mFilter = $wgRequest->getText( 'wpTestFilter' ); |
147 | | - $this->mShowNegative = $wgRequest->getBool( 'wpShowNegative' ); |
148 | | - $testUsername = $wgRequest->getText( 'wpTestUser' ); |
149 | | - $this->mTestPeriodEnd = $wgRequest->getText( 'wpTestPeriodEnd' ); |
150 | | - $this->mTestPeriodStart = $wgRequest->getText( 'wpTestPeriodStart' ); |
151 | | - $this->mTestPage = $wgRequest->getText( 'wpTestPage' ); |
| 146 | + $this->mFilter = $request->getText( 'wpTestFilter' ); |
| 147 | + $this->mShowNegative = $request->getBool( 'wpShowNegative' ); |
| 148 | + $testUsername = $request->getText( 'wpTestUser' ); |
| 149 | + $this->mTestPeriodEnd = $request->getText( 'wpTestPeriodEnd' ); |
| 150 | + $this->mTestPeriodStart = $request->getText( 'wpTestPeriodStart' ); |
| 151 | + $this->mTestPage = $request->getText( 'wpTestPage' ); |
152 | 152 | |
153 | 153 | if ( !$this->mFilter |
154 | 154 | && count( $this->mParams ) > 1 |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -11,26 +11,27 @@ |
12 | 12 | } |
13 | 13 | |
14 | 14 | function show() { |
15 | | - global $wgRequest, $wgUser, $wgOut; |
| 15 | + $user = $this->getUser(); |
| 16 | + $out = $this->getOutput(); |
| 17 | + $request = $this->getRequest(); |
16 | 18 | |
17 | 19 | $filter = $this->mFilter; |
18 | 20 | $history_id = $this->mHistoryID; |
19 | | - $this->mSkin = $wgUser->getSkin(); |
20 | 21 | |
21 | | - if ( $filter == 'new' && !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
22 | | - $wgOut->addWikiMsg( 'abusefilter-edit-notallowed' ); |
| 22 | + if ( $filter == 'new' && !$user->isAllowed( 'abusefilter-modify' ) ) { |
| 23 | + $out->addWikiMsg( 'abusefilter-edit-notallowed' ); |
23 | 24 | return; |
24 | 25 | } |
25 | 26 | |
26 | | - $editToken = $wgRequest->getVal( 'wpEditToken' ); |
| 27 | + $editToken = $request->getVal( 'wpEditToken' ); |
27 | 28 | $didEdit = $this->canEdit() |
28 | | - && $wgUser->matchEditToken( $editToken, array( 'abusefilter', $filter ) ); |
| 29 | + && $user->matchEditToken( $editToken, array( 'abusefilter', $filter ) ); |
29 | 30 | |
30 | 31 | if ( $didEdit ) { |
31 | 32 | // Check syntax |
32 | | - $syntaxerr = AbuseFilter::checkSyntax( $wgRequest->getVal( 'wpFilterRules' ) ); |
| 33 | + $syntaxerr = AbuseFilter::checkSyntax( $request->getVal( 'wpFilterRules' ) ); |
33 | 34 | if ( $syntaxerr !== true ) { |
34 | | - $wgOut->addHTML( |
| 35 | + $out->addHTML( |
35 | 36 | $this->buildFilterEditor( |
36 | 37 | wfMsgExt( |
37 | 38 | 'abusefilter-edit-badsyntax', |
— | — | @@ -57,7 +58,7 @@ |
58 | 59 | |
59 | 60 | // Check for non-changes |
60 | 61 | if ( !count( $differences ) ) { |
61 | | - $wgOut->redirect( $this->getTitle()->getLocalURL() ); |
| 62 | + $out->redirect( $this->getTitle()->getLocalURL() ); |
62 | 63 | return; |
63 | 64 | } |
64 | 65 | |
— | — | @@ -67,9 +68,9 @@ |
68 | 69 | array_intersect( |
69 | 70 | $wgAbuseFilterRestrictedActions, |
70 | 71 | array_keys( array_filter( $actions ) ) ) |
71 | | - && !$wgUser->isAllowed( 'abusefilter-modify-restricted' ) ) |
| 72 | + && !$user->isAllowed( 'abusefilter-modify-restricted' ) ) |
72 | 73 | { |
73 | | - $wgOut->addHTML( |
| 74 | + $out->addHTML( |
74 | 75 | $this->buildFilterEditor( |
75 | 76 | wfMsgExt( 'abusefilter-edit-restricted', 'parse' ), |
76 | 77 | $this->mFilter, |
— | — | @@ -89,7 +90,7 @@ |
90 | 91 | } |
91 | 92 | |
92 | 93 | if ( $bad ) { |
93 | | - $wgOut->addHTML( |
| 94 | + $out->addHTML( |
94 | 95 | $this->buildFilterEditor( |
95 | 96 | wfMsgExt( 'abusefilter-edit-bad-tags', 'parse' ), |
96 | 97 | $this->mFilter, |
— | — | @@ -105,8 +106,8 @@ |
106 | 107 | |
107 | 108 | // Set last modifier. |
108 | 109 | $newRow['af_timestamp'] = $dbw->timestamp( wfTimestampNow() ); |
109 | | - $newRow['af_user'] = $wgUser->getId(); |
110 | | - $newRow['af_user_text'] = $wgUser->getName(); |
| 110 | + $newRow['af_user'] = $user->getId(); |
| 111 | + $newRow['af_user_text'] = $user->getName(); |
111 | 112 | |
112 | 113 | $dbw->begin(); |
113 | 114 | |
— | — | @@ -215,46 +216,44 @@ |
216 | 217 | |
217 | 218 | AbuseFilter::resetFilterProfile( $new_id ); |
218 | 219 | |
219 | | - global $wgOut; |
220 | | - |
221 | | - $wgOut->redirect( |
| 220 | + $out->redirect( |
222 | 221 | $this->getTitle()->getLocalURL( 'result=success&changedfilter=' . $new_id ) ); |
223 | 222 | } else { |
224 | 223 | if ( $history_id ) { |
225 | | - $wgOut->addWikiMsg( |
| 224 | + $out->addWikiMsg( |
226 | 225 | 'abusefilter-edit-oldwarning', $this->mHistoryID, $this->mFilter ); |
227 | 226 | } |
228 | 227 | |
229 | | - $wgOut->addHTML( $this->buildFilterEditor( null, $this->mFilter, $history_id ) ); |
| 228 | + $out->addHTML( $this->buildFilterEditor( null, $this->mFilter, $history_id ) ); |
230 | 229 | |
231 | 230 | if ( $history_id ) { |
232 | | - $wgOut->addWikiMsg( |
| 231 | + $out->addWikiMsg( |
233 | 232 | 'abusefilter-edit-oldwarning', $this->mHistoryID, $this->mFilter ); |
234 | 233 | } |
235 | 234 | } |
236 | 235 | } |
237 | 236 | |
238 | 237 | function buildFilterEditor( $error, $filter, $history_id = null ) { |
239 | | - global $wgLang; |
240 | | - |
241 | 238 | if ( $filter === null ) { |
242 | 239 | return false; |
243 | 240 | } |
244 | 241 | |
245 | 242 | // Build the edit form |
246 | | - global $wgOut, $wgLang, $wgUser; |
247 | | - $sk = $this->mSkin; |
| 243 | + $out = $this->getOutput(); |
| 244 | + $lang = $this->getLang(); |
| 245 | + $user = $this->getUser(); |
| 246 | + $sk = $this->getSkin(); |
248 | 247 | |
249 | 248 | // Load from request OR database. |
250 | 249 | list( $row, $actions ) = $this->loadRequest( $filter, $history_id ); |
251 | 250 | |
252 | 251 | if ( !$row ) { |
253 | | - $wgOut->addWikiMsg( 'abusefilter-edit-badfilter' ); |
254 | | - $wgOut->addHTML( $sk->link( $this->getTitle(), wfMsg( 'abusefilter-return' ) ) ); |
| 252 | + $out->addWikiMsg( 'abusefilter-edit-badfilter' ); |
| 253 | + $out->addHTML( $sk->link( $this->getTitle(), wfMsg( 'abusefilter-return' ) ) ); |
255 | 254 | return; |
256 | 255 | } |
257 | 256 | |
258 | | - $wgOut->setSubtitle( wfMsg( 'abusefilter-edit-subtitle', $filter, $history_id ) ); |
| 257 | + $out->setSubtitle( wfMsg( 'abusefilter-edit-subtitle', $filter, $history_id ) ); |
259 | 258 | |
260 | 259 | // Hide hidden filters. |
261 | 260 | if ( ( ( isset( $row->af_hidden ) && $row->af_hidden ) || |
— | — | @@ -265,7 +264,7 @@ |
266 | 265 | |
267 | 266 | $output = ''; |
268 | 267 | if ( $error ) { |
269 | | - $wgOut->addHTML( "<span class=\"error\">$error</span>" ); |
| 268 | + $out->addHTML( "<span class=\"error\">$error</span>" ); |
270 | 269 | } |
271 | 270 | |
272 | 271 | // Read-only attribute |
— | — | @@ -280,7 +279,7 @@ |
281 | 280 | $fields = array(); |
282 | 281 | |
283 | 282 | $fields['abusefilter-edit-id'] = |
284 | | - $this->mFilter == 'new' ? wfMsg( 'abusefilter-edit-new' ) : $wgLang->formatNum( $filter ); |
| 283 | + $this->mFilter == 'new' ? wfMsg( 'abusefilter-edit-new' ) : $lang->formatNum( $filter ); |
285 | 284 | $fields['abusefilter-edit-description'] = |
286 | 285 | Xml::input( |
287 | 286 | 'wpFilterDescription', |
— | — | @@ -293,7 +292,7 @@ |
294 | 293 | if ( !empty( $row->af_hit_count ) ) { |
295 | 294 | $count = (int)$row->af_hit_count; |
296 | 295 | $count_display = wfMsgExt( 'abusefilter-hitcount', array( 'parseinline' ), |
297 | | - $wgLang->formatNum( $count ) |
| 296 | + $lang->formatNum( $count ) |
298 | 297 | ); |
299 | 298 | $hitCount = $sk->makeKnownLinkObj( |
300 | 299 | SpecialPage::getTitleFor( 'AbuseLog' ), |
— | — | @@ -306,10 +305,11 @@ |
307 | 306 | |
308 | 307 | if ( $filter !== 'new' ) { |
309 | 308 | // Statistics |
310 | | - global $wgMemc, $wgLang; |
| 309 | + global $wgMemc; |
311 | 310 | $matches_count = $wgMemc->get( AbuseFilter::filterMatchesKey( $filter ) ); |
312 | 311 | $total = $wgMemc->get( AbuseFilter::filterUsedKey() ); |
313 | 312 | |
| 313 | + |
314 | 314 | if ( $total > 0 ) { |
315 | 315 | $matches_percent = sprintf( '%.2f', 100 * $matches_count / $total ); |
316 | 316 | list( $timeProfile, $condProfile ) = AbuseFilter::getFilterProfile( $filter ); |
— | — | @@ -317,11 +317,11 @@ |
318 | 318 | $fields['abusefilter-edit-status-label'] = |
319 | 319 | wfMsgExt( 'abusefilter-edit-status', array( 'parsemag', 'escape' ), |
320 | 320 | array( |
321 | | - $wgLang->formatNum( $total ), |
322 | | - $wgLang->formatNum( $matches_count ), |
323 | | - $wgLang->formatNum( $matches_percent ), |
324 | | - $wgLang->formatNum( $timeProfile ), |
325 | | - $wgLang->formatNum( $condProfile ) |
| 321 | + $lang->formatNum( $total ), |
| 322 | + $lang->formatNum( $matches_count ), |
| 323 | + $lang->formatNum( $matches_percent ), |
| 324 | + $lang->formatNum( $timeProfile ), |
| 325 | + $lang->formatNum( $condProfile ) |
326 | 326 | ) |
327 | 327 | ); |
328 | 328 | } |
— | — | @@ -350,10 +350,10 @@ |
351 | 351 | if ( isset( $row->af_throttled ) && $row->af_throttled ) { |
352 | 352 | global $wgAbuseFilterEmergencyDisableThreshold; |
353 | 353 | $threshold_percent = sprintf( '%.2f', $wgAbuseFilterEmergencyDisableThreshold * 100 ); |
354 | | - $flags .= $wgOut->parse( |
| 354 | + $flags .= $out->parse( |
355 | 355 | wfMsg( |
356 | 356 | 'abusefilter-edit-throttled', |
357 | | - $wgLang->formatNum( $threshold_percent ) |
| 357 | + $lang->formatNum( $threshold_percent ) |
358 | 358 | ) |
359 | 359 | ); |
360 | 360 | } |
— | — | @@ -377,7 +377,7 @@ |
378 | 378 | $fields['abusefilter-edit-flags'] = $flags; |
379 | 379 | $tools = ''; |
380 | 380 | |
381 | | - if ( $filter != 'new' && $wgUser->isAllowed( 'abusefilter-revert' ) ) { |
| 381 | + if ( $filter != 'new' && $user->isAllowed( 'abusefilter-revert' ) ) { |
382 | 382 | $tools .= Xml::tags( |
383 | 383 | 'p', null, |
384 | 384 | $sk->link( |
— | — | @@ -405,10 +405,10 @@ |
406 | 406 | wfMsgExt( |
407 | 407 | 'abusefilter-edit-lastmod-text', |
408 | 408 | array( 'parseinline', 'replaceafter' ), |
409 | | - array( $wgLang->timeanddate( $row->af_timestamp, true ), |
| 409 | + array( $lang->timeanddate( $row->af_timestamp, true ), |
410 | 410 | $userLink, |
411 | | - $wgLang->date( $row->af_timestamp, true ), |
412 | | - $wgLang->time( $row->af_timestamp, true ), |
| 411 | + $lang->date( $row->af_timestamp, true ), |
| 412 | + $lang->time( $row->af_timestamp, true ), |
413 | 413 | $user |
414 | 414 | ) |
415 | 415 | ); |
— | — | @@ -439,7 +439,7 @@ |
440 | 440 | $form .= Xml::submitButton( wfMsg( 'abusefilter-edit-save' ), array( 'accesskey' => 's' ) ); |
441 | 441 | $form .= Html::hidden( |
442 | 442 | 'wpEditToken', |
443 | | - $wgUser->editToken( array( 'abusefilter', $filter ) ) |
| 443 | + $user->getEditToken( array( 'abusefilter', $filter ) ) |
444 | 444 | ); |
445 | 445 | } |
446 | 446 | |
— | — | @@ -655,14 +655,14 @@ |
656 | 656 | |
657 | 657 | $existingSelector->addOption( 'abusefilter-warning' ); |
658 | 658 | |
659 | | - global $wgLang; |
| 659 | + $lang = $this->getLang(); |
660 | 660 | foreach( $res as $row ) { |
661 | | - if ( $wgLang->lcfirst( $row->page_title ) == $wgLang->lcfirst( $warnMsg ) ) { |
662 | | - $existingSelector->setDefault( $wgLang->lcfirst( $warnMsg ) ); |
| 661 | + if ( $lang->lcfirst( $row->page_title ) == $lang->lcfirst( $warnMsg ) ) { |
| 662 | + $existingSelector->setDefault( $lang->lcfirst( $warnMsg ) ); |
663 | 663 | } |
664 | 664 | |
665 | 665 | if ( $row->page_title != 'Abusefilter-warning' ) { |
666 | | - $existingSelector->addOption( $wgLang->lcfirst( $row->page_title ) ); |
| 666 | + $existingSelector->addOption( $lang->lcfirst( $row->page_title ) ); |
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
— | — | @@ -733,11 +733,11 @@ |
734 | 734 | function loadRequest( $filter, $history_id = null ) { |
735 | 735 | static $row = null; |
736 | 736 | static $actions = null; |
737 | | - global $wgRequest; |
| 737 | + $request = $this->getRequest(); |
738 | 738 | |
739 | 739 | if ( !is_null( $actions ) && !is_null( $row ) ) { |
740 | 740 | return array( $row, $actions ); |
741 | | - } elseif ( $wgRequest->wasPosted() ) { |
| 741 | + } elseif ( $request->wasPosted() ) { |
742 | 742 | # Nothing, we do it all later |
743 | 743 | } elseif ( $history_id ) { |
744 | 744 | return $this->loadHistoryItem( $history_id ); |
— | — | @@ -752,7 +752,7 @@ |
753 | 753 | $row->mOriginalActions = $origActions; |
754 | 754 | |
755 | 755 | // Check for importing |
756 | | - $import = $wgRequest->getVal( 'wpImportText' ); |
| 756 | + $import = $request->getVal( 'wpImportText' ); |
757 | 757 | if ( $import ) { |
758 | 758 | $data = json_decode( $import ); |
759 | 759 | |
— | — | @@ -779,44 +779,44 @@ |
780 | 780 | ); |
781 | 781 | |
782 | 782 | foreach ( $textLoads as $col => $field ) { |
783 | | - $row->$col = trim( $wgRequest->getVal( $field ) ); |
| 783 | + $row->$col = trim( $request->getVal( $field ) ); |
784 | 784 | } |
785 | 785 | |
786 | | - $row->af_deleted = $wgRequest->getBool( 'wpFilterDeleted' ); |
787 | | - $row->af_enabled = $wgRequest->getBool( 'wpFilterEnabled' ) && !$row->af_deleted; |
788 | | - $row->af_hidden = $wgRequest->getBool( 'wpFilterHidden' ); |
| 786 | + $row->af_deleted = $request->getBool( 'wpFilterDeleted' ); |
| 787 | + $row->af_enabled = $request->getBool( 'wpFilterEnabled' ) && !$row->af_deleted; |
| 788 | + $row->af_hidden = $request->getBool( 'wpFilterHidden' ); |
789 | 789 | global $wgAbuseFilterIsCentral; |
790 | | - $row->af_global = $wgRequest->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral; |
| 790 | + $row->af_global = $request->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral; |
791 | 791 | |
792 | 792 | // Actions |
793 | 793 | global $wgAbuseFilterAvailableActions; |
794 | 794 | $actions = array(); |
795 | 795 | foreach ( $wgAbuseFilterAvailableActions as $action ) { |
796 | 796 | // Check if it's set |
797 | | - $enabled = $wgRequest->getBool( 'wpFilterAction' . ucfirst( $action ) ); |
| 797 | + $enabled = $request->getBool( 'wpFilterAction' . ucfirst( $action ) ); |
798 | 798 | |
799 | 799 | if ( $enabled ) { |
800 | 800 | $parameters = array(); |
801 | 801 | |
802 | 802 | if ( $action == 'throttle' ) { |
803 | 803 | // We need to load the parameters |
804 | | - $throttleCount = $wgRequest->getIntOrNull( 'wpFilterThrottleCount' ); |
805 | | - $throttlePeriod = $wgRequest->getIntOrNull( 'wpFilterThrottlePeriod' ); |
| 804 | + $throttleCount = $request->getIntOrNull( 'wpFilterThrottleCount' ); |
| 805 | + $throttlePeriod = $request->getIntOrNull( 'wpFilterThrottlePeriod' ); |
806 | 806 | $throttleGroups = explode( "\n", |
807 | | - trim( $wgRequest->getText( 'wpFilterThrottleGroups' ) ) ); |
| 807 | + trim( $request->getText( 'wpFilterThrottleGroups' ) ) ); |
808 | 808 | |
809 | 809 | $parameters[0] = $this->mFilter; // For now, anyway |
810 | 810 | $parameters[1] = "$throttleCount,$throttlePeriod"; |
811 | 811 | $parameters = array_merge( $parameters, $throttleGroups ); |
812 | 812 | } elseif ( $action == 'warn' ) { |
813 | | - $specMsg = $wgRequest->getVal( 'wpFilterWarnMessage' ); |
| 813 | + $specMsg = $request->getVal( 'wpFilterWarnMessage' ); |
814 | 814 | |
815 | 815 | if ( $specMsg == 'other' ) |
816 | | - $specMsg = $wgRequest->getVal( 'wpFilterWarnMessageOther' ); |
| 816 | + $specMsg = $request->getVal( 'wpFilterWarnMessageOther' ); |
817 | 817 | |
818 | 818 | $parameters[0] = $specMsg; |
819 | 819 | } elseif ( $action == 'tag' ) { |
820 | | - $parameters = explode( "\n", $wgRequest->getText( 'wpFilterTags' ) ); |
| 820 | + $parameters = explode( "\n", $request->getText( 'wpFilterTags' ) ); |
821 | 821 | } |
822 | 822 | |
823 | 823 | $thisAction = array( 'action' => $action, 'parameters' => $parameters ); |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php |
— | — | @@ -8,11 +8,10 @@ |
9 | 9 | public static $examineId = null; |
10 | 10 | |
11 | 11 | function show() { |
12 | | - global $wgOut; |
| 12 | + $out = $this->getOutput(); |
| 13 | + $out->setPageTitle( $this->msg( 'abusefilter-examine' ) ); |
| 14 | + $out->addWikiMsg( 'abusefilter-examine-intro' ); |
13 | 15 | |
14 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-examine' ) ); |
15 | | - $wgOut->addWikiMsg( 'abusefilter-examine-intro' ); |
16 | | - |
17 | 16 | $this->loadParameters(); |
18 | 17 | |
19 | 18 | // Check if we've got a subpage |
— | — | @@ -29,8 +28,6 @@ |
30 | 29 | } |
31 | 30 | |
32 | 31 | function showSearch() { |
33 | | - global $wgOut; |
34 | | - |
35 | 32 | // Add selector |
36 | 33 | $selector = ''; |
37 | 34 | |
— | — | @@ -55,7 +52,7 @@ |
56 | 53 | wfMsg( 'abusefilter-examine-legend' ), |
57 | 54 | $selector |
58 | 55 | ); |
59 | | - $wgOut->addHTML( $selector ); |
| 56 | + $this->getOutput()->addHTML( $selector ); |
60 | 57 | |
61 | 58 | if ( $this->mSubmit ) { |
62 | 59 | $this->showResults(); |
— | — | @@ -63,9 +60,7 @@ |
64 | 61 | } |
65 | 62 | |
66 | 63 | function showResults() { |
67 | | - global $wgUser, $wgOut; |
68 | | - |
69 | | - $changesList = new AbuseFilterChangesList( $wgUser->getSkin() ); |
| 64 | + $changesList = new AbuseFilterChangesList( $this->getSkin() ); |
70 | 65 | $output = $changesList->beginRecentChangesList(); |
71 | 66 | $this->mCounter = 1; |
72 | 67 | |
— | — | @@ -77,18 +72,16 @@ |
78 | 73 | |
79 | 74 | $output .= $changesList->endRecentChangesList(); |
80 | 75 | |
81 | | - $wgOut->addHTML( $output ); |
| 76 | + $this->getOutput()->addHTML( $output ); |
82 | 77 | } |
83 | 78 | |
84 | 79 | function showExaminerForRC( $rcid ) { |
85 | | - global $wgOut; |
86 | | - |
87 | 80 | // Get data |
88 | 81 | $dbr = wfGetDB( DB_SLAVE ); |
89 | 82 | $row = $dbr->selectRow( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ ); |
90 | 83 | |
91 | 84 | if ( !$row ) { |
92 | | - $wgOut->addWikiMsg( 'abusefilter-examine-notfound' ); |
| 85 | + $this->getOutput()->addWikiMsg( 'abusefilter-examine-notfound' ); |
93 | 86 | return; |
94 | 87 | } |
95 | 88 | |
— | — | @@ -101,14 +94,12 @@ |
102 | 95 | } |
103 | 96 | |
104 | 97 | function showExaminerForLogEntry( $logid ) { |
105 | | - global $wgOut; |
106 | | - |
107 | 98 | // Get data |
108 | 99 | $dbr = wfGetDB( DB_SLAVE ); |
109 | 100 | $row = $dbr->selectRow( 'abuse_filter_log', '*', array( 'afl_id' => $logid ), __METHOD__ ); |
110 | 101 | |
111 | 102 | if ( !$row ) { |
112 | | - $wgOut->addWikiMsg( 'abusefilter-examine-notfound' ); |
| 103 | + $this->getOutput()->addWikiMsg( 'abusefilter-examine-notfound' ); |
113 | 104 | return; |
114 | 105 | } |
115 | 106 | |
— | — | @@ -121,10 +112,10 @@ |
122 | 113 | } |
123 | 114 | |
124 | 115 | function showExaminer( $vars ) { |
125 | | - global $wgOut, $wgUser; |
| 116 | + $output = $this->getOutput(); |
126 | 117 | |
127 | 118 | if ( !$vars ) { |
128 | | - $wgOut->addWikiMsg( 'abusefilter-examine-incompatible' ); |
| 119 | + $output->addWikiMsg( 'abusefilter-examine-incompatible' ); |
129 | 120 | return; |
130 | 121 | } |
131 | 122 | |
— | — | @@ -134,10 +125,10 @@ |
135 | 126 | |
136 | 127 | $output = ''; |
137 | 128 | |
138 | | - $wgOut->addModules( 'ext.abuseFilter.examine' ); |
| 129 | + $output->addModules( 'ext.abuseFilter.examine' ); |
139 | 130 | |
140 | 131 | // Add test bit |
141 | | - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 132 | + if ( $this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
142 | 133 | $tester = Xml::tags( 'h2', null, wfMsgExt( 'abusefilter-examine-test', 'parseinline' ) ); |
143 | 134 | $tester .= AbuseFilter::buildEditBox( $this->mTestFilter, 'wpTestFilter', false ); |
144 | 135 | $tester .= |
— | — | @@ -181,16 +172,16 @@ |
182 | 173 | $output .= Xml::tags( 'h2', null, wfMsgExt( 'abusefilter-examine-vars', 'parseinline' ) ); |
183 | 174 | $output .= AbuseFilter::buildVarDumpTable( $vars ); |
184 | 175 | |
185 | | - $wgOut->addHTML( $output ); |
| 176 | + $output->addHTML( $output ); |
186 | 177 | } |
187 | 178 | |
188 | 179 | function loadParameters() { |
189 | | - global $wgRequest; |
190 | | - $searchUsername = $wgRequest->getText( 'wpSearchUser' ); |
191 | | - $this->mSearchPeriodStart = $wgRequest->getText( 'wpSearchPeriodStart' ); |
192 | | - $this->mSearchPeriodEnd = $wgRequest->getText( 'wpSearchPeriodEnd' ); |
193 | | - $this->mSubmit = $wgRequest->getCheck( 'submit' ); |
194 | | - $this->mTestFilter = $wgRequest->getText( 'testfilter' ); |
| 180 | + $request = $this->getRequest(); |
| 181 | + $searchUsername = $request->getText( 'wpSearchUser' ); |
| 182 | + $this->mSearchPeriodStart = $request->getText( 'wpSearchPeriodStart' ); |
| 183 | + $this->mSearchPeriodEnd = $request->getText( 'wpSearchPeriodEnd' ); |
| 184 | + $this->mSubmit = $request->getCheck( 'submit' ); |
| 185 | + $this->mTestFilter = $request->getText( 'testfilter' ); |
195 | 186 | |
196 | 187 | // Normalise username |
197 | 188 | $userTitle = Title::newFromText( $searchUsername ); |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewRevert.php |
— | — | @@ -8,10 +8,12 @@ |
9 | 9 | $filter = $this->mPage->mFilter; |
10 | 10 | |
11 | 11 | global $wgUser, $wgOut; |
12 | | - $sk = $wgUser->getSkin(); |
| 12 | + $user = $this->getUser(); |
| 13 | + $out = $this->getOutput(); |
| 14 | + $sk = $this->getSkin(); |
13 | 15 | |
14 | | - if ( !$wgUser->isAllowed( 'abusefilter-revert' ) ) { |
15 | | - $wgOut->permissionRequired( 'abusefilter-revert' ); |
| 16 | + if ( !$user->isAllowed( 'abusefilter-revert' ) ) { |
| 17 | + throw new PermissionsError( 'abusefilter-revert' ); |
16 | 18 | return; |
17 | 19 | } |
18 | 20 | |
— | — | @@ -21,8 +23,8 @@ |
22 | 24 | return; |
23 | 25 | } |
24 | 26 | |
25 | | - $wgOut->addWikiMsg( 'abusefilter-revert-intro', $filter ); |
26 | | - $wgOut->setPageTitle( wfMsg( 'abusefilter-revert-title', $filter ) ); |
| 27 | + $out->addWikiMsg( 'abusefilter-revert-intro', $filter ); |
| 28 | + $out->setPageTitle( wfMsg( 'abusefilter-revert-title', $filter ) ); |
27 | 29 | |
28 | 30 | // First, the search form. |
29 | 31 | $searchFields = array(); |
— | — | @@ -46,18 +48,18 @@ |
47 | 49 | $searchForm = |
48 | 50 | Xml::fieldset( wfMsg( 'abusefilter-revert-search-legend' ), $searchForm ); |
49 | 51 | |
50 | | - $wgOut->addHTML( $searchForm ); |
| 52 | + $out->addHTML( $searchForm ); |
51 | 53 | |
52 | 54 | if ( $this->mSubmit ) { |
53 | 55 | // Add a summary of everything that will be reversed. |
54 | | - $wgOut->addWikiMsg( 'abusefilter-revert-preview-intro' ); |
| 56 | + $out->addWikiMsg( 'abusefilter-revert-preview-intro' ); |
55 | 57 | |
56 | 58 | // Look up all of them. |
57 | 59 | $results = $this->doLookup(); |
| 60 | + $lang = $this->getLang(); |
58 | 61 | $list = array(); |
59 | 62 | |
60 | 63 | foreach ( $results as $result ) { |
61 | | - global $wgLang; |
62 | 64 | $displayActions = array_map( |
63 | 65 | array( 'AbuseFilter', 'getActionDisplay' ), |
64 | 66 | $result['actions'] ); |
— | — | @@ -66,11 +68,11 @@ |
67 | 69 | 'abusefilter-revert-preview-item', |
68 | 70 | array( 'parseinline', 'replaceafter' ), |
69 | 71 | array( |
70 | | - $wgLang->timeanddate( $result['timestamp'], true ), |
| 72 | + $lang->timeanddate( $result['timestamp'], true ), |
71 | 73 | $sk->userLink( $result['userid'], $result['user'] ), |
72 | 74 | $result['action'], |
73 | 75 | $sk->link( $result['title'] ), |
74 | | - $wgLang->commaList( $displayActions ), |
| 76 | + $lang->commaList( $displayActions ), |
75 | 77 | $sk->link( |
76 | 78 | SpecialPage::getTitleFor( 'AbuseLog' ), |
77 | 79 | wfMsgNoTrans( 'abusefilter-log-detailslink' ), |
— | — | @@ -82,11 +84,11 @@ |
83 | 85 | $list[] = Xml::tags( 'li', null, $msg ); |
84 | 86 | } |
85 | 87 | |
86 | | - $wgOut->addHTML( Xml::tags( 'ul', null, implode( "\n", $list ) ) ); |
| 88 | + $out->addHTML( Xml::tags( 'ul', null, implode( "\n", $list ) ) ); |
87 | 89 | |
88 | 90 | // Add a button down the bottom. |
89 | 91 | $confirmForm = |
90 | | - Html::hidden( 'editToken', $wgUser->editToken( "abusefilter-revert-$filter" ) ) . |
| 92 | + Html::hidden( 'editToken', $user->getEditToken( "abusefilter-revert-$filter" ) ) . |
91 | 93 | Html::hidden( 'title', $this->getTitle( "revert/$filter" )->getPrefixedText() ) . |
92 | 94 | Html::hidden( 'wpPeriodStart', $this->origPeriodStart ) . |
93 | 95 | Html::hidden( 'wpPeriodEnd', $this->origPeriodEnd ) . |
— | — | @@ -104,7 +106,7 @@ |
105 | 107 | ), |
106 | 108 | $confirmForm |
107 | 109 | ); |
108 | | - $wgOut->addHTML( $confirmForm ); |
| 110 | + $out->addHTML( $confirmForm ); |
109 | 111 | } |
110 | 112 | } |
111 | 113 | |
— | — | @@ -154,22 +156,20 @@ |
155 | 157 | } |
156 | 158 | |
157 | 159 | function loadParameters() { |
158 | | - global $wgRequest; |
| 160 | + $request = $this->getRequest(); |
159 | 161 | |
160 | | - $this->origPeriodStart = $wgRequest->getText( 'wpPeriodStart' ); |
| 162 | + $this->origPeriodStart = $request->getText( 'wpPeriodStart' ); |
161 | 163 | $this->mPeriodStart = strtotime( $this->origPeriodStart ); |
162 | | - $this->origPeriodEnd = $wgRequest->getText( 'wpPeriodEnd' ); |
| 164 | + $this->origPeriodEnd = $request->getText( 'wpPeriodEnd' ); |
163 | 165 | $this->mPeriodEnd = strtotime( $this->origPeriodEnd ); |
164 | | - $this->mSubmit = $wgRequest->getVal( 'submit' ); |
165 | | - $this->mReason = $wgRequest->getVal( 'wpReason' ); |
| 166 | + $this->mSubmit = $request->getVal( 'submit' ); |
| 167 | + $this->mReason = $request->getVal( 'wpReason' ); |
166 | 168 | } |
167 | 169 | |
168 | 170 | function attemptRevert() { |
169 | | - global $wgUser, $wgRequest, $wgOut; |
170 | | - |
171 | 171 | $filter = $this->mPage->mFilter; |
172 | | - $token = $wgRequest->getVal( 'editToken' ); |
173 | | - if ( !$wgUser->matchEditToken( $token, "abusefilter-revert-$filter" ) ) { |
| 172 | + $token = $this->getRequest()->getVal( 'editToken' ); |
| 173 | + if ( !$this->getUser()->matchEditToken( $token, "abusefilter-revert-$filter" ) ) { |
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
— | — | @@ -180,7 +180,7 @@ |
181 | 181 | $this->revertAction( $action, $result ); |
182 | 182 | } |
183 | 183 | } |
184 | | - $wgOut->addWikiMsg( 'abusefilter-revert-success', $filter ); |
| 184 | + $this->getOutput()->addWikiMsg( 'abusefilter-revert-success', $filter ); |
185 | 185 | |
186 | 186 | return true; |
187 | 187 | } |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php |
— | — | @@ -2,12 +2,11 @@ |
3 | 3 | |
4 | 4 | class ApiAbuseFilterCheckMatch extends ApiBase { |
5 | 5 | public function execute() { |
6 | | - global $wgUser; |
7 | 6 | $params = $this->extractRequestParams(); |
8 | 7 | $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' ); |
9 | 8 | |
10 | 9 | // "Anti-DoS" |
11 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 10 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
12 | 11 | $this->dieUsageMsg( 'permissiondenied' ); |
13 | 12 | } |
14 | 13 | |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php |
— | — | @@ -2,9 +2,7 @@ |
3 | 3 | |
4 | 4 | class ApiAbuseFilterUnblockAutopromote extends ApiBase { |
5 | 5 | public function execute() { |
6 | | - global $wgUser; |
7 | | - |
8 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 6 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
9 | 7 | $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' ); |
10 | 8 | } |
11 | 9 | |
Index: trunk/extensions/AbuseFilter/api/ApiQueryAbuseLog.php |
— | — | @@ -35,8 +35,8 @@ |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function execute() { |
39 | | - global $wgUser; |
40 | | - if ( !$wgUser->isAllowed( 'abusefilter-log' ) ) { |
| 39 | + $user = $this->getUser(); |
| 40 | + if ( !$user->isAllowed( 'abusefilter-log' ) ) { |
41 | 41 | $this->dieUsage( 'You don\'t have permission to view the abuse log', 'permissiondenied' ); |
42 | 42 | } |
43 | 43 | |
— | — | @@ -54,10 +54,10 @@ |
55 | 55 | $fld_timestamp = isset( $prop['timestamp'] ); |
56 | 56 | $fld_hidden = isset( $prop['hidden'] ); |
57 | 57 | |
58 | | - if ( $fld_ip && !$wgUser->isAllowed( 'abusefilter-private' ) ) { |
| 58 | + if ( $fld_ip && !$user->isAllowed( 'abusefilter-private' ) ) { |
59 | 59 | $this->dieUsage( 'You don\'t have permission to view IP addresses', 'permissiondenied' ); |
60 | 60 | } |
61 | | - if ( $fld_details && !$wgUser->isAllowed( 'abusefilter-log-detail' ) ) { |
| 61 | + if ( $fld_details && !$user->isAllowed( 'abusefilter-log-detail' ) ) { |
62 | 62 | $this->dieUsage( 'You don\'t have permission to view detailed abuse log entries', 'permissiondenied' ); |
63 | 63 | } |
64 | 64 | |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | |
92 | 92 | $this->addWhereIf( array( 'afl_user_text' => $params['user'] ), isset( $params['user'] ) ); |
93 | 93 | $this->addWhereIf( array( 'afl_filter' => $params['filter'] ), isset( $params['filter'] ) ); |
94 | | - $this->addWhereIf( $notDeletedCond, !SpecialAbuseLog::canSeeHidden() ); |
| 94 | + $this->addWhereIf( $notDeletedCond, !SpecialAbuseLog::canSeeHidden( $user ) ); |
95 | 95 | |
96 | 96 | $title = $params['title']; |
97 | 97 | if ( !is_null( $title ) ) { |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php |
— | — | @@ -3,10 +3,8 @@ |
4 | 4 | class ApiAbuseFilterCheckSyntax extends ApiBase { |
5 | 5 | |
6 | 6 | public function execute() { |
7 | | - global $wgUser; |
8 | | - |
9 | 7 | // "Anti-DoS" |
10 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 8 | + if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) { |
11 | 9 | $this->dieUsageMsg( 'permissiondenied' ); |
12 | 10 | } |
13 | 11 | |
Index: trunk/extensions/AbuseFilter/api/ApiQueryAbuseFilters.php |
— | — | @@ -35,8 +35,8 @@ |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function execute() { |
39 | | - global $wgUser; |
40 | | - if ( !$wgUser->isAllowed( 'abusefilter-view' ) ) { |
| 39 | + $user = $this->getUser(); |
| 40 | + if ( !$user->isAllowed( 'abusefilter-view' ) ) { |
41 | 41 | $this->dieUsage( 'You don\'t have permission to view abuse filters', 'permissiondenied' ); |
42 | 42 | } |
43 | 43 | |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | |
96 | 96 | $res = $this->select( __METHOD__ ); |
97 | 97 | |
98 | | - $showhidden = $wgUser->isAllowed( 'abusefilter-modify' ); |
| 98 | + $showhidden = $user->isAllowed( 'abusefilter-modify' ); |
99 | 99 | |
100 | 100 | $count = 0; |
101 | 101 | foreach ( $res as $row ) { |