r103298 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103297‎ | r103298 | r103299 >
Date:05:34, 16 November 2011
Author:johnduhart
Status:resolved (Comments)
Tags:
Comment:
Pass one of converting AbuseFilter to use ContextSource

The main AbuseFilter class still needs to be fixed up, but that's a bigger job and I'm out of time
Modified paths:
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterView.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewDiff.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewImport.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewRevert.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewTestBatch.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewTools.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiQueryAbuseFilters.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiQueryAbuseLog.php (modified) (history)
  • /trunk/extensions/AbuseFilter/special/SpecialAbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php
@@ -22,32 +22,33 @@
2323 }
2424
2525 public function execute( $parameter ) {
26 - global $wgUser, $wgOut, $wgRequest;
 26+ $out = $this->getOutput();
 27+ $request = $this->getRequest();
2728
28 - AbuseFilter::addNavigationLinks( $wgOut, $wgUser->getSkin(), 'log' );
 29+ AbuseFilter::addNavigationLinks( $out, $this->getSkin(), 'log' );
2930
3031 $this->setHeaders();
3132 $this->outputHeader( 'abusefilter-log-summary' );
3233 $this->loadParameters();
3334
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 );
3839
39 - $wgOut->addModuleStyles( 'ext.abuseFilter' );
 40+ $out->addModuleStyles( 'ext.abuseFilter' );
4041
4142 // Are we allowed?
4243 $errors = $this->getTitle()->getUserPermissionsErrors(
43 - 'abusefilter-log', $wgUser, true, array( 'ns-specialprotected' ) );
 44+ 'abusefilter-log', $this->getUser(), true, array( 'ns-specialprotected' ) );
4445 if ( count( $errors ) ) {
4546 // Go away.
46 - $wgOut->showPermissionsErrorPage( $errors, 'abusefilter-log' );
 47+ $out->showPermissionsErrorPage( $errors, 'abusefilter-log' );
4748 return;
4849 }
4950
50 - $detailsid = $wgRequest->getIntOrNull( 'details' );
51 - $hideid = $wgRequest->getIntOrNull( 'hide' );
 51+ $detailsid = $request->getIntOrNull( 'details' );
 52+ $hideid = $request->getIntOrNull( 'hide' );
5253
5354 if ( $parameter ) {
5455 $detailsid = $parameter;
@@ -67,9 +68,9 @@
6869 }
6970
7071 function loadParameters() {
71 - global $wgRequest;
 72+ $request = $this->getRequest();
7273
73 - $this->mSearchUser = $wgRequest->getText( 'wpSearchUser' );
 74+ $this->mSearchUser = $request->getText( 'wpSearchUser' );
7475
7576 $t = Title::newFromText( trim( $this->mSearchUser ) );
7677 if ( $t ) {
@@ -78,23 +79,21 @@
7980 $this->mSearchUser = null;
8081 }
8182
82 - $this->mSearchTitle = $wgRequest->getText( 'wpSearchTitle' );
 83+ $this->mSearchTitle = $request->getText( 'wpSearchTitle' );
8384 $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' );
8687 }
8788 }
8889
8990 function searchForm() {
90 - global $wgOut;
91 -
9291 $output = Xml::element( 'legend', null, wfMsg( 'abusefilter-log-search' ) );
9392 $fields = array();
9493
9594 // Search conditions
9695 $fields['abusefilter-log-search-user'] =
9796 Xml::input( 'wpSearchUser', 45, $this->mSearchUser );
98 - if ( self::canSeeDetails() ) {
 97+ if ( self::canSeeDetails( $this->getUser() ) ) {
9998 $fields['abusefilter-log-search-filter'] =
10099 Xml::input( 'wpSearchFilter', 45, $this->mSearchFilter );
101100 }
@@ -109,14 +108,12 @@
110109 $form );
111110 $output = Xml::tags( 'fieldset', null, $output );
112111
113 - $wgOut->addHTML( $output );
 112+ $this->getOutput()->addHTML( $output );
114113 }
115114
116115 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' );
121118 return;
122119 }
123120
@@ -152,7 +149,7 @@
153150 ),
154151 );
155152
156 - $form = new HTMLForm( $formInfo );
 153+ $form = new HTMLForm( $formInfo, $this->getContext() );
157154 $form->setTitle( $this->getTitle() );
158155 $form->setWrapperLegend( wfMsgExt( 'abusefilter-log-hide-legend', 'parsemag' ) );
159156 $form->addHiddenField( 'hide', $id );
@@ -161,8 +158,7 @@
162159 }
163160
164161 function saveHideForm( $fields ) {
165 - global $wgRequest, $wgOut;
166 - $logid = $wgRequest->getVal( 'hide' );
 162+ $logid = $this->getRequest()->getVal( 'hide' );
167163
168164 $dbw = wfGetDB( DB_MASTER );
169165
@@ -178,13 +174,13 @@
179175
180176 $logPage->addEntry( $action, $this->getTitle( $logid ), $fields['reason'] );
181177
182 - $wgOut->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() );
 178+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() );
