r92388 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92387‎ | r92388 | r92389 >
Date:09:25, 17 July 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Changed Special:RecentChanges and Special:RecentChangesLinked to use the local context instead of global variables
* Added context to ChangesList
* Added new factory for ChangesList and subclasses in ChangesList::newFromContext() and modified ChangesList::newFromUser() to call it with the main context since anyway User::getSkin() return the Skin from the main context, so this won't change anything but the User::getOption() call
* Updates Special:RecentChanges and Special:Watchlist to use that new function
* Call Linker methods statically
* Use Linker::linkKnown() instead of Linker::link() where possible
* In Special:Watchlist: Use wfMessage() instead of OutputPage::addWikiMsgArray() with the third parameter
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchangeslinked.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ChangesList.php
@@ -31,7 +31,7 @@
3232 /**
3333 * Base class for all changes lists
3434 */
35 -class ChangesList {
 35+class ChangesList extends ContextSource {
3636
3737 /**
3838 * @var Skin
@@ -43,29 +43,47 @@
4444 protected $message;
4545
4646 /**
47 - * Changeslist contructor
48 - * @param $skin Skin
49 - */
50 - public function __construct( $skin ) {
51 - $this->skin = $skin;
 47+ * Changeslist contructor
 48+ *
 49+ * @param $obj Skin or RequestContext
 50+ */
 51+ public function __construct( $obj ) {
 52+ if ( $obj instanceof RequestContext ) {
 53+ $this->setContext( $obj );
 54+ $this->skin = $obj->getSkin();
 55+ } else {
 56+ $this->setContext( $obj->getContext() );
 57+ $this->skin = $obj;
 58+ }
5259 $this->preCacheMessages();
5360 }
5461
5562 /**
56 - * Fetch an appropriate changes list class for the specified user
57 - * Some users might want to use an enhanced list format, for instance
 63+ * Fetch an appropriate changes list class for the main context
 64+ * This first argument used to be an User object.
5865 *
59 - * @param $user User to fetch the list class for
 66+ * @deprecated in 1.19; use newFromContext() instead
 67+ * @param $unused Unused
6068 * @return ChangesList|EnhancedChangesList|OldChangesList derivative
6169 */
62 - public static function newFromUser( $user ) {
63 - global $wgRequest;
 70+ public static function newFromUser( $unused ) {
 71+ return self::newFromContext( RequestContext::getMain() );
 72+ }
6473
65 - $sk = $user->getSkin();
 74+ /**
 75+ * Fetch an appropriate changes list class for the specified context
 76+ * Some users might want to use an enhanced list format, for instance
 77+ *
 78+ * @param $context RequestContext to use
 79+ * @return ChangesList|EnhancedChangesList|OldChangesList derivative
 80+ */
 81+ public static function newFromContext( RequestContext $context ) {
 82+ $user = $context->getUser();
 83+ $sk = $context->getSkin();
6684 $list = null;
6785 if( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
68 - $new = $wgRequest->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
69 - return $new ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
 86+ $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
 87+ return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
7088 } else {
7189 return $list;
7290 }
@@ -216,38 +234,29 @@
217235 # Diff
218236 $s .= '(' . $this->message['diff'] . ') (';
219237 # Hist
220 - $s .= $this->skin->link(
 238+ $s .= Linker::linkKnown(
221239 $rc->getMovedToTitle(),
222240 $this->message['hist'],
223241 array(),
224 - array( 'action' => 'history' ),
225 - array( 'known', 'noclasses' )
 242+ array( 'action' => 'history' )
226243 ) . ') . . ';
227244 # "[[x]] moved to [[y]]"
228245 $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
229 - $s .= wfMsg(
 246+ $s .= wfMsgHtml(
230247 $msg,
231 - $this->skin->link(
 248+ Linker::linkKnown(
232249 $rc->getTitle(),
233250 null,
234251 array(),
235 - array( 'redirect' => 'no' ),
236 - array( 'known', 'noclasses' )
 252+ array( 'redirect' => 'no' )
237253 ),
238 - $this->skin->link(
239 - $rc->getMovedToTitle(),
240 - null,
241 - array(),
242 - array(),
243 - array( 'known', 'noclasses' )
244 - )
 254+ Linker::linkKnown( $rc->getMovedToTitle() )
245255 );
246256 }
247257
248258 public function insertDateHeader( &$s, $rc_timestamp ) {
249 - global $wgLang;
250259 # Make date header if necessary
251 - $date = $wgLang->date( $rc_timestamp, true, true );
 260+ $date = $this->getLang()->date( $rc_timestamp, true, true );
252261 if( $date != $this->lastdate ) {
253262 if( $this->lastdate != '' ) {
254263 $s .= "</ul>\n";
@@ -260,13 +269,7 @@
261270
262271 public function insertLog( &$s, $title, $logtype ) {
263272 $logname = LogPage::logName( $logtype );
264 - $s .= '(' . $this->skin->link(
265 - $title,
266 - $logname,
267 - array(),
268 - array(),
269 - array( 'known', 'noclasses' )
270 - ) . ')';
 273+ $s .= '(' . Linker::linkKnown( $title, htmlspecialchars( $logname ) ) . ')';
271274 }
272275
273276 /**
@@ -292,25 +295,23 @@
293296 $query['rcid'] = $rc->mAttribs['rc_id'];
294297 };
295298
296 - $diffLink = $this->skin->link(
 299+ $diffLink = Linker::linkKnown(
297300 $rc->getTitle(),
298301 $this->message['diff'],
299302 array( 'tabindex' => $rc->counter ),
300 - $query,
301 - array( 'known', 'noclasses' )
 303+ $query
302304 );
303305 }
304306 $s .= '(' . $diffLink . $this->message['pipe-separator'];
305307 # History link
306 - $s .= $this->skin->link(
 308+ $s .= Linker::linkKnown(
307309 $rc->getTitle(),
308310 $this->message['hist'],
309311 array(),
310312 array(
311313 'curid' => $rc->mAttribs['rc_cur_id'],
312314 'action' => 'history'
313 - ),
314 - array( 'known', 'noclasses' )
 315+ )
315316 );
316317 $s .= ') . . ';
317318 }
@@ -323,7 +324,6 @@
324325 * @return void
325326 */
326327 public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
327 - global $wgLang;
328328 # If it's a new article, there is no diff link, but if it hasn't been
329329 # patrolled yet, we need to give users a way to do so
330330 $params = array();
@@ -333,21 +333,19 @@
334334 }
335335
336336 if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
337 - $articlelink = $this->skin->link(
 337+ $articlelink = Linker::linkKnown(
338338 $rc->getTitle(),
339339 null,
340340 array(),
341 - $params,
342 - array( 'known', 'noclasses' )
 341+ $params
343342 );
344343 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
345344 } else {
346 - $articlelink = ' '. $this->skin->link(
 345+ $articlelink = ' '. Linker::linkKnown(
347346 $rc->getTitle(),
348347 null,
349348 array(),
350 - $params,
351 - array( 'known', 'noclasses' )
 349+ $params
352350 );
353351 }
354352 # Bolden pages watched by this user
@@ -355,7 +353,7 @@
356354 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
357355 }
358356 # RTL/LTR marker
359 - $articlelink .= $wgLang->getDirMark();
 357+ $articlelink .= $this->getLang()->getDirMark();
360358
361359 wfRunHooks( 'ChangesListInsertArticleLink',
362360 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
@@ -369,9 +367,8 @@
370368 * @return void
371369 */
372370 public function insertTimestamp( &$s, $rc ) {
373 - global $wgLang;
374371 $s .= $this->message['semicolon-separator'] .
375 - $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
 372+ $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
376373 }
377374
378375 /** Insert links to user page, user talk page and eventually a blocking link
@@ -382,8 +379,8 @@
383380 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
384381 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
385382 } else {
386 - $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
387 - $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
 383+ $s .= Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
 384+ $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
388385 }
389386 }
390387
@@ -397,7 +394,7 @@
398395 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
399396 } else {
400397 $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
401 - $rc->getTitle(), $this->skin, LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
 398+ $rc->getTitle(), $this->getSkin(), LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
402399 }
403400 }
404401 }
@@ -411,7 +408,7 @@
412409 if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
413410 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
414411 } else {
415 - $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
 412+ $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
416413 }
417414 }
418415 }
@@ -429,12 +426,11 @@
430427 * Returns the string which indicates the number of watching users
431428 */
432429 protected function numberofWatchingusers( $count ) {
433 - global $wgLang;
434430 static $cache = array();
435431 if( $count > 0 ) {
436432 if( !isset( $cache[$count] ) ) {
437433 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
438 - array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
 434+ array('parsemag', 'escape' ), $this->getLang()->formatNum( $count ) );
439435 }
440436 return $cache[$count];
441437 } else {
@@ -481,12 +477,11 @@
482478 * @param $rc RecentChange
483479 */
484480 public function insertRollback( &$s, &$rc ) {
485 - global $wgUser;
486481 if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
487482 $page = $rc->getTitle();
488483 /** Check for rollback and edit permissions, disallow special pages, and only
489484 * show a link on the top-most revision */
490 - if ($wgUser->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
 485+ if ( $this->getUser()->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
491486 {
492487 $rev = new Revision( array(
493488 'id' => $rc->mAttribs['rc_this_oldid'],
@@ -495,7 +490,7 @@
496491 'deleted' => $rc->mAttribs['rc_deleted']
497492 ) );
498493 $rev->setTitle( $page );
499 - $s .= ' '.$this->skin->generateRollback( $rev );
 494+ $s .= ' '.Linker::generateRollback( $rev, $this->getContext() );
500495 }
501496 }
502497 }
@@ -531,10 +526,10 @@
532527 * @param $rc RecentChange
533528 */
534529 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
535 - global $wgLang, $wgRCShowChangedSize, $wgUser;
 530+ global $wgRCShowChangedSize;
536531 wfProfileIn( __METHOD__ );
537532 # Should patrol-related stuff be shown?
538 - $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
 533+ $unpatrolled = $this->getUser()->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
539534
540535 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
541536 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
@@ -591,7 +586,7 @@
592587 # User tool links
593588 $this->insertUserRelatedLinks( $s, $rc );
594589 # LTR/RTL direction mark
595 - $s .= $wgLang->getDirMark();
 590+ $s .= $this->getLang()->getDirMark();
596591 # Log action text (if any)
597592 $this->insertAction( $s, $rc );
598593 # Edit or log comment
@@ -606,7 +601,7 @@
607602 # How many users watch this page
608603 if( $rc->numberofWatchingusers > 0 ) {
609604 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
610 - array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) );
 605+ array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $rc->numberofWatchingusers ) );
611606 }
612607
613608 if( $this->watchlist ) {
@@ -630,13 +625,12 @@
631626 * @return String
632627 */
633628 public function beginRecentChangesList() {
634 - global $wgOut;
635629 $this->rc_cache = array();
636630 $this->rcMoveIndex = 0;
637631 $this->rcCacheIndex = 0;
638632 $this->lastdate = '';
639633 $this->rclistOpen = false;
640 - $wgOut->addModuleStyles( 'mediawiki.special.changeslist' );
 634+ $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
641635 return '';
642636 }
643637 /**
@@ -648,8 +642,6 @@
649643 * @return string
650644 */
651645 public function recentChangesLine( &$baseRC, $watched = false ) {
652 - global $wgLang, $wgUser;
653 -
654646 wfProfileIn( __METHOD__ );
655647
656648 # Create a specialised object
@@ -658,7 +650,7 @@
659651 $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
660652
661653 # If it's a new day, add the headline and flush the cache
662 - $date = $wgLang->date( $rc->mAttribs['rc_timestamp'], true );
 654+ $date = $this->getLang()->date( $rc->mAttribs['rc_timestamp'], true );
663655 $ret = '';
664656 if( $date != $this->lastdate ) {
665657 # Process current cache
@@ -669,7 +661,7 @@
670662 }
671663
672664 # Should patrol-related stuff be shown?
673 - if( $wgUser->useRCPatrol() ) {
 665+ if( $this->getUser()->useRCPatrol() ) {
674666 $rc->unpatrolled = !$rc->mAttribs['rc_patrolled'];
675667 } else {
676668 $rc->unpatrolled = false;
@@ -682,21 +674,21 @@
683675 // Page moves
684676 if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
685677 $msg = ( $type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
686 - $clink = wfMsg( $msg, $this->skin->linkKnown( $rc->getTitle(), null,
 678+ $clink = wfMsg( $msg, Linker::linkKnown( $rc->getTitle(), null,
687679 array(), array( 'redirect' => 'no' ) ),
688 - $this->skin->linkKnown( $rc->getMovedToTitle() ) );
 680+ Linker::linkKnown( $rc->getMovedToTitle() ) );
689681 // New unpatrolled pages
690682 } elseif( $rc->unpatrolled && $type == RC_NEW ) {
691 - $clink = $this->skin->linkKnown( $rc->getTitle(), null, array(),
 683+ $clink = Linker::linkKnown( $rc->getTitle(), null, array(),
692684 array( 'rcid' => $rc->mAttribs['rc_id'] ) );
693685 // Log entries
694686 } elseif( $type == RC_LOG ) {
695687 if( $logType ) {
696688 $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
697 - $clink = '(' . $this->skin->linkKnown( $logtitle,
 689+ $clink = '(' . Linker::linkKnown( $logtitle,
698690 LogPage::logName( $logType ) ) . ')';
699691 } else {
700 - $clink = $this->skin->link( $rc->getTitle() );
 692+ $clink = Linker::link( $rc->getTitle() );
701693 }
702694 $watched = false;
703695 // Log entries (old format) and special pages
@@ -705,14 +697,14 @@
706698 if ( $specialName == 'Log' ) {
707699 # Log updates, etc
708700 $logname = LogPage::logName( $logtype );
709 - $clink = '(' . $this->skin->linkKnown( $rc->getTitle(), $logname ) . ')';
 701+ $clink = '(' . Linker::linkKnown( $rc->getTitle(), $logname ) . ')';
710702 } else {
711703 wfDebug( "Unexpected special page in recentchanges\n" );
712704 $clink = '';
713705 }
714706 // Edits
715707 } else {
716 - $clink = $this->skin->linkKnown( $rc->getTitle() );
 708+ $clink = Linker::linkKnown( $rc->getTitle() );
717709 }
718710
719711 # Don't show unusable diff links
@@ -720,7 +712,7 @@
721713 $showdifflinks = false;
722714 }
723715
724 - $time = $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true );
 716+ $time = $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true );
725717 $rc->watched = $watched;
726718 $rc->link = $clink;
727719 $rc->timestamp = $time;
@@ -763,7 +755,7 @@
764756 } elseif( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
765757 $lastLink = $this->message['last'];
766758 } else {
767 - $lastLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['last'],
 759+ $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
768760 array(), $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery );
769761 }
770762
@@ -771,8 +763,8 @@
772764 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
773765 $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
774766 } else {
775 - $rc->userlink = $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
776 - $rc->usertalklink = $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
 767+ $rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
 768+ $rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
777769 }
778770
779771 $rc->lastlink = $lastLink;
@@ -807,7 +799,7 @@
808800 * Enhanced RC group
809801 */
810802 protected function recentChangesBlockGroup( $block ) {
811 - global $wgLang, $wgRCShowChangedSize;
 803+ global $wgRCShowChangedSize;
812804
813805 wfProfileIn( __METHOD__ );
814806
@@ -869,9 +861,9 @@
870862 $users = array();
871863 foreach( $userlinks as $userlink => $count) {
872864 $text = $userlink;
873 - $text .= $wgLang->getDirMark();
 865+ $text .= $this->getLang()->getDirMark();
874866 if( $count > 1 ) {
875 - $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
 867+ $text .= ' (' . $this->getLang()->formatNum( $count ) . '×)';
876868 }
877869 array_push( $users, $text );
878870 }
@@ -911,14 +903,14 @@
912904 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
913905 }
914906
915 - $r .= $wgLang->getDirMark();
 907+ $r .= $this->getLang()->getDirMark();
916908
917909 $queryParams['curid'] = $curId;
918910 # Changes message
919911 $n = count($block);
920912 static $nchanges = array();
921913 if ( !isset( $nchanges[$n] ) ) {
922 - $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
 914+ $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) );
923915 }
924916 # Total change link
925917 $r .= ' ';
@@ -933,7 +925,7 @@
934926 $params['diff'] = $currentRevision;
935927 $params['oldid'] = $oldid;
936928
937 - $r .= $this->skin->link(
 929+ $r .= Linker::link(
938930 $block[0]->getTitle(),
939931 $nchanges[$n],
940932 array(),
@@ -953,12 +945,11 @@
954946 $params['action'] = 'history';
955947
956948 $r .= $this->message['pipe-separator'] .
957 - $this->skin->link(
 949+ Linker::linkKnown(
958950 $block[0]->getTitle(),
959951 $this->message['hist'],
960952 array(),
961 - $params,
962 - array( 'known', 'noclasses' )
 953+ $params
963954 ) . ')';
964955 }
965956 $r .= ' . . ';
@@ -1021,12 +1012,11 @@
10221013 $params['rcid'] = $rcObj->mAttribs['rc_id'];
10231014 }
10241015
1025 - $link = $this->skin->link(
 1016+ $link = Linker::linkKnown(
10261017 $rcObj->getTitle(),
10271018 $rcObj->timestamp,
10281019 array(),
1029 - $params,
1030 - array( 'known', 'noclasses' )
 1020+ $params
10311021 );
10321022 if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
10331023 $link = '<span class="history-deleted">'.$link.'</span> ';
@@ -1151,15 +1141,9 @@
11521142 $r .= '&#160;'.$rcObj->timestamp.'&#160;</td><td>';
11531143 # Article or log link
11541144 if( $logType ) {
1155 - $logtitle = Title::newFromText( "Log/$logType", NS_SPECIAL );
 1145+ $logtitle = SpecialPage::getTitleFor( 'Log', $logType );
11561146 $logname = LogPage::logName( $logType );
1157 - $r .= '(' . $this->skin->link(
1158 - $logtitle,
1159 - $logname,
1160 - array(),
1161 - array(),
1162 - array( 'known', 'noclasses' )
1163 - ) . ')';
 1147+ $r .= '(' . Linker::linkKnown( $logtitle, htmlspecialchars( $logname ) ) . ')';
11641148 } else {
11651149 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
11661150 }
@@ -1167,12 +1151,11 @@
11681152 if ( $type != RC_LOG ) {
11691153 $r .= ' ('. $rcObj->difflink . $this->message['pipe-separator'];
11701154 $query['action'] = 'history';
1171 - $r .= $this->skin->link(
 1155+ $r .= Linker::linkKnown(
11721156 $rcObj->getTitle(),
11731157 $this->message['hist'],
11741158 array(),
1175 - $query,
1176 - array( 'known', 'noclasses' )
 1159+ $query
11771160 ) . ')';
11781161 }
11791162 $r .= ' . . ';
@@ -1188,7 +1171,7 @@
11891172 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
11901173 } else {
11911174 $r .= ' ' . LogPage::actionText( $logType, $rcObj->mAttribs['rc_log_action'], $rcObj->getTitle(),
1192 - $this->skin, LogPage::extractParams( $rcObj->mAttribs['rc_params'] ), true, true );
 1175+ $this->getSkin(), LogPage::extractParams( $rcObj->mAttribs['rc_params'] ), true, true );
11931176 }
11941177 }
11951178 $this->insertComment( $r, $rcObj );
Index: trunk/phase3/includes/specials/SpecialRecentchangeslinked.php
@@ -46,9 +46,8 @@
4747 }
4848
4949 public function feedSetup() {
50 - global $wgRequest;
5150 $opts = parent::feedSetup();
52 - $opts['target'] = $wgRequest->getVal( 'target' );
 51+ $opts['target'] = $this->getRequest()->getVal( 'target' );
5352 return $opts;
5453 }
5554
@@ -63,8 +62,6 @@
6463 }
6564
6665 public function doMainQuery( $conds, $opts ) {
67 - global $wgUser, $wgOut;
68 -
6966 $target = $opts['target'];
7067 $showlinkedto = $opts['showlinkedto'];
7168 $limit = $opts['limit'];
@@ -74,11 +71,11 @@
7572 }
7673 $title = Title::newFromURL( $target );
7774 if( !$title || $title->getInterwiki() != '' ){
78 - $wgOut->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br style=\"clear: both\" />", 'allpagesbadtitle' );
 75+ $this->getOutput()->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br style=\"clear: both\" />", 'allpagesbadtitle' );
7976 return false;
8077 }
8178
82 - $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
 79+ $this->getOutput()->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
8380
8481 /*
8582 * Ordinary links are in the pagelinks table, while transclusions are
@@ -100,13 +97,13 @@
10198 $query_options = array();
10299
103100 // left join with watchlist table to highlight watched rows
104 - $uid = $wgUser->getId();
 101+ $uid = $this->getUser()->getId();
105102 if( $uid ) {
106103 $tables[] = 'watchlist';
107104 $select[] = 'wl_user';
108105 $join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" );
109106 }
110 - if ( $wgUser->isAllowed( 'rollback' ) ) {
 107+ if ( $this->getUser()->isAllowed( 'rollback' ) ) {
111108 $tables[] = 'page';
112109 $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
113110 $select[] = 'page_latest';
@@ -235,12 +232,12 @@
236233 return $this->rclTargetTitle;
237234 }
238235
239 - function setTopText( OutputPage $out, FormOptions $opts ) {
240 - $skin = $this->getSkin();
 236+ function setTopText( FormOptions $opts ) {
241237 $target = $this->getTargetTitle();
242 - if( $target )
243 - $out->setSubtitle( wfMsg( 'recentchangeslinked-backlink', $skin->link( $target,
 238+ if( $target ) {
 239+ $this->getOutput()->setSubtitle( wfMsg( 'recentchangeslinked-backlink', Linker::link( $target,
244240 $target->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) );
 241+ }
245242 }
246243
247244 public function getFeedQuery() {
@@ -252,9 +249,9 @@
253250 }
254251 }
255252
256 - function setBottomText( OutputPage $out, FormOptions $opts ) {
257 - if( isset( $this->mResultEmpty ) && $this->mResultEmpty ){
258 - $out->addWikiMsg( 'recentchangeslinked-noresult' );
 253+ function setBottomText( FormOptions $opts ) {
 254+ if( isset( $this->mResultEmpty ) && $this->mResultEmpty ) {
 255+ $this->getOutput()->addWikiMsg( 'recentchangeslinked-noresult' );
259256 }
260257 }
261258 }
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -71,8 +71,6 @@
7272 * @return FormOptions
7373 */
7474 public function setup( $parameters ) {
75 - global $wgRequest;
76 -
7775 $opts = $this->getDefaultOptions();
7876
7977 $this->customFilters = array();
@@ -81,7 +79,7 @@
8280 $opts->add( $key, $params['default'] );
8381 }
8482
85 - $opts->fetchValuesFromRequest( $wgRequest );
 83+ $opts->fetchValuesFromRequest( $this->getRequest() );
8684
8785 // Give precedence to subpage syntax
8886 if( $parameters !== null ) {
@@ -98,10 +96,10 @@
9997 * @return FormOptions
10098 */
10199 public function feedSetup() {
102 - global $wgFeedLimit, $wgRequest;
 100+ global $wgFeedLimit;
103101 $opts = $this->getDefaultOptions();
104102 # Feed is cached on limit,hideminor,namespace; other params would randomly not work
105 - $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor', 'namespace' ) );
 103+ $opts->fetchValuesFromRequest( $this->getRequest(), array( 'limit', 'hideminor', 'namespace' ) );
106104 $opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
107105 return $opts;
108106 }
@@ -114,8 +112,7 @@
115113 if ( $this->including() ) {
116114 $isFeed = false;
117115 } else {
118 - global $wgRequest;
119 - $isFeed = (bool)$wgRequest->getVal( 'feed' );
 116+ $isFeed = (bool)$this->getRequest()->getVal( 'feed' );
120117 }
121118 $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage );
122119 }
@@ -129,12 +126,11 @@
130127 * @param $subpage String
131128 */
132129 public function execute( $subpage ) {
133 - global $wgRequest, $wgOut;
134130 $this->rcSubpage = $subpage;
135 - $feedFormat = $this->including() ? null : $wgRequest->getVal( 'feed' );
 131+ $feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
136132
137133 # 10 seconds server-side caching max
138 - $wgOut->setSquidMaxage( 10 );
 134+ $this->getOutput()->setSquidMaxage( 10 );
139135 # Check if the client has a cached version
140136 $lastmod = $this->checkLastModified( $feedFormat );
141137 if( $lastmod === false ) {
@@ -453,14 +449,13 @@
454450 }
455451
456452 /**
457 - * Send output to $wgOut, only called if not used feeds
 453+ * Send output to the OutputPage object, only called if not used feeds
458454 *
459455 * @param $rows Array of database rows
460456 * @param $opts FormOptions
461457 */
462458 public function webOutput( $rows, $opts ) {
463 - global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
464 - global $wgAllowCategorizedRecentChanges;
 459+ global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges;
465460
466461 $limit = $opts['limit'];
467462
@@ -470,7 +465,7 @@
471466 }
472467
473468 // And now for the content
474 - $wgOut->setFeedAppendQuery( $this->getFeedQuery() );
 469+ $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() );
475470
476471 if( $wgAllowCategorizedRecentChanges ) {
477472 $this->filterByCategories( $rows, $opts );
@@ -482,7 +477,7 @@
483478 $dbr = wfGetDB( DB_SLAVE );
484479
485480 $counter = 1;
486 - $list = ChangesList::newFromUser( $this->getUser() );
 481+ $list = ChangesList::newFromContext( $this->getContext() );
487482
488483 $s = $list->beginRecentChangesList();
489484 foreach( $rows as $obj ) {
@@ -518,7 +513,7 @@
519514 --$limit;
520515 }
521516 $s .= $list->endRecentChangesList();
522 - $wgOut->addHTML( $s );
 517+ $this->getOutput()->addHTML( $s );
523518 }
524519
525520 /**
@@ -536,9 +531,9 @@
537532 * @return String: XHTML
538533 */
539534 public function doHeader( $opts ) {
540 - global $wgScript, $wgOut;
 535+ global $wgScript;
541536
542 - $this->setTopText( $wgOut, $opts );
 537+ $this->setTopText( $opts );
543538
544539 $defaults = $opts->getAllValues();
545540 $nondefaults = $opts->getChangedValues();
@@ -584,11 +579,11 @@
585580 $panel[] = $form;
586581 $panelString = implode( "\n", $panel );
587582
588 - $wgOut->addHTML(
 583+ $this->getOutput()->addHTML(
589584 Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
590585 );
591586
592 - $this->setBottomText( $wgOut, $opts );
 587+ $this->setBottomText( $opts );
593588 }
594589
595590 /**
@@ -618,21 +613,19 @@
619614 /**
620615 * Send the text to be displayed above the options
621616 *
622 - * @param $out OutputPage
623617 * @param $opts FormOptions
624618 */
625 - function setTopText( OutputPage $out, FormOptions $opts ) {
626 - $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) );
 619+ function setTopText( FormOptions $opts ) {
 620+ $this->getOutput()->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) );
627621 }
628622
629623 /**
630624 * Send the text to be displayed after the options, for use in
631625 * Recentchangeslinked
632626 *
633 - * @param $out OutputPage
634627 * @param $opts FormOptions
635628 */
636 - function setBottomText( OutputPage $out, FormOptions $opts ) {}
 629+ function setBottomText( FormOptions $opts ) {}
