Index: trunk/phase3/includes/ChangesList.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | /** |
33 | 33 | * Base class for all changes lists |
34 | 34 | */ |
35 | | -class ChangesList { |
| 35 | +class ChangesList extends ContextSource { |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var Skin |
— | — | @@ -43,29 +43,47 @@ |
44 | 44 | protected $message; |
45 | 45 | |
46 | 46 | /** |
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 | + } |
52 | 59 | $this->preCacheMessages(); |
53 | 60 | } |
54 | 61 | |
55 | 62 | /** |
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. |
58 | 65 | * |
59 | | - * @param $user User to fetch the list class for |
| 66 | + * @deprecated in 1.19; use newFromContext() instead |
| 67 | + * @param $unused Unused |
60 | 68 | * @return ChangesList|EnhancedChangesList|OldChangesList derivative |
61 | 69 | */ |
62 | | - public static function newFromUser( $user ) { |
63 | | - global $wgRequest; |
| 70 | + public static function newFromUser( $unused ) { |
| 71 | + return self::newFromContext( RequestContext::getMain() ); |
| 72 | + } |
64 | 73 | |
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(); |
66 | 84 | $list = null; |
67 | 85 | 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 ); |
70 | 88 | } else { |
71 | 89 | return $list; |
72 | 90 | } |
— | — | @@ -216,38 +234,29 @@ |
217 | 235 | # Diff |
218 | 236 | $s .= '(' . $this->message['diff'] . ') ('; |
219 | 237 | # Hist |
220 | | - $s .= $this->skin->link( |
| 238 | + $s .= Linker::linkKnown( |
221 | 239 | $rc->getMovedToTitle(), |
222 | 240 | $this->message['hist'], |
223 | 241 | array(), |
224 | | - array( 'action' => 'history' ), |
225 | | - array( 'known', 'noclasses' ) |
| 242 | + array( 'action' => 'history' ) |
226 | 243 | ) . ') . . '; |
227 | 244 | # "[[x]] moved to [[y]]" |
228 | 245 | $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir'; |
229 | | - $s .= wfMsg( |
| 246 | + $s .= wfMsgHtml( |
230 | 247 | $msg, |
231 | | - $this->skin->link( |
| 248 | + Linker::linkKnown( |
232 | 249 | $rc->getTitle(), |
233 | 250 | null, |
234 | 251 | array(), |
235 | | - array( 'redirect' => 'no' ), |
236 | | - array( 'known', 'noclasses' ) |
| 252 | + array( 'redirect' => 'no' ) |
237 | 253 | ), |
238 | | - $this->skin->link( |
239 | | - $rc->getMovedToTitle(), |
240 | | - null, |
241 | | - array(), |
242 | | - array(), |
243 | | - array( 'known', 'noclasses' ) |
244 | | - ) |
| 254 | + Linker::linkKnown( $rc->getMovedToTitle() ) |
245 | 255 | ); |
246 | 256 | } |
247 | 257 | |
248 | 258 | public function insertDateHeader( &$s, $rc_timestamp ) { |
249 | | - global $wgLang; |
250 | 259 | # Make date header if necessary |
251 | | - $date = $wgLang->date( $rc_timestamp, true, true ); |
| 260 | + $date = $this->getLang()->date( $rc_timestamp, true, true ); |
252 | 261 | if( $date != $this->lastdate ) { |
253 | 262 | if( $this->lastdate != '' ) { |
254 | 263 | $s .= "</ul>\n"; |
— | — | @@ -260,13 +269,7 @@ |
261 | 270 | |
262 | 271 | public function insertLog( &$s, $title, $logtype ) { |
263 | 272 | $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 ) ) . ')'; |
271 | 274 | } |
272 | 275 | |
273 | 276 | /** |
— | — | @@ -292,25 +295,23 @@ |
293 | 296 | $query['rcid'] = $rc->mAttribs['rc_id']; |
294 | 297 | }; |
295 | 298 | |
296 | | - $diffLink = $this->skin->link( |
| 299 | + $diffLink = Linker::linkKnown( |
297 | 300 | $rc->getTitle(), |
298 | 301 | $this->message['diff'], |
299 | 302 | array( 'tabindex' => $rc->counter ), |
300 | | - $query, |
301 | | - array( 'known', 'noclasses' ) |
| 303 | + $query |
302 | 304 | ); |
303 | 305 | } |
304 | 306 | $s .= '(' . $diffLink . $this->message['pipe-separator']; |
305 | 307 | # History link |
306 | | - $s .= $this->skin->link( |
| 308 | + $s .= Linker::linkKnown( |
307 | 309 | $rc->getTitle(), |
308 | 310 | $this->message['hist'], |
309 | 311 | array(), |
310 | 312 | array( |
311 | 313 | 'curid' => $rc->mAttribs['rc_cur_id'], |
312 | 314 | 'action' => 'history' |
313 | | - ), |
314 | | - array( 'known', 'noclasses' ) |
| 315 | + ) |
315 | 316 | ); |
316 | 317 | $s .= ') . . '; |
317 | 318 | } |
— | — | @@ -323,7 +324,6 @@ |
324 | 325 | * @return void |
325 | 326 | */ |
326 | 327 | public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) { |
327 | | - global $wgLang; |
328 | 328 | # If it's a new article, there is no diff link, but if it hasn't been |
329 | 329 | # patrolled yet, we need to give users a way to do so |
330 | 330 | $params = array(); |
— | — | @@ -333,21 +333,19 @@ |
334 | 334 | } |
335 | 335 | |
336 | 336 | if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) { |
337 | | - $articlelink = $this->skin->link( |
| 337 | + $articlelink = Linker::linkKnown( |
338 | 338 | $rc->getTitle(), |
339 | 339 | null, |
340 | 340 | array(), |
341 | | - $params, |
342 | | - array( 'known', 'noclasses' ) |
| 341 | + $params |
343 | 342 | ); |
344 | 343 | $articlelink = '<span class="history-deleted">' . $articlelink . '</span>'; |
345 | 344 | } else { |
346 | | - $articlelink = ' '. $this->skin->link( |
| 345 | + $articlelink = ' '. Linker::linkKnown( |
347 | 346 | $rc->getTitle(), |
348 | 347 | null, |
349 | 348 | array(), |
350 | | - $params, |
351 | | - array( 'known', 'noclasses' ) |
| 349 | + $params |
352 | 350 | ); |
353 | 351 | } |
354 | 352 | # Bolden pages watched by this user |
— | — | @@ -355,7 +353,7 @@ |
356 | 354 | $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>"; |
357 | 355 | } |
358 | 356 | # RTL/LTR marker |
359 | | - $articlelink .= $wgLang->getDirMark(); |
| 357 | + $articlelink .= $this->getLang()->getDirMark(); |
360 | 358 | |
361 | 359 | wfRunHooks( 'ChangesListInsertArticleLink', |
362 | 360 | array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) ); |
— | — | @@ -369,9 +367,8 @@ |
370 | 368 | * @return void |
371 | 369 | */ |
372 | 370 | public function insertTimestamp( &$s, $rc ) { |
373 | | - global $wgLang; |
374 | 371 | $s .= $this->message['semicolon-separator'] . |
375 | | - $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; |
| 372 | + $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; |
376 | 373 | } |
377 | 374 | |
378 | 375 | /** Insert links to user page, user talk page and eventually a blocking link |
— | — | @@ -382,8 +379,8 @@ |
383 | 380 | if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { |
384 | 381 | $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
385 | 382 | } 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'] ); |
388 | 385 | } |
389 | 386 | } |
390 | 387 | |
— | — | @@ -397,7 +394,7 @@ |
398 | 395 | $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>'; |
399 | 396 | } else { |
400 | 397 | $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 ); |
402 | 399 | } |
403 | 400 | } |
404 | 401 | } |
— | — | @@ -411,7 +408,7 @@ |
412 | 409 | if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) { |
413 | 410 | $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>'; |
414 | 411 | } else { |
415 | | - $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); |
| 412 | + $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); |
416 | 413 | } |
417 | 414 | } |
418 | 415 | } |
— | — | @@ -429,12 +426,11 @@ |
430 | 427 | * Returns the string which indicates the number of watching users |
431 | 428 | */ |
432 | 429 | protected function numberofWatchingusers( $count ) { |
433 | | - global $wgLang; |
434 | 430 | static $cache = array(); |
435 | 431 | if( $count > 0 ) { |
436 | 432 | if( !isset( $cache[$count] ) ) { |
437 | 433 | $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview', |
438 | | - array('parsemag', 'escape' ), $wgLang->formatNum( $count ) ); |
| 434 | + array('parsemag', 'escape' ), $this->getLang()->formatNum( $count ) ); |
439 | 435 | } |
440 | 436 | return $cache[$count]; |
441 | 437 | } else { |
— | — | @@ -481,12 +477,11 @@ |
482 | 478 | * @param $rc RecentChange |
483 | 479 | */ |
484 | 480 | public function insertRollback( &$s, &$rc ) { |
485 | | - global $wgUser; |
486 | 481 | if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) { |
487 | 482 | $page = $rc->getTitle(); |
488 | 483 | /** Check for rollback and edit permissions, disallow special pages, and only |
489 | 484 | * 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'] ) |
491 | 486 | { |
492 | 487 | $rev = new Revision( array( |
493 | 488 | 'id' => $rc->mAttribs['rc_this_oldid'], |
— | — | @@ -495,7 +490,7 @@ |
496 | 491 | 'deleted' => $rc->mAttribs['rc_deleted'] |
497 | 492 | ) ); |
498 | 493 | $rev->setTitle( $page ); |
499 | | - $s .= ' '.$this->skin->generateRollback( $rev ); |
| 494 | + $s .= ' '.Linker::generateRollback( $rev, $this->getContext() ); |
500 | 495 | } |
501 | 496 | } |
502 | 497 | } |
— | — | @@ -531,10 +526,10 @@ |
532 | 527 | * @param $rc RecentChange |
533 | 528 | */ |
534 | 529 | public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) { |
535 | | - global $wgLang, $wgRCShowChangedSize, $wgUser; |
| 530 | + global $wgRCShowChangedSize; |
536 | 531 | wfProfileIn( __METHOD__ ); |
537 | 532 | # Should patrol-related stuff be shown? |
538 | | - $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled']; |
| 533 | + $unpatrolled = $this->getUser()->useRCPatrol() && !$rc->mAttribs['rc_patrolled']; |
539 | 534 | |
540 | 535 | $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience. |
541 | 536 | $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] ); |
— | — | @@ -591,7 +586,7 @@ |
592 | 587 | # User tool links |
593 | 588 | $this->insertUserRelatedLinks( $s, $rc ); |
594 | 589 | # LTR/RTL direction mark |
595 | | - $s .= $wgLang->getDirMark(); |
| 590 | + $s .= $this->getLang()->getDirMark(); |
596 | 591 | # Log action text (if any) |
597 | 592 | $this->insertAction( $s, $rc ); |
598 | 593 | # Edit or log comment |
— | — | @@ -606,7 +601,7 @@ |
607 | 602 | # How many users watch this page |
608 | 603 | if( $rc->numberofWatchingusers > 0 ) { |
609 | 604 | $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview', |
610 | | - array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) ); |
| 605 | + array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $rc->numberofWatchingusers ) ); |
611 | 606 | } |
612 | 607 | |
613 | 608 | if( $this->watchlist ) { |
— | — | @@ -630,13 +625,12 @@ |
631 | 626 | * @return String |
632 | 627 | */ |
633 | 628 | public function beginRecentChangesList() { |
634 | | - global $wgOut; |
635 | 629 | $this->rc_cache = array(); |
636 | 630 | $this->rcMoveIndex = 0; |
637 | 631 | $this->rcCacheIndex = 0; |
638 | 632 | $this->lastdate = ''; |
639 | 633 | $this->rclistOpen = false; |
640 | | - $wgOut->addModuleStyles( 'mediawiki.special.changeslist' ); |
| 634 | + $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' ); |
641 | 635 | return ''; |
642 | 636 | } |
643 | 637 | /** |
— | — | @@ -648,8 +642,6 @@ |
649 | 643 | * @return string |
650 | 644 | */ |
651 | 645 | public function recentChangesLine( &$baseRC, $watched = false ) { |
652 | | - global $wgLang, $wgUser; |
653 | | - |
654 | 646 | wfProfileIn( __METHOD__ ); |
655 | 647 | |
656 | 648 | # Create a specialised object |
— | — | @@ -658,7 +650,7 @@ |
659 | 651 | $curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] ); |
660 | 652 | |
661 | 653 | # 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 ); |
663 | 655 | $ret = ''; |
664 | 656 | if( $date != $this->lastdate ) { |
665 | 657 | # Process current cache |
— | — | @@ -669,7 +661,7 @@ |
670 | 662 | } |
671 | 663 | |
672 | 664 | # Should patrol-related stuff be shown? |
673 | | - if( $wgUser->useRCPatrol() ) { |
| 665 | + if( $this->getUser()->useRCPatrol() ) { |
674 | 666 | $rc->unpatrolled = !$rc->mAttribs['rc_patrolled']; |
675 | 667 | } else { |
676 | 668 | $rc->unpatrolled = false; |
— | — | @@ -682,21 +674,21 @@ |
683 | 675 | // Page moves |
684 | 676 | if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) { |
685 | 677 | $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, |
687 | 679 | array(), array( 'redirect' => 'no' ) ), |
688 | | - $this->skin->linkKnown( $rc->getMovedToTitle() ) ); |
| 680 | + Linker::linkKnown( $rc->getMovedToTitle() ) ); |
689 | 681 | // New unpatrolled pages |
690 | 682 | } elseif( $rc->unpatrolled && $type == RC_NEW ) { |
691 | | - $clink = $this->skin->linkKnown( $rc->getTitle(), null, array(), |
| 683 | + $clink = Linker::linkKnown( $rc->getTitle(), null, array(), |
692 | 684 | array( 'rcid' => $rc->mAttribs['rc_id'] ) ); |
693 | 685 | // Log entries |
694 | 686 | } elseif( $type == RC_LOG ) { |
695 | 687 | if( $logType ) { |
696 | 688 | $logtitle = SpecialPage::getTitleFor( 'Log', $logType ); |
697 | | - $clink = '(' . $this->skin->linkKnown( $logtitle, |
| 689 | + $clink = '(' . Linker::linkKnown( $logtitle, |
698 | 690 | LogPage::logName( $logType ) ) . ')'; |
699 | 691 | } else { |
700 | | - $clink = $this->skin->link( $rc->getTitle() ); |
| 692 | + $clink = Linker::link( $rc->getTitle() ); |
701 | 693 | } |
702 | 694 | $watched = false; |
703 | 695 | // Log entries (old format) and special pages |
— | — | @@ -705,14 +697,14 @@ |
706 | 698 | if ( $specialName == 'Log' ) { |
707 | 699 | # Log updates, etc |
708 | 700 | $logname = LogPage::logName( $logtype ); |
709 | | - $clink = '(' . $this->skin->linkKnown( $rc->getTitle(), $logname ) . ')'; |
| 701 | + $clink = '(' . Linker::linkKnown( $rc->getTitle(), $logname ) . ')'; |
710 | 702 | } else { |
711 | 703 | wfDebug( "Unexpected special page in recentchanges\n" ); |
712 | 704 | $clink = ''; |
713 | 705 | } |
714 | 706 | // Edits |
715 | 707 | } else { |
716 | | - $clink = $this->skin->linkKnown( $rc->getTitle() ); |
| 708 | + $clink = Linker::linkKnown( $rc->getTitle() ); |
717 | 709 | } |
718 | 710 | |
719 | 711 | # Don't show unusable diff links |
— | — | @@ -720,7 +712,7 @@ |
721 | 713 | $showdifflinks = false; |
722 | 714 | } |
723 | 715 | |
724 | | - $time = $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ); |
| 716 | + $time = $this->getLang()->time( $rc->mAttribs['rc_timestamp'], true, true ); |
725 | 717 | $rc->watched = $watched; |
726 | 718 | $rc->link = $clink; |
727 | 719 | $rc->timestamp = $time; |
— | — | @@ -763,7 +755,7 @@ |
764 | 756 | } elseif( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) { |
765 | 757 | $lastLink = $this->message['last']; |
766 | 758 | } else { |
767 | | - $lastLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['last'], |
| 759 | + $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'], |
768 | 760 | array(), $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery ); |
769 | 761 | } |
770 | 762 | |
— | — | @@ -771,8 +763,8 @@ |
772 | 764 | if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { |
773 | 765 | $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
774 | 766 | } 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'] ); |
777 | 769 | } |
778 | 770 | |
779 | 771 | $rc->lastlink = $lastLink; |
— | — | @@ -807,7 +799,7 @@ |
808 | 800 | * Enhanced RC group |
809 | 801 | */ |
810 | 802 | protected function recentChangesBlockGroup( $block ) { |
811 | | - global $wgLang, $wgRCShowChangedSize; |
| 803 | + global $wgRCShowChangedSize; |
812 | 804 | |
813 | 805 | wfProfileIn( __METHOD__ ); |
814 | 806 | |
— | — | @@ -869,9 +861,9 @@ |
870 | 862 | $users = array(); |
871 | 863 | foreach( $userlinks as $userlink => $count) { |
872 | 864 | $text = $userlink; |
873 | | - $text .= $wgLang->getDirMark(); |
| 865 | + $text .= $this->getLang()->getDirMark(); |
874 | 866 | if( $count > 1 ) { |
875 | | - $text .= ' (' . $wgLang->formatNum( $count ) . '×)'; |
| 867 | + $text .= ' (' . $this->getLang()->formatNum( $count ) . '×)'; |
876 | 868 | } |
877 | 869 | array_push( $users, $text ); |
878 | 870 | } |
— | — | @@ -911,14 +903,14 @@ |
912 | 904 | $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched ); |
913 | 905 | } |
914 | 906 | |
915 | | - $r .= $wgLang->getDirMark(); |
| 907 | + $r .= $this->getLang()->getDirMark(); |
916 | 908 | |
917 | 909 | $queryParams['curid'] = $curId; |
918 | 910 | # Changes message |
919 | 911 | $n = count($block); |
920 | 912 | static $nchanges = array(); |
921 | 913 | 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 ) ); |
923 | 915 | } |
924 | 916 | # Total change link |
925 | 917 | $r .= ' '; |
— | — | @@ -933,7 +925,7 @@ |
934 | 926 | $params['diff'] = $currentRevision; |
935 | 927 | $params['oldid'] = $oldid; |
936 | 928 | |
937 | | - $r .= $this->skin->link( |
| 929 | + $r .= Linker::link( |
938 | 930 | $block[0]->getTitle(), |
939 | 931 | $nchanges[$n], |
940 | 932 | array(), |
— | — | @@ -953,12 +945,11 @@ |
954 | 946 | $params['action'] = 'history'; |
955 | 947 | |
956 | 948 | $r .= $this->message['pipe-separator'] . |
957 | | - $this->skin->link( |
| 949 | + Linker::linkKnown( |
958 | 950 | $block[0]->getTitle(), |
959 | 951 | $this->message['hist'], |
960 | 952 | array(), |
961 | | - $params, |
962 | | - array( 'known', 'noclasses' ) |
| 953 | + $params |
963 | 954 | ) . ')'; |
964 | 955 | } |
965 | 956 | $r .= ' . . '; |
— | — | @@ -1021,12 +1012,11 @@ |
1022 | 1013 | $params['rcid'] = $rcObj->mAttribs['rc_id']; |
1023 | 1014 | } |
1024 | 1015 | |
1025 | | - $link = $this->skin->link( |
| 1016 | + $link = Linker::linkKnown( |
1026 | 1017 | $rcObj->getTitle(), |
1027 | 1018 | $rcObj->timestamp, |
1028 | 1019 | array(), |
1029 | | - $params, |
1030 | | - array( 'known', 'noclasses' ) |
| 1020 | + $params |
1031 | 1021 | ); |
1032 | 1022 | if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) |
1033 | 1023 | $link = '<span class="history-deleted">'.$link.'</span> '; |
— | — | @@ -1151,15 +1141,9 @@ |
1152 | 1142 | $r .= ' '.$rcObj->timestamp.' </td><td>'; |
1153 | 1143 | # Article or log link |
1154 | 1144 | if( $logType ) { |
1155 | | - $logtitle = Title::newFromText( "Log/$logType", NS_SPECIAL ); |
| 1145 | + $logtitle = SpecialPage::getTitleFor( 'Log', $logType ); |
1156 | 1146 | $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 ) ) . ')'; |
1164 | 1148 | } else { |
1165 | 1149 | $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched ); |
1166 | 1150 | } |
— | — | @@ -1167,12 +1151,11 @@ |
1168 | 1152 | if ( $type != RC_LOG ) { |
1169 | 1153 | $r .= ' ('. $rcObj->difflink . $this->message['pipe-separator']; |
1170 | 1154 | $query['action'] = 'history'; |
1171 | | - $r .= $this->skin->link( |
| 1155 | + $r .= Linker::linkKnown( |
1172 | 1156 | $rcObj->getTitle(), |
1173 | 1157 | $this->message['hist'], |
1174 | 1158 | array(), |
1175 | | - $query, |
1176 | | - array( 'known', 'noclasses' ) |
| 1159 | + $query |
1177 | 1160 | ) . ')'; |
1178 | 1161 | } |
1179 | 1162 | $r .= ' . . '; |
— | — | @@ -1188,7 +1171,7 @@ |
1189 | 1172 | $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; |
1190 | 1173 | } else { |
1191 | 1174 | $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 ); |
1193 | 1176 | } |
1194 | 1177 | } |
1195 | 1178 | $this->insertComment( $r, $rcObj ); |
Index: trunk/phase3/includes/specials/SpecialRecentchangeslinked.php |
— | — | @@ -46,9 +46,8 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function feedSetup() { |
50 | | - global $wgRequest; |
51 | 50 | $opts = parent::feedSetup(); |
52 | | - $opts['target'] = $wgRequest->getVal( 'target' ); |
| 51 | + $opts['target'] = $this->getRequest()->getVal( 'target' ); |
53 | 52 | return $opts; |
54 | 53 | } |
55 | 54 | |
— | — | @@ -63,8 +62,6 @@ |
64 | 63 | } |
65 | 64 | |
66 | 65 | public function doMainQuery( $conds, $opts ) { |
67 | | - global $wgUser, $wgOut; |
68 | | - |
69 | 66 | $target = $opts['target']; |
70 | 67 | $showlinkedto = $opts['showlinkedto']; |
71 | 68 | $limit = $opts['limit']; |
— | — | @@ -74,11 +71,11 @@ |
75 | 72 | } |
76 | 73 | $title = Title::newFromURL( $target ); |
77 | 74 | 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' ); |
79 | 76 | return false; |
80 | 77 | } |
81 | 78 | |
82 | | - $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) ); |
| 79 | + $this->getOutput()->setPageTitle( wfMsg( 'recentchangeslinked-title', $title->getPrefixedText() ) ); |
83 | 80 | |
84 | 81 | /* |
85 | 82 | * Ordinary links are in the pagelinks table, while transclusions are |
— | — | @@ -100,13 +97,13 @@ |
101 | 98 | $query_options = array(); |
102 | 99 | |
103 | 100 | // left join with watchlist table to highlight watched rows |
104 | | - $uid = $wgUser->getId(); |
| 101 | + $uid = $this->getUser()->getId(); |
105 | 102 | if( $uid ) { |
106 | 103 | $tables[] = 'watchlist'; |
107 | 104 | $select[] = 'wl_user'; |
108 | 105 | $join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" ); |
109 | 106 | } |
110 | | - if ( $wgUser->isAllowed( 'rollback' ) ) { |
| 107 | + if ( $this->getUser()->isAllowed( 'rollback' ) ) { |
111 | 108 | $tables[] = 'page'; |
112 | 109 | $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id'); |
113 | 110 | $select[] = 'page_latest'; |
— | — | @@ -235,12 +232,12 @@ |
236 | 233 | return $this->rclTargetTitle; |
237 | 234 | } |
238 | 235 | |
239 | | - function setTopText( OutputPage $out, FormOptions $opts ) { |
240 | | - $skin = $this->getSkin(); |
| 236 | + function setTopText( FormOptions $opts ) { |
241 | 237 | $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, |
244 | 240 | $target->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) ); |
| 241 | + } |
245 | 242 | } |
246 | 243 | |
247 | 244 | public function getFeedQuery() { |
— | — | @@ -252,9 +249,9 @@ |
253 | 250 | } |
254 | 251 | } |
255 | 252 | |
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' ); |
259 | 256 | } |
260 | 257 | } |
261 | 258 | } |
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php |
— | — | @@ -71,8 +71,6 @@ |
72 | 72 | * @return FormOptions |
73 | 73 | */ |
74 | 74 | public function setup( $parameters ) { |
75 | | - global $wgRequest; |
76 | | - |
77 | 75 | $opts = $this->getDefaultOptions(); |
78 | 76 | |
79 | 77 | $this->customFilters = array(); |
— | — | @@ -81,7 +79,7 @@ |
82 | 80 | $opts->add( $key, $params['default'] ); |
83 | 81 | } |
84 | 82 | |
85 | | - $opts->fetchValuesFromRequest( $wgRequest ); |
| 83 | + $opts->fetchValuesFromRequest( $this->getRequest() ); |
86 | 84 | |
87 | 85 | // Give precedence to subpage syntax |
88 | 86 | if( $parameters !== null ) { |
— | — | @@ -98,10 +96,10 @@ |
99 | 97 | * @return FormOptions |
100 | 98 | */ |
101 | 99 | public function feedSetup() { |
102 | | - global $wgFeedLimit, $wgRequest; |
| 100 | + global $wgFeedLimit; |
103 | 101 | $opts = $this->getDefaultOptions(); |
104 | 102 | # 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' ) ); |
106 | 104 | $opts->validateIntBounds( 'limit', 0, $wgFeedLimit ); |
107 | 105 | return $opts; |
108 | 106 | } |
— | — | @@ -114,8 +112,7 @@ |
115 | 113 | if ( $this->including() ) { |
116 | 114 | $isFeed = false; |
117 | 115 | } else { |
118 | | - global $wgRequest; |
119 | | - $isFeed = (bool)$wgRequest->getVal( 'feed' ); |
| 116 | + $isFeed = (bool)$this->getRequest()->getVal( 'feed' ); |
120 | 117 | } |
121 | 118 | $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage ); |
122 | 119 | } |
— | — | @@ -129,12 +126,11 @@ |
130 | 127 | * @param $subpage String |
131 | 128 | */ |
132 | 129 | public function execute( $subpage ) { |
133 | | - global $wgRequest, $wgOut; |
134 | 130 | $this->rcSubpage = $subpage; |
135 | | - $feedFormat = $this->including() ? null : $wgRequest->getVal( 'feed' ); |
| 131 | + $feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' ); |
136 | 132 | |
137 | 133 | # 10 seconds server-side caching max |
138 | | - $wgOut->setSquidMaxage( 10 ); |
| 134 | + $this->getOutput()->setSquidMaxage( 10 ); |
139 | 135 | # Check if the client has a cached version |
140 | 136 | $lastmod = $this->checkLastModified( $feedFormat ); |
141 | 137 | if( $lastmod === false ) { |
— | — | @@ -453,14 +449,13 @@ |
454 | 450 | } |
455 | 451 | |
456 | 452 | /** |
457 | | - * Send output to $wgOut, only called if not used feeds |
| 453 | + * Send output to the OutputPage object, only called if not used feeds |
458 | 454 | * |
459 | 455 | * @param $rows Array of database rows |
460 | 456 | * @param $opts FormOptions |
461 | 457 | */ |
462 | 458 | public function webOutput( $rows, $opts ) { |
463 | | - global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker; |
464 | | - global $wgAllowCategorizedRecentChanges; |
| 459 | + global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges; |
465 | 460 | |
466 | 461 | $limit = $opts['limit']; |
467 | 462 | |
— | — | @@ -470,7 +465,7 @@ |
471 | 466 | } |
472 | 467 | |
473 | 468 | // And now for the content |
474 | | - $wgOut->setFeedAppendQuery( $this->getFeedQuery() ); |
| 469 | + $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() ); |
475 | 470 | |
476 | 471 | if( $wgAllowCategorizedRecentChanges ) { |
477 | 472 | $this->filterByCategories( $rows, $opts ); |
— | — | @@ -482,7 +477,7 @@ |
483 | 478 | $dbr = wfGetDB( DB_SLAVE ); |
484 | 479 | |
485 | 480 | $counter = 1; |
486 | | - $list = ChangesList::newFromUser( $this->getUser() ); |
| 481 | + $list = ChangesList::newFromContext( $this->getContext() ); |
487 | 482 | |
488 | 483 | $s = $list->beginRecentChangesList(); |
489 | 484 | foreach( $rows as $obj ) { |
— | — | @@ -518,7 +513,7 @@ |
519 | 514 | --$limit; |
520 | 515 | } |
521 | 516 | $s .= $list->endRecentChangesList(); |
522 | | - $wgOut->addHTML( $s ); |
| 517 | + $this->getOutput()->addHTML( $s ); |
523 | 518 | } |
524 | 519 | |
525 | 520 | /** |
— | — | @@ -536,9 +531,9 @@ |
537 | 532 | * @return String: XHTML |
538 | 533 | */ |
539 | 534 | public function doHeader( $opts ) { |
540 | | - global $wgScript, $wgOut; |
| 535 | + global $wgScript; |
541 | 536 | |
542 | | - $this->setTopText( $wgOut, $opts ); |
| 537 | + $this->setTopText( $opts ); |
543 | 538 | |
544 | 539 | $defaults = $opts->getAllValues(); |
545 | 540 | $nondefaults = $opts->getChangedValues(); |
— | — | @@ -584,11 +579,11 @@ |
585 | 580 | $panel[] = $form; |
586 | 581 | $panelString = implode( "\n", $panel ); |
587 | 582 | |
588 | | - $wgOut->addHTML( |
| 583 | + $this->getOutput()->addHTML( |
589 | 584 | Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) ) |
590 | 585 | ); |
591 | 586 | |
592 | | - $this->setBottomText( $wgOut, $opts ); |
| 587 | + $this->setBottomText( $opts ); |
593 | 588 | } |
594 | 589 | |
595 | 590 | /** |
— | — | @@ -618,21 +613,19 @@ |
619 | 614 | /** |
620 | 615 | * Send the text to be displayed above the options |
621 | 616 | * |
622 | | - * @param $out OutputPage |
623 | 617 | * @param $opts FormOptions |
624 | 618 | */ |
625 | | - function setTopText( OutputPage $out, FormOptions $opts ) { |
626 | | - $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) ); |
| 619 | + function setTopText( FormOptions $opts ) { |
| 620 | + $this->getOutput()->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) ); |
627 | 621 | } |
628 | 622 | |
629 | 623 | /** |
630 | 624 | * Send the text to be displayed after the options, for use in |
631 | 625 | * Recentchangeslinked |
632 | 626 | * |
633 | | - * @param $out OutputPage |
634 | 627 | * @param $opts FormOptions |
635 | 628 | */ |
636 | | - function setBottomText( OutputPage $out, FormOptions $opts ) {} |
| 629 | + function setBottomText( FormOptions $opts ) {} |
637 | 630 | |
638 | 631 | /** |
639 | 632 | * Creates the choose namespace selection |
— | — | @@ -747,16 +740,11 @@ |
748 | 741 | */ |
749 | 742 | function makeOptionsLink( $title, $override, $options, $active = false ) { |
750 | 743 | $params = $override + $options; |
| 744 | + $text = htmlspecialchars( $title ); |
751 | 745 | 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>'; |
760 | 747 | } |
| 748 | + return Linker::linkKnown( $this->getTitle(), $text, array(), $params ); |
761 | 749 | } |
762 | 750 | |
763 | 751 | /** |
— | — | @@ -766,7 +754,7 @@ |
767 | 755 | * @param $nondefaults Array |
768 | 756 | */ |
769 | 757 | function optionsPanel( $defaults, $nondefaults ) { |
770 | | - global $wgLang, $wgRCLinkLimits, $wgRCLinkDays; |
| 758 | + global $wgRCLinkLimits, $wgRCLinkDays; |
771 | 759 | |
772 | 760 | $options = $nondefaults + $defaults; |
773 | 761 | |
— | — | @@ -777,10 +765,10 @@ |
778 | 766 | } |
779 | 767 | if( $options['from'] ) { |
780 | 768 | $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 />'; |
785 | 773 | } |
786 | 774 | |
787 | 775 | # Sort data for display and make sure it's unique after we've added user data. |
— | — | @@ -793,17 +781,17 @@ |
794 | 782 | |
795 | 783 | // limit links |
796 | 784 | foreach( $wgRCLinkLimits as $value ) { |
797 | | - $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), |
| 785 | + $cl[] = $this->makeOptionsLink( $this->getLang()->formatNum( $value ), |
798 | 786 | array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ); |
799 | 787 | } |
800 | | - $cl = $wgLang->pipeList( $cl ); |
| 788 | + $cl = $this->getLang()->pipeList( $cl ); |
801 | 789 | |
802 | 790 | // day links, reset 'from' to none |
803 | 791 | foreach( $wgRCLinkDays as $value ) { |
804 | | - $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), |
| 792 | + $dl[] = $this->makeOptionsLink( $this->getLang()->formatNum( $value ), |
805 | 793 | array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ); |
806 | 794 | } |
807 | | - $dl = $wgLang->pipeList( $dl ); |
| 795 | + $dl = $this->getLang()->pipeList( $dl ); |
808 | 796 | |
809 | 797 | |
810 | 798 | // show/hide links |
— | — | @@ -833,13 +821,13 @@ |
834 | 822 | |
835 | 823 | // show from this onward link |
836 | 824 | $timestamp = wfTimestampNow(); |
837 | | - $now = $wgLang->timeanddate( $timestamp, true ); |
| 825 | + $now = $this->getLang()->timeanddate( $timestamp, true ); |
838 | 826 | $tl = $this->makeOptionsLink( |
839 | 827 | $now, array( 'from' => $timestamp ), $nondefaults |
840 | 828 | ); |
841 | 829 | |
842 | 830 | $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ), |
843 | | - $cl, $dl, $wgLang->pipeList( $links ) ); |
| 831 | + $cl, $dl, $this->getLang()->pipeList( $links ) ); |
844 | 832 | $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); |
845 | 833 | return "{$note}$rclinks<br />$rclistfrom"; |
846 | 834 | } |
— | — | @@ -848,8 +836,7 @@ |
849 | 837 | * add javascript specific to the [[Special:RecentChanges]] page |
850 | 838 | */ |
851 | 839 | function addRecentChangesJS() { |
852 | | - global $wgOut; |
853 | | - $wgOut->addModules( array( |
| 840 | + $this->getOutput()->addModules( array( |
854 | 841 | 'mediawiki.special.recentchanges', |
855 | 842 | ) ); |
856 | 843 | } |
Index: trunk/phase3/includes/specials/SpecialWatchlist.php |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | array(), |
64 | 64 | array( 'returnto' => $this->getTitle()->getPrefixedText() ) |
65 | 65 | ); |
66 | | - $output->addWikiMsgArray( 'watchlistanontext', array( $llink ), array( 'replaceafter' ) ); |
| 66 | + $out->addHTML( wfMessage( 'watchlistanontext' )->rawParam( $llink )->parse() ); |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
— | — | @@ -380,7 +380,7 @@ |
381 | 381 | $linkBatch->execute(); |
382 | 382 | $dbr->dataSeek( $res, 0 ); |
383 | 383 | |
384 | | - $list = ChangesList::newFromUser( $this->getUser() ); |
| 384 | + $list = ChangesList::newFromContext( $this->getContext() ); |
385 | 385 | $list->setWatchlistDivs(); |
386 | 386 | |
387 | 387 | $s = $list->beginRecentChangesList(); |