183179
184180 return true;
185181 }
186182
187183 function showList() {
188 - global $wgOut;
 184+ $out = $this->getOutput();
189185
190186 // Generate conditions list.
191187 $conds = array();
@@ -216,16 +212,17 @@
217213 $pager->doQuery();
218214 $result = $pager->getResult();
219215 if( $result && $result->numRows() !== 0 ) {
220 - $wgOut->addHTML( $pager->getNavigationBar() .
 216+ $out->addHTML( $pager->getNavigationBar() .
221217 Xml::tags( 'ul', null, $pager->getBody() ) .
222218 $pager->getNavigationBar() );
223219 } else {
224 - $wgOut->addWikiMsg( 'abusefilter-log-noresults' );
 220+ $out->addWikiMsg( 'abusefilter-log-noresults' );
225221 }
226222 }
227223
228224 function showDetails( $id ) {
229 - if ( !self::canSeeDetails() ) {
 225+ $out = $this->getOutput();
 226+ if ( !self::canSeeDetails( $this->getUser() ) ) {
230227 return;
231228 }
232229
@@ -244,9 +241,8 @@
245242 return;
246243 }
247244
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' );
251247 return;
252248 }
253249
@@ -291,7 +287,7 @@
292288 // Build a table.
293289 $output .= AbuseFilter::buildVarDumpTable( $vars );
294290
295 - if ( self::canSeePrivate() ) {
 291+ if ( self::canSeePrivate( $this->getUser() ) ) {
296292 // Private stuff, like IPs.
297293 $header =
298294 Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-var' ) ) .
@@ -322,46 +318,42 @@
323319
324320 $output = Xml::tags( 'fieldset', null, $output );
325321
326 - global $wgOut;
327 - $wgOut->addHTML( $output );
 322+ $out->addHTML( $output );
328323 }
329324
330325 /**
 326+ * @param $user User
331327 * @return bool
332328 */
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' );
336331 }
337332
338333 /**
 334+ * @param $user User
339335 * @return bool
340336 */
341 - static function canSeePrivate() {
 337+ static function canSeePrivate( User $user ) {
342338 global $wgUser;
343339 return $wgUser->isAllowed( 'abusefilter-private' );
344340 }
345341
346342 /**
 343+ * @param $user User
347344 * @return bool
348345 */
349 - static function canSeeHidden() {
 346+ static function canSeeHidden( User $user ) {
350347 global $wgUser;
351348 return $wgUser->isAllowed( 'abusefilter-hidden-log' );
352349 }
353350
354351 function formatRow( $row, $li = true ) {
355 - global $wgLang, $wgUser;
 352+ $user = $this->getUser();
 353+ $sk = $this->getSkin();
 354+ $lang = $this->getLang();
356355
357 - # One-time setup
358 - static $sk = null;
359 -
360356 $actionLinks = array();
361357
362 - if ( is_null( $sk ) ) {
363 - $sk = $wgUser->getSkin();
364 - }
365 -
366358 $title = Title::makeTitle( $row->afl_namespace, $row->afl_title );
367359
368360 if ( !$row->afl_wiki ) {
@@ -372,14 +364,14 @@
373365
374366 if ( !$row->afl_wiki ) {
375367 // Local user
376 - $user = $sk->userLink( $row->afl_user, $row->afl_user_text ) .
 368+ $userLink = $sk->userLink( $row->afl_user, $row->afl_user_text ) .
377369 $sk->userToolLinks( $row->afl_user, $row->afl_user_text );
378370 } 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 ) . ')';
381373 }
382374
383 - $timestamp = $wgLang->timeanddate( $row->afl_timestamp, true );
 375+ $timestamp = $lang->timeanddate( $row->afl_timestamp, true );
384376
385377 $actions_taken = $row->afl_actions;
386378 if ( !strlen( trim( $actions_taken ) ) ) {
@@ -391,7 +383,7 @@
392384 foreach ( $actions as $action ) {
393385 $displayActions[] = AbuseFilter::getActionDisplay( $action );
394386 }
395 - $actions_taken = $wgLang->commaList( $displayActions );
 387+ $actions_taken = $lang->commaList( $displayActions );
396388 }
397389
398390 $globalIndex = AbuseFilter::decodeGlobalName( $row->afl_filter );
@@ -405,7 +397,7 @@
406398 $parsed_comments = $wgOut->parseInline( $row->af_public_comments );
407399 }
408400
409 - if ( self::canSeeDetails() ) {
 401+ if ( self::canSeeDetails( $user ) ) {
410402 $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id );
411403 $detailsLink = $sk->makeKnownLinkObj(
412404 $this->getTitle($row->afl_id),
@@ -420,7 +412,7 @@
421413 $actionLinks[] = $detailsLink;
422414 $actionLinks[] = $examineLink;
423415
424 - if ( $wgUser->isAllowed( 'abusefilter-hide-log' ) ) {
 416+ if ( $user->isAllowed( 'abusefilter-hide-log' ) ) {
425417 $hideLink = $sk->link(
426418 $this->getTitle(),
427419 wfMsg( 'abusefilter-log-hidelink' ),
@@ -448,13 +440,13 @@
449441 array( 'parseinline', 'replaceafter' ),
450442 array(
451443 $timestamp,
452 - $user,
 444+ $userLink,
453445 $filterLink,
454446 $row->afl_action,
455447 $pageLink,
456448 $actions_taken,
457449 $parsed_comments,
458 - $wgLang->pipeList( $actionLinks ),
 450+ $lang->pipeList( $actionLinks ),
459451 )
460452 );
461453 } else {
@@ -463,7 +455,7 @@
464456 array( 'parseinline', 'replaceafter' ),
465457 array(
466458 $timestamp,
467 - $user,
 459+ $userLink,
468460 $row->afl_action,
469461 $sk->link( $title ),
470462 $actions_taken,
Index: trunk/extensions/AbuseFilter/special/SpecialAbuseFilter.php
@@ -4,37 +4,32 @@
55 }
66
77 class SpecialAbuseFilter extends SpecialPage {
8 - var $mSkin;
9 -
108 public function __construct() {
119 parent::__construct( 'AbuseFilter', 'abusefilter-view' );
1210 }
1311
1412 public function execute( $subpage ) {
15 - global $wgUser, $wgOut, $wgRequest;
 13+ $out = $this->getOutput();
 14+ $request = $this->getRequest();
1615
17 - $wgOut->addModuleStyles( 'ext.abuseFilter' );
 16+ $out->addModuleStyles( 'ext.abuseFilter' );
1817 $view = 'AbuseFilterViewList';
1918
2019 $this->setHeaders();
2120
2221 $this->loadParameters( $subpage );
23 - $wgOut->setPageTitle( wfMsg( 'abusefilter-management' ) );
 22+ $out->setPageTitle( $this->msg( 'abusefilter-management' ) );
2423
2524 // Are we allowed?
26 - if ( !$wgUser->isAllowed( 'abusefilter-view' ) ) {
27 - $this->displayRestrictionError();
28 - return;
29 - }
 25+ $this->checkPermissions();
3026
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>',
3531 array( 'abusefilter-edit-done', $changedFilter ) );
3632 }
3733
38 - $this->mSkin = $wgUser->getSkin();
3934 $this->mHistoryID = null;
4035 $pageType = 'home';
4136
@@ -100,19 +95,17 @@
10196 }
10297
10398 // Links at the top
104 - AbuseFilter::addNavigationLinks( $wgOut, $this->mSkin, $pageType );
 99+ AbuseFilter::addNavigationLinks( $out, $this->getSkin(), $pageType );
105100
106101 $v = new $view( $this, $params );
107102 $v->show();
108103 }
109104
110105 function loadParameters( $subpage ) {
111 - global $wgRequest;
112 -
113106 $filter = $subpage;
114107
115108 if ( !is_numeric( $filter ) && $filter != 'new' ) {
116 - $filter = $wgRequest->getIntOrNull( 'wpFilter' );
 109+ $filter = $this->getRequest()->getIntOrNull( 'wpFilter' );
117110 }
118111 $this->mFilter = $filter;
119112 }
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewDiff.php
@@ -10,9 +10,8 @@
1111
1212 function show() {
1313 $show = $this->loadData();
 14+ $out = $this->getOutput();
1415
15 - global $wgOut, $wgLang;
16 -
1716 $links = array();
1817 if ( $this->mFilter ) {
1918 $links['abusefilter-history-backedit'] = $this->getTitle( $this->mFilter );
@@ -23,24 +22,22 @@
2423 $links[$msg] = Linker::link( $title, wfMsgExt( $msg, 'parseinline' ) );
2524 }
2625
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 ) );
2928
3029 if ( $show ) {
31 - $wgOut->addHTML( $this->formatDiff() );
 30+ $out->addHTML( $this->formatDiff() );
3231 }
3332 }
3433
3534 function loadData() {
36 - global $wgUser;
3735 $oldSpec = $this->mParams[3];
3836 $newSpec = $this->mParams[4];
3937 $this->mFilter = $this->mParams[1];
4038
4139 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' );
4542 return false;
4643 }
4744
@@ -48,8 +45,7 @@
4946 $this->mNewVersion = $this->loadSpec( $newSpec, $oldSpec );
5047
5148 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' );
5450 return false;
5551 }
5652
@@ -153,10 +149,8 @@
154150 }
155151
156152 function formatVersionLink( $timestamp, $history_id ) {
157 - global $wgLang;
158 -
159153 $filter = $this->mFilter;
160 - $text = $wgLang->timeanddate( $timestamp, true );
 154+ $text = $this->getLang()->timeanddate( $timestamp, true );
161155 $title = $this->getTitle( "history/$filter/item/$history_id" );
162156
163157 $link = Linker::link( $title, $text );
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewImport.php
@@ -2,13 +2,13 @@
33 class AbuseFilterViewImport extends AbuseFilterView {
44
55 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' );
99 return;
1010 }
1111
12 - $wgOut->addWikiMsg( 'abusefilter-import-intro' );
 12+ $out->addWikiMsg( 'abusefilter-import-intro' );
1313
1414 $html = Xml::textarea( 'wpImportText', '', 40, 20 );
1515 $html .= Xml::submitButton(
@@ -19,6 +19,6 @@
2020
2121 $html = Xml::tags( 'form', array( 'method' => 'post', 'action' => $url ), $html );
2222
23 - $wgOut->addHTML( $html );
 23+ $out->addHTML( $html );
2424 }
2525 }
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
@@ -2,25 +2,26 @@
33
44 class AbuseFilterViewList extends AbuseFilterView {
55 function show() {
6 - global $wgOut, $wgRequest;
 6+ $out = $this->getOutput();
 7+ $request = $this->getRequest();
78
89 // Status info...
910 $this->showStatus();
1011
11 - $wgOut->addWikiMsg( 'abusefilter-intro' );
 12+ $out->addWikiMsg( 'abusefilter-intro' );
1213
1314 // New filter button
1415 if ( $this->canEdit() ) {
1516 $title = $this->getTitle( 'new' );
1617 $link = Linker::link( $title, wfMsg( 'abusefilter-new' ) );
1718 $links = Xml::tags( 'p', null, $link ) . "\n";
18 - $wgOut->addHTML( $links );
 19+ $out->addHTML( $links );
1920 }
2021
2122 // Options.
2223 $conds = array();
23 - $deleted = $wgRequest->getVal( 'deletedfilters' );
24 - $hidedisabled = $wgRequest->getBool( 'hidedisabled' );
 24+ $deleted = $request->getVal( 'deletedfilters' );
 25+ $hidedisabled = $request->getBool( 'hidedisabled' );
2526 if ( $deleted == 'show' ) {
2627 # Nothing
2728 } elseif ( $deleted == 'only' ) {
@@ -38,8 +39,6 @@
3940 }
4041
4142 function showList( $conds = array( 'af_deleted' => 0 ), $optarray = array() ) {
42 - global $wgOut;
43 -
4443 $output = '';
4544 $output .= Xml::element( 'h2', null,
4645 wfMsgExt( 'abusefilter-list', array( 'parseinline' ) ) );
@@ -100,11 +99,11 @@
101100 $pager->getBody() .
102101 $pager->getNavigationBar();
103102
104 - $wgOut->addHTML( $output );
 103+ $this->getOutput()->addHTML( $output );
105104 }
106105
107106 function showStatus() {
108 - global $wgMemc, $wgAbuseFilterConditionLimit, $wgOut, $wgLang;
 107+ global $wgMemc, $wgAbuseFilterConditionLimit;
109108
110109 $overflow_count = (int)$wgMemc->get( AbuseFilter::filterLimitReachedKey() );
111110 $match_count = (int) $wgMemc->get( AbuseFilter::filterMatchesKey() );
@@ -114,17 +113,18 @@
115114 $overflow_percent = sprintf( "%.2f", 100 * $overflow_count / $total_count );
116115 $match_percent = sprintf( "%.2f", 100 * $match_count / $total_count );
117116
 117+ $lang = $this->getLang();
118118 $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 )
125125 );
126126
127127 $status = Xml::tags( 'div', array( 'class' => 'mw-abusefilter-status' ), $status );
128 - $wgOut->addHTML( $status );
 128+ $this->getOutput()->addHTML( $status );
129129 }
130130 }
131131 }
@@ -134,7 +134,7 @@
135135 function __construct( $page, $conds ) {
136136 $this->mPage = $page;
137137 $this->mConds = $conds;
138 - parent::__construct();
 138+ parent::__construct( $this->mPage->getContext() );
139139 }
140140
141141 function getQueryInfo() {
@@ -180,18 +180,17 @@
181181 }
182182
183183 function formatValue( $name, $value ) {
184 - global $wgOut, $wgLang;
185 -
 184+ $lang = $this->getLang();
186185 $row = $this->mCurrentRow;
187186
188187 switch( $name ) {
189188 case 'af_id':
190189 return Linker::link(
191 - SpecialPage::getTitleFor( 'AbuseFilter', intval( $value ) ), $wgLang->formatNum( intval( $value ) ) );
 190+ SpecialPage::getTitleFor( 'AbuseFilter', intval( $value ) ), $lang->formatNum( intval( $value ) ) );
192191 case 'af_public_comments':
193192 return Linker::link(
194193 SpecialPage::getTitleFor( 'AbuseFilter', intval( $row->af_id ) ),
195 - $wgOut->parseInline( $value )
 194+ $this->getOutput()->parseInline( $value )
196195 );
197196 case 'af_actions':
198197 $actions = explode( ',', $value );
@@ -199,7 +198,7 @@
200199 foreach ( $actions as $action ) {
201200 $displayActions[] = AbuseFilter::getActionDisplay( $action );
202201 }
203 - return htmlspecialchars( $wgLang->commaList( $displayActions ) );
 202+ return htmlspecialchars( $lang->commaList( $displayActions ) );
204203 case 'af_enabled':
205204 $statuses = array();
206205 if ( $row->af_deleted ) {
@@ -215,7 +214,7 @@
216215 $statuses[] = wfMsgExt( 'abusefilter-status-global', 'parseinline' );
217216 }
218217
219 - return $wgLang->commaList( $statuses );
 218+ return $lang->commaList( $statuses );
220219 case 'af_hidden':
221220 $msg = $value ? 'abusefilter-hidden' : 'abusefilter-unhidden';
222221 return wfMsgExt( $msg, 'parseinline' );
@@ -223,7 +222,7 @@
224223 $count_display = wfMsgExt(
225224 'abusefilter-hitcount',
226225 array( 'parseinline' ),
227 - $wgLang->formatNum( $value )
 226+ $lang->formatNum( $value )
228227 );
229228 // @todo FIXME: makeKnownLinkObj() is deprecated.
230229 $link = Linker::makeKnownLinkObj(
@@ -246,10 +245,10 @@
247246 return wfMsgExt(
248247 'abusefilter-edit-lastmod-text',
249248 array( 'replaceafter', 'parseinline' ),
250 - array( $wgLang->timeanddate( $value, true ),
 249+ array( $lang->timeanddate( $value, true ),
251250 $userLink,
252 - $wgLang->date( $value, true ),
253 - $wgLang->time( $value, true ),
 251+ $lang->date( $value, true ),
 252+ $lang->time( $value, true ),
254253 $user )
255254 );
256255 default:
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php
@@ -1,9 +1,14 @@
22 <?php
33
4 -abstract class AbuseFilterView {
 4+abstract class AbuseFilterView extends ContextSource {
 5+ /**
 6+ * @param $page SpecialPage
 7+ * @param $params array
 8+ */
59 function __construct( $page, $params ) {
610 $this->mPage = $page;
711 $this->mParams = $params;
 12+ $this->setContext( $this->mPage->getContext() );
813 }
914
1015 /**
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewTools.php
@@ -4,17 +4,18 @@
55
66 class AbuseFilterViewTools extends AbuseFilterView {
77 function show() {
8 - global $wgOut, $wgUser;
 8+ $out = $this->getOutput();
 9+ $user = $this->getUser();
910
1011 // Header
11 - $wgOut->addWikiMsg( 'abusefilter-tools-text' );
 12+ $out->addWikiMsg( 'abusefilter-tools-text' );
1213
1314 // Expression evaluator
1415 $eval = '';
1516 $eval .= AbuseFilter::buildEditBox( '', 'wpTestExpr' );
1617
1718 // Only let users with permission actually test it
18 - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) {
 19+ if ( $user->isAllowed( 'abusefilter-modify' ) ) {
1920 $eval .= Xml::tags( 'p', null,
2021 Xml::element( 'input',
2122 array(
@@ -26,11 +27,11 @@
2728 $eval .= Xml::element( 'p', array( 'id' => 'mw-abusefilter-expr-result' ), ' ' );
2829 }
2930 $eval = Xml::fieldset( wfMsg( 'abusefilter-tools-expr' ), $eval );
30 - $wgOut->addHTML( $eval );
 31+ $out->addHTML( $eval );
3132
32 - $wgOut->addModules( 'ext.abuseFilter.tools' );
 33+ $out->addModules( 'ext.abuseFilter.tools' );
3334
34 - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) {
 35+ if ( $user->isAllowed( 'abusefilter-modify' ) ) {
3536 // Hacky little box to re-enable autoconfirmed if it got disabled
3637 $rac = '';
3738 $rac .= Xml::inputLabel(
@@ -49,7 +50,7 @@
5051 )
5152 );
5253 $rac = Xml::fieldset( wfMsg( 'abusefilter-tools-reautoconfirm' ), $rac );
53 - $wgOut->addHTML( $rac );
 54+ $out->addHTML( $rac );
5455 }
5556 }
5657 }
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
@@ -10,26 +10,25 @@
1111 }
1212
1313 function show() {
14 - global $wgRequest, $wgOut, $wgLang, $wgUser;
15 -
 14+ $out = $this->getOutput();
1615 $filter = $this->mFilter;
1716
1817 if ( $filter ) {
19 - $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
 18+ $out->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
2019 } else {
21 - $wgOut->setPageTitle( wfMsg( 'abusefilter-filter-log' ) );
 20+ $out->setPageTitle( wfMsg( 'abusefilter-filter-log' ) );
2221 }
2322
2423 # Check perms
2524 if ( $filter &&
26 - !$wgUser->isAllowed( 'abusefilter-modify' ) &&
 25+ !$this->getUser()->isAllowed( 'abusefilter-modify' ) &&
2726 AbuseFilter::filterHidden( $filter ) ) {
28 - $wgOut->addWikiMsg( 'abusefilter-history-error-hidden' );
 27+ $out->addWikiMsg( 'abusefilter-history-error-hidden' );
2928 return;
3029 }
3130
3231 # Useful links
33 - $sk = $wgUser->getSkin();
 32+ $sk = $this->getSkin();
3433 $links = array();
3534 if ( $filter ) {
3635 $links['abusefilter-history-backedit'] = $this->getTitle( $filter );
@@ -39,13 +38,13 @@
4039 $links[$msg] = $sk->link( $title, wfMsgExt( $msg, 'parseinline' ) );
4140 }
4241
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 ) );
4544
4645 # For user
47 - $user = $wgRequest->getText( 'user' );
 46+ $user = $this->getRequest()->getText( 'user' );
4847 if ( $user ) {
49 - $wgOut->setSubtitle(
 48+ $out->setSubtitle(
5049 wfMsg(
5150 'abusefilter-history-foruser',
5251 $sk->userLink( 1 /* We don't really need to get a user ID */, $user ),
@@ -67,12 +66,12 @@
6867 $filterForm
6968 );
7069 $filterForm = Xml::fieldset( wfMsg( 'abusefilter-history-select-legend' ), $filterForm );
71 - $wgOut->addHTML( $filterForm );
 70+ $out->addHTML( $filterForm );
7271
7372 $pager = new AbuseFilterHistoryPager( $filter, $this, $user );
7473 $table = $pager->getBody();
7574
76 - $wgOut->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() );
 75+ $out->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() );
7776 }
7877 }
7978
@@ -88,7 +87,7 @@
8988 $this->mPage = $page;
9089 $this->mUser = $user;
9190 $this->mDefaultDirection = true;
92 - parent::__construct();
 91+ parent::__construct( $this->mPage->getContext() );