637630
638631 /**
639632 * Creates the choose namespace selection
@@ -747,16 +740,11 @@
748741 */
749742 function makeOptionsLink( $title, $override, $options, $active = false ) {
750743 $params = $override + $options;
 744+ $text = htmlspecialchars( $title );
751745 if ( $active ) {
752 - return $this->getSkin()->link(
753 - $this->getTitle(),
754 - '<strong>' . htmlspecialchars( $title ) . '</strong>',
755 - array(), $params, array( 'known' ) );
756 - } else {
757 - return $this->getSkin()->link(
758 - $this->getTitle(), htmlspecialchars( $title ), array(),
759 - $params, array( 'known' ) );
 746+ $text = '<strong>' . $text . '</strong>';
760747 }
 748+ return Linker::linkKnown( $this->getTitle(), $text, array(), $params );
761749 }
762750
763751 /**
@@ -766,7 +754,7 @@
767755 * @param $nondefaults Array
768756 */
769757 function optionsPanel( $defaults, $nondefaults ) {
770 - global $wgLang, $wgRCLinkLimits, $wgRCLinkDays;
 758+ global $wgRCLinkLimits, $wgRCLinkDays;
771759
772760 $options = $nondefaults + $defaults;
773761
@@ -777,10 +765,10 @@
778766 }
779767 if( $options['from'] ) {
780768 $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ),
781 - $wgLang->formatNum( $options['limit'] ),
782 - $wgLang->timeanddate( $options['from'], true ),
783 - $wgLang->date( $options['from'], true ),
784 - $wgLang->time( $options['from'], true ) ) . '<br />';
 769+ $this->getLang()->formatNum( $options['limit'] ),
 770+ $this->getLang()->timeanddate( $options['from'], true ),
 771+ $this->getLang()->date( $options['from'], true ),
 772+ $this->getLang()->time( $options['from'], true ) ) . '<br />';
785773 }
786774
787775 # Sort data for display and make sure it's unique after we've added user data.
@@ -793,17 +781,17 @@
794782
795783 // limit links
796784 foreach( $wgRCLinkLimits as $value ) {
797 - $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
 785+ $cl[] = $this->makeOptionsLink( $this->getLang()->formatNum( $value ),
798786 array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
799787 }
800 - $cl = $wgLang->pipeList( $cl );
 788+ $cl = $this->getLang()->pipeList( $cl );
801789
802790 // day links, reset 'from' to none
803791 foreach( $wgRCLinkDays as $value ) {
804 - $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
 792+ $dl[] = $this->makeOptionsLink( $this->getLang()->formatNum( $value ),
805793 array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
806794 }
807 - $dl = $wgLang->pipeList( $dl );
 795+ $dl = $this->getLang()->pipeList( $dl );
808796
809797
810798 // show/hide links
@@ -833,13 +821,13 @@
834822
835823 // show from this onward link
836824 $timestamp = wfTimestampNow();
837 - $now = $wgLang->timeanddate( $timestamp, true );
 825+ $now = $this->getLang()->timeanddate( $timestamp, true );
838826 $tl = $this->makeOptionsLink(
839827 $now, array( 'from' => $timestamp ), $nondefaults
840828 );
841829
842830 $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
843 - $cl, $dl, $wgLang->pipeList( $links ) );
 831+ $cl, $dl, $this->getLang()->pipeList( $links ) );