9392 }
9493
9594 function getFieldNames() {
@@ -119,25 +118,19 @@
120119 }
121120
122121 function formatValue( $name, $value ) {
123 - global $wgOut, $wgLang;
 122+ $sk = $this->getSkin();
 123+ $lang = $this->getLang();
124124
125 - static $sk = null;
126 -
127 - if ( empty( $sk ) ) {
128 - global $wgUser;
129 - $sk = $wgUser->getSkin();
130 - }
131 -
132125 $row = $this->mCurrentRow;
133126
134127 switch( $name ) {
135128 case 'afh_filter':
136 - $formatted = $wgLang->formatNum ( $row->afh_filter );
 129+ $formatted = $lang->formatNum ( $row->afh_filter );
137130 break;
138131 case 'afh_timestamp':
139132 $title = SpecialPage::getTitleFor( 'AbuseFilter',
140133 '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 ) );
142135 break;
143136 case 'afh_user_text':
144137 $formatted =
@@ -145,7 +138,7 @@
146139 $sk->userToolLinks( $row->afh_user, $row->afh_user_text );
147140 break;
148141 case 'afh_public_comments':
149 - $formatted = $wgOut->parse( $value );
 142+ $formatted = $this->getOutput()->parse( $value );
150143 break;
151144 case 'afh_flags':
152145 $formatted = AbuseFilter::formatFlags( $value );
@@ -231,8 +224,6 @@
232225 ),
233226 );
234227
235 - global $wgUser;
236 -
237228 if ( $this->mUser ) {
238229 $info['conds']['afh_user_text'] = $this->mUser;
239230 }
@@ -241,7 +232,7 @@
242233 $info['conds']['afh_filter'] = $this->mFilter;
243234 }
244235
245 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 236+ if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
246237 // Hide data the user can't see.
247238 $info['conds']['af_hidden'] = 0;
248239 }
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewTestBatch.php
@@ -8,19 +8,19 @@
99 static $mChangeLimit = 100;
1010
1111 function show() {
12 - global $wgOut, $wgUser, $wgRequest;
 12+ $out = $this->getOutput();
1313
1414 AbuseFilter::disableConditionLimit();
1515
16 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
17 - $wgOut->addWikiMsg( 'abusefilter-mustbeeditor' );
 16+ if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
 17+ $out->addWikiMsg( 'abusefilter-mustbeeditor' );
1818 return;
1919 }
2020
2121 $this->loadParameters();
2222
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 );
2525
2626 $output = '';
2727 $output .= AbuseFilter::buildEditBox( $this->mFilter, 'wpTestFilter' ) . "\n";
@@ -68,19 +68,19 @@
6969
7070 $output = Xml::fieldset( wfMsg( 'abusefilter-test-legend' ), $output );
7171
72 - $wgOut->addHTML( $output );
 72+ $out->addHTML( $output );