844832 $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl );
845833 return "{$note}$rclinks<br />$rclistfrom";
846834 }
@@ -848,8 +836,7 @@
849837 * add javascript specific to the [[Special:RecentChanges]] page
850838 */
851839 function addRecentChangesJS() {
852 - global $wgOut;
853 - $wgOut->addModules( array(
 840+ $this->getOutput()->addModules( array(
854841 'mediawiki.special.recentchanges',
855842 ) );
856843 }
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -62,7 +62,7 @@
6363 array(),
6464 array( 'returnto' => $this->getTitle()->getPrefixedText() )
6565 );
66 - $output->addWikiMsgArray( 'watchlistanontext', array( $llink ), array( 'replaceafter' ) );
 66+ $out->addHTML( wfMessage( 'watchlistanontext' )->rawParam( $llink )->parse() );
6767 return;
6868 }
6969
@@ -380,7 +380,7 @@
381381 $linkBatch->execute();
382382 $dbr->dataSeek( $res, 0 );
383383
384 - $list = ChangesList::newFromUser( $this->getUser() );
 384+ $list = ChangesList::newFromContext( $this->getContext() );
385385 $list->setWatchlistDivs();
386386
387387 $s = $list->beginRecentChangesList();

Follow-up revisions

RevisionCommit summaryAuthorDate
r92389Fix for r92388: that was the wrong methodialex09:33, 17 July 2011

Comments

#Comment by Nikerabbit (talk | contribs)   11:58, 17 July 2011

Could you check whether there is something in CleanChanges extension that should be updated?

Status & tagging log