7373
74 - if ( $wgRequest->wasPosted() ) {
 74+ if ( $this->getRequest()->wasPosted() ) {
7575 $this->doTest();
7676 }
7777 }
7878
7979 function doTest() {
8080 // Quick syntax check.
81 - global $wgUser, $wgOut;
 81+ $out = $this->getOutput();
8282 $result = AbuseFilter::checkSyntax( $this->mFilter );
8383 if ( $result !== true ) {
84 - $wgOut->addWikiMsg( 'abusefilter-test-syntaxerr' );
 84+ $out->addWikiMsg( 'abusefilter-test-syntaxerr' );
8585 return;
8686 }
8787 $dbr = wfGetDB( DB_SLAVE );
@@ -102,7 +102,7 @@
103103 }
104104
105105 // Get our ChangesList
106 - $changesList = new AbuseFilterChangesList( $wgUser->getSkin() );
 106+ $changesList = new AbuseFilterChangesList( $this->getSkin() );
107107 $output = $changesList->beginRecentChangesList();
108108
109109 $res = $dbr->select(
@@ -136,18 +136,18 @@
137137
138138 $output .= $changesList->endRecentChangesList();
139139
140 - $wgOut->addHTML( $output );
 140+ $out->addHTML( $output );
141141 }
142142
143143 function loadParameters() {
144 - global $wgRequest;
 144+ $request = $this->getRequest();
145145
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' );
152152
153153 if ( !$this->mFilter
154154 && count( $this->mParams ) > 1
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php
@@ -11,26 +11,27 @@
1212 }
1313
1414 function show() {
15 - global $wgRequest, $wgUser, $wgOut;
 15+ $user = $this->getUser();
 16+ $out = $this->getOutput();
 17+ $request = $this->getRequest();
1618
1719 $filter = $this->mFilter;
1820 $history_id = $this->mHistoryID;
19 - $this->mSkin = $wgUser->getSkin();
2021
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' );
2324 return;
2425 }
2526
26 - $editToken = $wgRequest->getVal( 'wpEditToken' );
 27+ $editToken = $request->getVal( 'wpEditToken' );
2728 $didEdit = $this->canEdit()
28 - && $wgUser->matchEditToken( $editToken, array( 'abusefilter', $filter ) );
 29+ && $user->matchEditToken( $editToken, array( 'abusefilter', $filter ) );
2930
3031 if ( $didEdit ) {
3132 // Check syntax
32 - $syntaxerr = AbuseFilter::checkSyntax( $wgRequest->getVal( 'wpFilterRules' ) );
 33+ $syntaxerr = AbuseFilter::checkSyntax( $request->getVal( 'wpFilterRules' ) );
3334 if ( $syntaxerr !== true ) {
34 - $wgOut->addHTML(
 35+ $out->addHTML(
3536 $this->buildFilterEditor(
3637 wfMsgExt(
3738 'abusefilter-edit-badsyntax',
@@ -57,7 +58,7 @@
5859
5960 // Check for non-changes
6061 if ( !count( $differences ) ) {
61 - $wgOut->redirect( $this->getTitle()->getLocalURL() );
 62+ $out->redirect( $this->getTitle()->getLocalURL() );
6263 return;
6364 }
6465
@@ -67,9 +68,9 @@
6869 array_intersect(
6970 $wgAbuseFilterRestrictedActions,
7071 array_keys( array_filter( $actions ) ) )
71 - && !$wgUser->isAllowed( 'abusefilter-modify-restricted' ) )
 72+ && !$user->isAllowed( 'abusefilter-modify-restricted' ) )
7273 {
73 - $wgOut->addHTML(
 74+ $out->addHTML(
7475 $this->buildFilterEditor(
7576 wfMsgExt( 'abusefilter-edit-restricted', 'parse' ),
7677 $this->mFilter,
@@ -89,7 +90,7 @@
9091 }
9192
9293 if ( $bad ) {
93 - $wgOut->addHTML(
 94+ $out->addHTML(
9495 $this->buildFilterEditor(
9596 wfMsgExt( 'abusefilter-edit-bad-tags', 'parse' ),
9697 $this->mFilter,
@@ -105,8 +106,8 @@
106107
107108 // Set last modifier.
108109 $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();
111112
112113 $dbw->begin();
113114
@@ -215,46 +216,44 @@
216217
217218 AbuseFilter::resetFilterProfile( $new_id );
218219
219 - global $wgOut;
220 -
221 - $wgOut->redirect(
 220+ $out->redirect(
222221 $this->getTitle()->getLocalURL( 'result=success&changedfilter=' . $new_id ) );
223222 } else {
224223 if ( $history_id ) {
225 - $wgOut->addWikiMsg(
 224+ $out->addWikiMsg(
226225 'abusefilter-edit-oldwarning', $this->mHistoryID, $this->mFilter );
227226 }
228227
229 - $wgOut->addHTML( $this->buildFilterEditor( null, $this->mFilter, $history_id ) );
 228+ $out->addHTML( $this->buildFilterEditor( null, $this->mFilter, $history_id ) );
230229
231230 if ( $history_id ) {
232 - $wgOut->addWikiMsg(
 231+ $out->addWikiMsg(
233232 'abusefilter-edit-oldwarning', $this->mHistoryID, $this->mFilter );
234233 }
235234 }
236235 }
237236
238237 function buildFilterEditor( $error, $filter, $history_id = null ) {
239 - global $wgLang;
240 -
241238 if ( $filter === null ) {
242239 return false;
243240 }
244241
245242 // 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();
248247
249248 // Load from request OR database.
250249 list( $row, $actions ) = $this->loadRequest( $filter, $history_id );
251250
252251 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' ) ) );
255254 return;
256255 }
257256
258 - $wgOut->setSubtitle( wfMsg( 'abusefilter-edit-subtitle', $filter, $history_id ) );
 257+ $out->setSubtitle( wfMsg( 'abusefilter-edit-subtitle', $filter, $history_id ) );
259258
260259 // Hide hidden filters.
261260 if ( ( ( isset( $row->af_hidden ) && $row->af_hidden ) ||
@@ -265,7 +264,7 @@
266265
267266 $output = '';
268267 if ( $error ) {
269 - $wgOut->addHTML( "<span class=\"error\">$error</span>" );
 268+ $out->addHTML( "<span class=\"error\">$error</span>" );
270269 }
271270
272271 // Read-only attribute
@@ -280,7 +279,7 @@
281280 $fields = array();
282281
283282 $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 );
285284 $fields['abusefilter-edit-description'] =
286285 Xml::input(
287286 'wpFilterDescription',
@@ -293,7 +292,7 @@
294293 if ( !empty( $row->af_hit_count ) ) {
295294 $count = (int)$row->af_hit_count;
296295 $count_display = wfMsgExt( 'abusefilter-hitcount', array( 'parseinline' ),
297 - $wgLang->formatNum( $count )
 296+ $lang->formatNum( $count )
298297 );
299298 $hitCount = $sk->makeKnownLinkObj(
300299 SpecialPage::getTitleFor( 'AbuseLog' ),
@@ -306,10 +305,11 @@
307306
308307 if ( $filter !== 'new' ) {
309308 // Statistics
310 - global $wgMemc, $wgLang;
 309+ global $wgMemc;
311310 $matches_count = $wgMemc->get( AbuseFilter::filterMatchesKey( $filter ) );
312311 $total = $wgMemc->get( AbuseFilter::filterUsedKey() );
313312
 313+
314314 if ( $total > 0 ) {
315315 $matches_percent = sprintf( '%.2f', 100 * $matches_count / $total );
316316 list( $timeProfile, $condProfile ) = AbuseFilter::getFilterProfile( $filter );
@@ -317,11 +317,11 @@
318318 $fields['abusefilter-edit-status-label'] =
319319 wfMsgExt( 'abusefilter-edit-status', array( 'parsemag', 'escape' ),
320320 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 )
326326 )
327327 );
328328 }
@@ -350,10 +350,10 @@
351351 if ( isset( $row->af_throttled ) && $row->af_throttled ) {
352352 global $wgAbuseFilterEmergencyDisableThreshold;
353353 $threshold_percent = sprintf( '%.2f', $wgAbuseFilterEmergencyDisableThreshold * 100 );
354 - $flags .= $wgOut->parse(
 354+ $flags .= $out->parse(
355355 wfMsg(
356356 'abusefilter-edit-throttled',
357 - $wgLang->formatNum( $threshold_percent )
 357+ $lang->formatNum( $threshold_percent )
358358 )
359359 );
360360 }
@@ -377,7 +377,7 @@
378378 $fields['abusefilter-edit-flags'] = $flags;
379379 $tools = '';
380380
381 - if ( $filter != 'new' && $wgUser->isAllowed( 'abusefilter-revert' ) ) {
 381+ if ( $filter != 'new' && $user->isAllowed( 'abusefilter-revert' ) ) {
382382 $tools .= Xml::tags(
383383 'p', null,
384384 $sk->link(
@@ -405,10 +405,10 @@
406406 wfMsgExt(
407407 'abusefilter-edit-lastmod-text',
408408 array( 'parseinline', 'replaceafter' ),
409 - array( $wgLang->timeanddate( $row->af_timestamp, true ),
 409+ array( $lang->timeanddate( $row->af_timestamp, true ),
410410 $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 ),
413413 $user
414414 )
415415 );
@@ -439,7 +439,7 @@
440440 $form .= Xml::submitButton( wfMsg( 'abusefilter-edit-save' ), array( 'accesskey' => 's' ) );
441441 $form .= Html::hidden(
442442 'wpEditToken',
443 - $wgUser->editToken( array( 'abusefilter', $filter ) )
 443+ $user->getEditToken( array( 'abusefilter', $filter ) )
444444 );
445445 }
446446
@@ -655,14 +655,14 @@
656656
657657 $existingSelector->addOption( 'abusefilter-warning' );
658658
659 - global $wgLang;
 659+ $lang = $this->getLang();
660660 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 ) );
663663 }
664664
665665 if ( $row->page_title != 'Abusefilter-warning' ) {
666 - $existingSelector->addOption( $wgLang->lcfirst( $row->page_title ) );
 666+ $existingSelector->addOption( $lang->lcfirst( $row->page_title ) );
667667 }
668668 }
669669
@@ -733,11 +733,11 @@
734734 function loadRequest( $filter, $history_id = null ) {
735735 static $row = null;
736736 static $actions = null;
737 - global $wgRequest;
 737+ $request = $this->getRequest();
738738
739739 if ( !is_null( $actions ) && !is_null( $row ) ) {
740740 return array( $row, $actions );
741 - } elseif ( $wgRequest->wasPosted() ) {
 741+ } elseif ( $request->wasPosted() ) {
742742 # Nothing, we do it all later
743743 } elseif ( $history_id ) {
744744 return $this->loadHistoryItem( $history_id );
@@ -752,7 +752,7 @@
753753 $row->mOriginalActions = $origActions;
754754
755755 // Check for importing
756 - $import = $wgRequest->getVal( 'wpImportText' );
 756+ $import = $request->getVal( 'wpImportText' );
757757 if ( $import ) {
758758 $data = json_decode( $import );
759759
@@ -779,44 +779,44 @@
780780 );
781781
782782 foreach ( $textLoads as $col => $field ) {
783 - $row->$col = trim( $wgRequest->getVal( $field ) );
 783+ $row->$col = trim( $request->getVal( $field ) );
784784 }
785785
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' );
789789 global $wgAbuseFilterIsCentral;
790 - $row->af_global = $wgRequest->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral;
 790+ $row->af_global = $request->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral;
791791
792792 // Actions
793793 global $wgAbuseFilterAvailableActions;
794794 $actions = array();
795795 foreach ( $wgAbuseFilterAvailableActions as $action ) {
796796 // Check if it's set
797 - $enabled = $wgRequest->getBool( 'wpFilterAction' . ucfirst( $action ) );
 797+ $enabled = $request->getBool( 'wpFilterAction' . ucfirst( $action ) );
798798
799799 if ( $enabled ) {
800800 $parameters = array();
801801
802802 if ( $action == 'throttle' ) {
803803 // 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' );
806806 $throttleGroups = explode( "\n",
807 - trim( $wgRequest->getText( 'wpFilterThrottleGroups' ) ) );
 807+ trim( $request->getText( 'wpFilterThrottleGroups' ) ) );
808808
809809 $parameters[0] = $this->mFilter; // For now, anyway
810810 $parameters[1] = "$throttleCount,$throttlePeriod";
811811 $parameters = array_merge( $parameters, $throttleGroups );
812812 } elseif ( $action == 'warn' ) {
813 - $specMsg = $wgRequest->getVal( 'wpFilterWarnMessage' );
 813+ $specMsg = $request->getVal( 'wpFilterWarnMessage' );
814814
815815 if ( $specMsg == 'other' )
816 - $specMsg = $wgRequest->getVal( 'wpFilterWarnMessageOther' );
 816+ $specMsg = $request->getVal( 'wpFilterWarnMessageOther' );
817817
818818 $parameters[0] = $specMsg;
819819 } elseif ( $action == 'tag' ) {
820 - $parameters = explode( "\n", $wgRequest->getText( 'wpFilterTags' ) );
 820+ $parameters = explode( "\n", $request->getText( 'wpFilterTags' ) );
821821 }
822822
823823 $thisAction = array( 'action' => $action, 'parameters' => $parameters );
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php
@@ -8,11 +8,10 @@
99 public static $examineId = null;
1010
1111 function show() {
12 - global $wgOut;
 12+ $out = $this->getOutput();
 13+ $out->setPageTitle( $this->msg( 'abusefilter-examine' ) );
 14+ $out->addWikiMsg( 'abusefilter-examine-intro' );
1315
14 - $wgOut->setPageTitle( wfMsg( 'abusefilter-examine' ) );
15 - $wgOut->addWikiMsg( 'abusefilter-examine-intro' );
16 -
1716 $this->loadParameters();
1817
1918 // Check if we've got a subpage
@@ -29,8 +28,6 @@
3029 }
3130
3231 function showSearch() {
33 - global $wgOut;
34 -
3532 // Add selector
3633 $selector = '';
3734
@@ -55,7 +52,7 @@
5653 wfMsg( 'abusefilter-examine-legend' ),
5754 $selector
5855 );
59 - $wgOut->addHTML( $selector );
 56+ $this->getOutput()->addHTML( $selector );
6057
6158 if ( $this->mSubmit ) {
6259 $this->showResults();
@@ -63,9 +60,7 @@
6461 }
6562
6663 function showResults() {
67 - global $wgUser, $wgOut;
68 -
69 - $changesList = new AbuseFilterChangesList( $wgUser->getSkin() );
 64+ $changesList = new AbuseFilterChangesList( $this->getSkin() );
7065 $output = $changesList->beginRecentChangesList();
7166 $this->mCounter = 1;
7267
@@ -77,18 +72,16 @@
7873
7974 $output .= $changesList->endRecentChangesList();
8075
81 - $wgOut->addHTML( $output );
 76+ $this->getOutput()->addHTML( $output );
8277 }
8378
8479 function showExaminerForRC( $rcid ) {
85 - global $wgOut;
86 -
8780 // Get data
8881 $dbr = wfGetDB( DB_SLAVE );
8982 $row = $dbr->selectRow( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ );
9083
9184 if ( !$row ) {
92 - $wgOut->addWikiMsg( 'abusefilter-examine-notfound' );
 85+ $this->getOutput()->addWikiMsg( 'abusefilter-examine-notfound' );
9386 return;
9487 }
9588
@@ -101,14 +94,12 @@
10295 }
10396
10497 function showExaminerForLogEntry( $logid ) {
105 - global $wgOut;
106 -
10798 // Get data
10899 $dbr = wfGetDB( DB_SLAVE );
109100 $row = $dbr->selectRow( 'abuse_filter_log', '*', array( 'afl_id' => $logid ), __METHOD__ );
110101
111102 if ( !$row ) {
112 - $wgOut->addWikiMsg( 'abusefilter-examine-notfound' );
 103+ $this->getOutput()->addWikiMsg( 'abusefilter-examine-notfound' );
113104 return;
114105 }
115106
@@ -121,10 +112,10 @@
122113 }
123114
124115 function showExaminer( $vars ) {
125 - global $wgOut, $wgUser;
 116+ $output = $this->getOutput();
126117
127118 if ( !$vars ) {
128 - $wgOut->addWikiMsg( 'abusefilter-examine-incompatible' );
 119+ $output->addWikiMsg( 'abusefilter-examine-incompatible' );
129120 return;
130121 }
131122
@@ -134,10 +125,10 @@
135126
136127 $output = '';
137128
138 - $wgOut->addModules( 'ext.abuseFilter.examine' );
 129+ $output->addModules( 'ext.abuseFilter.examine' );
139130
140131 // Add test bit
141 - if ( $wgUser->isAllowed( 'abusefilter-modify' ) ) {
 132+ if ( $this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
142133 $tester = Xml::tags( 'h2', null, wfMsgExt( 'abusefilter-examine-test', 'parseinline' ) );
143134 $tester .= AbuseFilter::buildEditBox( $this->mTestFilter, 'wpTestFilter', false );
144135 $tester .=
@@ -181,16 +172,16 @@
182173 $output .= Xml::tags( 'h2', null, wfMsgExt( 'abusefilter-examine-vars', 'parseinline' ) );
183174 $output .= AbuseFilter::buildVarDumpTable( $vars );
184175
185 - $wgOut->addHTML( $output );
 176+ $output->addHTML( $output );
186177 }
187178
188179 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' );
195186
196187 // Normalise username
197188 $userTitle = Title::newFromText( $searchUsername );
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewRevert.php
@@ -8,10 +8,12 @@
99 $filter = $this->mPage->mFilter;
1010
1111 global $wgUser, $wgOut;
12 - $sk = $wgUser->getSkin();
 12+ $user = $this->getUser();
 13+ $out = $this->getOutput();
 14+ $sk = $this->getSkin();
1315
14 - if ( !$wgUser->isAllowed( 'abusefilter-revert' ) ) {
15 - $wgOut->permissionRequired( 'abusefilter-revert' );
 16+ if ( !$user->isAllowed( 'abusefilter-revert' ) ) {
 17+ throw new PermissionsError( 'abusefilter-revert' );
1618 return;
1719 }
1820
@@ -21,8 +23,8 @@
2224 return;
2325 }
2426
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 ) );
2729
2830 // First, the search form.
2931 $searchFields = array();
@@ -46,18 +48,18 @@
4749 $searchForm =
4850 Xml::fieldset( wfMsg( 'abusefilter-revert-search-legend' ), $searchForm );
4951
50 - $wgOut->addHTML( $searchForm );
 52+ $out->addHTML( $searchForm );
5153
5254 if ( $this->mSubmit ) {
5355 // Add a summary of everything that will be reversed.
54 - $wgOut->addWikiMsg( 'abusefilter-revert-preview-intro' );
 56+ $out->addWikiMsg( 'abusefilter-revert-preview-intro' );
5557
5658 // Look up all of them.
5759 $results = $this->doLookup();
 60+ $lang = $this->getLang();
5861 $list = array();
5962
6063 foreach ( $results as $result ) {
61 - global $wgLang;
6264 $displayActions = array_map(
6365 array( 'AbuseFilter', 'getActionDisplay' ),
6466 $result['actions'] );
@@ -66,11 +68,11 @@
6769 'abusefilter-revert-preview-item',
6870 array( 'parseinline', 'replaceafter' ),
6971 array(
70 - $wgLang->timeanddate( $result['timestamp'], true ),
 72+ $lang->timeanddate( $result['timestamp'], true ),
7173 $sk->userLink( $result['userid'], $result['user'] ),
7274 $result['action'],
7375 $sk->link( $result['title'] ),
74 - $wgLang->commaList( $displayActions ),
 76+ $lang->commaList( $displayActions ),
7577 $sk->link(
7678 SpecialPage::getTitleFor( 'AbuseLog' ),
7779 wfMsgNoTrans( 'abusefilter-log-detailslink' ),
@@ -82,11 +84,11 @@
8385 $list[] = Xml::tags( 'li', null, $msg );
8486 }
8587
86 - $wgOut->addHTML( Xml::tags( 'ul', null, implode( "\n", $list ) ) );
 88+ $out->addHTML( Xml::tags( 'ul', null, implode( "\n", $list ) ) );
8789
8890 // Add a button down the bottom.
8991 $confirmForm =
90 - Html::hidden( 'editToken', $wgUser->editToken( "abusefilter-revert-$filter" ) ) .
 92+ Html::hidden( 'editToken', $user->getEditToken( "abusefilter-revert-$filter" ) ) .
9193 Html::hidden( 'title', $this->getTitle( "revert/$filter" )->getPrefixedText() ) .
9294 Html::hidden( 'wpPeriodStart', $this->origPeriodStart ) .
9395 Html::hidden( 'wpPeriodEnd', $this->origPeriodEnd ) .
@@ -104,7 +106,7 @@
105107 ),
106108 $confirmForm
107109 );
108 - $wgOut->addHTML( $confirmForm );
 110+ $out->addHTML( $confirmForm );
109111 }
110112 }
111113
@@ -154,22 +156,20 @@
155157 }
156158
157159 function loadParameters() {
158 - global $wgRequest;
 160+ $request = $this->getRequest();
159161
160 - $this->origPeriodStart = $wgRequest->getText( 'wpPeriodStart' );
 162+ $this->origPeriodStart = $request->getText( 'wpPeriodStart' );
161163 $this->mPeriodStart = strtotime( $this->origPeriodStart );
162 - $this->origPeriodEnd = $wgRequest->getText( 'wpPeriodEnd' );
 164+ $this->origPeriodEnd = $request->getText( 'wpPeriodEnd' );
163165 $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' );
166168 }
167169
168170 function attemptRevert() {
169 - global $wgUser, $wgRequest, $wgOut;
170 -
171171 $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" ) ) {
174174 return false;
175175 }
176176
@@ -180,7 +180,7 @@
181181 $this->revertAction( $action, $result );
182182 }
183183 }
184 - $wgOut->addWikiMsg( 'abusefilter-revert-success', $filter );
 184+ $this->getOutput()->addWikiMsg( 'abusefilter-revert-success', $filter );
185185
186186 return true;
187187 }
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php
@@ -2,12 +2,11 @@
33
44 class ApiAbuseFilterCheckMatch extends ApiBase {
55 public function execute() {
6 - global $wgUser;
76 $params = $this->extractRequestParams();
87 $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' );
98
109 // "Anti-DoS"
11 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 10+ if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
1211 $this->dieUsageMsg( 'permissiondenied' );
1312 }
1413
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php
@@ -2,9 +2,7 @@
33
44 class ApiAbuseFilterUnblockAutopromote extends ApiBase {
55 public function execute() {
6 - global $wgUser;
7 -
8 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 6+ if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
97 $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
108 }
119
Index: trunk/extensions/AbuseFilter/api/ApiQueryAbuseLog.php
@@ -35,8 +35,8 @@
3636 }
3737
3838 public function execute() {
39 - global $wgUser;
40 - if ( !$wgUser->isAllowed( 'abusefilter-log' ) ) {
 39+ $user = $this->getUser();
 40+ if ( !$user->isAllowed( 'abusefilter-log' ) ) {
4141 $this->dieUsage( 'You don\'t have permission to view the abuse log', 'permissiondenied' );
4242 }
4343
@@ -54,10 +54,10 @@
5555 $fld_timestamp = isset( $prop['timestamp'] );
5656 $fld_hidden = isset( $prop['hidden'] );
5757
58 - if ( $fld_ip && !$wgUser->isAllowed( 'abusefilter-private' ) ) {
 58+ if ( $fld_ip && !$user->isAllowed( 'abusefilter-private' ) ) {
5959 $this->dieUsage( 'You don\'t have permission to view IP addresses', 'permissiondenied' );
6060 }
61 - if ( $fld_details && !$wgUser->isAllowed( 'abusefilter-log-detail' ) ) {
 61+ if ( $fld_details && !$user->isAllowed( 'abusefilter-log-detail' ) ) {
6262 $this->dieUsage( 'You don\'t have permission to view detailed abuse log entries', 'permissiondenied' );
6363 }
6464
@@ -90,7 +90,7 @@
9191
9292 $this->addWhereIf( array( 'afl_user_text' => $params['user'] ), isset( $params['user'] ) );
9393 $this->addWhereIf( array( 'afl_filter' => $params['filter'] ), isset( $params['filter'] ) );
94 - $this->addWhereIf( $notDeletedCond, !SpecialAbuseLog::canSeeHidden() );
 94+ $this->addWhereIf( $notDeletedCond, !SpecialAbuseLog::canSeeHidden( $user ) );
9595
9696 $title = $params['title'];
9797 if ( !is_null( $title ) ) {
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php
@@ -3,10 +3,8 @@
44 class ApiAbuseFilterCheckSyntax extends ApiBase {
55
66 public function execute() {
7 - global $wgUser;
8 -
97 // "Anti-DoS"
10 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 8+ if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
119 $this->dieUsageMsg( 'permissiondenied' );
1210 }
1311
Index: trunk/extensions/AbuseFilter/api/ApiQueryAbuseFilters.php
@@ -35,8 +35,8 @@
3636 }
3737
3838 public function execute() {
39 - global $wgUser;
40 - if ( !$wgUser->isAllowed( 'abusefilter-view' ) ) {
 39+ $user = $this->getUser();
 40+ if ( !$user->isAllowed( 'abusefilter-view' ) ) {
4141 $this->dieUsage( 'You don\'t have permission to view abuse filters', 'permissiondenied' );
4242 }
4343
@@ -94,7 +94,7 @@
9595
9696 $res = $this->select( __METHOD__ );
9797
98 - $showhidden = $wgUser->isAllowed( 'abusefilter-modify' );
 98+ $showhidden = $user->isAllowed( 'abusefilter-modify' );
9999
100100 $count = 0;
101101 foreach ( $res as $row ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r103911Changes from r103817johnduhart16:08, 22 November 2011
r107177Followup r103298 which causes a fatal errorjohnduhart20:23, 23 December 2011

Comments

#Comment by Tim Starling (talk | contribs)   05:17, 2 January 2012

Added followup r103911 since AbuseFilterViewExamine::showExaminer() was fixed there.

Status & tagging log