From 08be017dcc257797bac60d1caa0aa8674251936b Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Mon, 4 Apr 2011 02:00:47 +0000 Subject: [PATCH] Update special pages which use $wgUser->getSkin(); inside their constructor: - Use the Linker:: properly - Don't use $wgOut, $wgUser, $wgRequest - Don't fetch the skin early --- includes/specials/SpecialListgrouprights.php | 23 ++++----- includes/specials/SpecialSpecialpages.php | 24 ++++----- includes/specials/SpecialWhatlinkshere.php | 54 +++++++++----------- 3 files changed, 47 insertions(+), 54 deletions(-) diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 29eef62193..7a49b3e953 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -30,30 +30,27 @@ */ class SpecialListGroupRights extends SpecialPage { - var $skin; - /** * Constructor */ function __construct() { - global $wgUser; parent::__construct( 'Listgrouprights' ); - $this->skin = $wgUser->getSkin(); } /** * Show the special page */ public function execute( $par ) { - global $wgOut, $wgImplicitGroups; + global $wgImplicitGroups; global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups; global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; + $out = $this->getOutput(); $this->setHeaders(); $this->outputHeader(); - $wgOut->addModuleStyles( 'mediawiki.special' ); + $out->addModuleStyles( 'mediawiki.special' ); - $wgOut->addHTML( + $out->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable mw-listgrouprights-table' ) ) . '' . Xml::element( 'th', null, wfMsg( 'listgrouprights-group' ) ) . @@ -91,7 +88,7 @@ class SpecialListGroupRights extends SpecialPage { // Do not make a link for the generic * group $grouppage = htmlspecialchars( $groupnameLocalized ); } else { - $grouppage = $this->skin->link( + $grouppage = Linker::link( Title::newFromText( $grouppageLocalized ), htmlspecialchars( $groupnameLocalized ) ); @@ -99,7 +96,7 @@ class SpecialListGroupRights extends SpecialPage { if ( $group === 'user' ) { // Link to Special:listusers for implicit group 'user' - $grouplink = '
' . $this->skin->link( + $grouplink = '
' . Linker::link( SpecialPage::getTitleFor( 'Listusers' ), wfMsgHtml( 'listgrouprights-members' ), array(), @@ -107,7 +104,7 @@ class SpecialListGroupRights extends SpecialPage { array( 'known', 'noclasses' ) ); } elseif ( !in_array( $group, $wgImplicitGroups ) ) { - $grouplink = '
' . $this->skin->link( + $grouplink = '
' . Linker::link( SpecialPage::getTitleFor( 'Listusers' ), wfMsgHtml( 'listgrouprights-members' ), array(), @@ -126,7 +123,7 @@ class SpecialListGroupRights extends SpecialPage { $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] ) ? $wgGroupsRemoveFromSelf[$group] : array(); $id = $group == '*' ? false : Sanitizer::escapeId( $group ); - $wgOut->addHTML( Html::rawElement( 'tr', array( 'id' => $id ), + $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ), " $grouppage$grouplink " . @@ -135,10 +132,10 @@ class SpecialListGroupRights extends SpecialPage { ' ) ); } - $wgOut->addHTML( + $out->addHTML( Xml::closeElement( 'table' ) . "\n

\n" ); - $wgOut->wrapWikiMsg( "
\n$1\n
", 'listgrouprights-key' ); + $out->wrapWikiMsg( "
\n$1\n
", 'listgrouprights-key' ); } /** diff --git a/includes/specials/SpecialSpecialpages.php b/includes/specials/SpecialSpecialpages.php index 638f235a43..6939bfb317 100644 --- a/includes/specials/SpecialSpecialpages.php +++ b/includes/specials/SpecialSpecialpages.php @@ -33,11 +33,11 @@ class SpecialSpecialpages extends UnlistedSpecialPage { } function execute( $par ) { - global $wgOut; + $out = $this->getOutput(); $this->setHeaders(); $this->outputHeader(); - $wgOut->allowClickjacking(); - $wgOut->addModuleStyles( 'mediawiki.special' ); + $out->allowClickjacking(); + $out->addModuleStyles( 'mediawiki.special' ); $groups = $this->getPageGroups(); @@ -88,9 +88,9 @@ class SpecialSpecialpages extends UnlistedSpecialPage { } private function outputPageList( $groups ) { - global $wgUser, $wgOut, $wgMiserMode; + global $wgMiserMode; + $out = $this->getOutput(); - $sk = $wgUser->getSkin(); $includesRestrictedPages = false; $includesCachedPages = false; @@ -99,8 +99,8 @@ class SpecialSpecialpages extends UnlistedSpecialPage { $total = count( $sortedPages ); $count = 0; - $wgOut->wrapWikiMsg( "

$1

\n", "specialpages-group-$group" ); - $wgOut->addHTML( + $out->wrapWikiMsg( "

$1

\n", "specialpages-group-$group" ); + $out->addHTML( Html::openElement( 'table', array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' ) ) ."\n" . Html::openElement( 'tr' ) . "\n" . Html::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" . @@ -119,20 +119,20 @@ class SpecialSpecialpages extends UnlistedSpecialPage { $pageClasses[] = 'mw-specialpagerestricted'; } - $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) ); - $wgOut->addHTML( Html::rawElement( 'li', array( 'class' => implode( ' ', $pageClasses ) ), $link ) . "\n" ); + $link = Linker::linkKnown( $title , htmlspecialchars( $desc ) ); + $out->addHTML( Html::rawElement( 'li', array( 'class' => implode( ' ', $pageClasses ) ), $link ) . "\n" ); # Split up the larger groups $count++; if( $total > 3 && $count == $middle ) { - $wgOut->addHTML( + $out->addHTML( Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) . Html::element( 'td', array( 'style' => 'width:10%' ), '' ) . Html::openElement( 'td', array( 'style' => 'width:30%' ) ) . Html::openElement( 'ul' ) . "\n" ); } } - $wgOut->addHTML( + $out->addHTML( Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) . Html::element( 'td', array( 'style' => 'width:30%' ), '' ) . Html::closeElement( 'tr' ) . Html::closeElement( 'table' ) . "\n" @@ -140,7 +140,7 @@ class SpecialSpecialpages extends UnlistedSpecialPage { } if ( $includesRestrictedPages || $includesCachedPages ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'specialpages-note' ); + $out->wrapWikiMsg( "
\n$1\n
", 'specialpages-note' ); } } } diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index c7f9b5a361..44dd227381 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -31,20 +31,15 @@ class SpecialWhatLinksHere extends SpecialPage { // Stored objects protected $opts, $target, $selfTitle; - // Stored globals - protected $skin; - protected $limits = array( 20, 50, 100, 250, 500 ); public function __construct() { parent::__construct( 'Whatlinkshere' ); - global $wgUser; - $this->skin = $wgUser->getSkin(); } function execute( $par ) { - global $wgOut, $wgRequest; - + $out = $this->getOutput(); + $this->setHeaders(); $opts = new FormOptions(); @@ -59,7 +54,7 @@ class SpecialWhatLinksHere extends SpecialPage { $opts->add( 'hidelinks', false ); $opts->add( 'hideimages', false ); - $opts->fetchValuesFromRequest( $wgRequest ); + $opts->fetchValuesFromRequest( $this->getRequest() ); $opts->validateIntBounds( 'limit', 0, 5000 ); // Give precedence to subpage syntax @@ -72,17 +67,17 @@ class SpecialWhatLinksHere extends SpecialPage { $this->target = Title::newFromURL( $opts->getValue( 'target' ) ); if( !$this->target ) { - $wgOut->addHTML( $this->whatlinkshereForm() ); + $out->addHTML( $this->whatlinkshereForm() ); return; } - $this->skin->setRelevantTitle( $this->target ); + $this->getSkin()->setRelevantTitle( $this->target ); $this->selfTitle = $this->getTitle( $this->target->getPrefixedDBkey() ); - $wgOut->setPageTitle( wfMsg( 'whatlinkshere-title', $this->target->getPrefixedText() ) ); - $wgOut->setSubtitle( wfMsg( 'whatlinkshere-backlink', $this->skin->link( $this->target, $this->target->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) ); + $out->setPageTitle( wfMsg( 'whatlinkshere-title', $this->target->getPrefixedText() ) ); + $out->setSubtitle( wfMsg( 'whatlinkshere-backlink', Linker::link( $this->target, $this->target->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) ); $this->showIndirectLinks( 0, $this->target, $opts->getValue( 'limit' ), $opts->getValue( 'from' ), $opts->getValue( 'back' ) ); @@ -97,7 +92,8 @@ class SpecialWhatLinksHere extends SpecialPage { * @private */ function showIndirectLinks( $level, $target, $limit, $from = 0, $back = 0 ) { - global $wgOut, $wgMaxRedirectLinksRetrieved; + global $wgMaxRedirectLinksRetrieved; + $out = $this->getOutput(); $dbr = wfGetDB( DB_SLAVE ); $options = array(); @@ -174,14 +170,14 @@ class SpecialWhatLinksHere extends SpecialPage { if( ( !$fetchlinks || !$dbr->numRows($plRes) ) && ( $hidetrans || !$dbr->numRows($tlRes) ) && ( $hideimages || !$dbr->numRows($ilRes) ) ) { if ( 0 == $level ) { - $wgOut->addHTML( $this->whatlinkshereForm() ); + $out->addHTML( $this->whatlinkshereForm() ); // Show filters only if there are links if( $hidelinks || $hidetrans || $hideredirs || $hideimages ) - $wgOut->addHTML( $this->getFilterPanel() ); + $out->addHTML( $this->getFilterPanel() ); $errMsg = is_int($namespace) ? 'nolinkshere-ns' : 'nolinkshere'; - $wgOut->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); + $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); } return; } @@ -231,31 +227,31 @@ class SpecialWhatLinksHere extends SpecialPage { $prevId = $from; if ( $level == 0 ) { - $wgOut->addHTML( $this->whatlinkshereForm() ); - $wgOut->addHTML( $this->getFilterPanel() ); - $wgOut->addWikiMsg( 'linkshere', $this->target->getPrefixedText() ); + $out->addHTML( $this->whatlinkshereForm() ); + $out->addHTML( $this->getFilterPanel() ); + $out->addWikiMsg( 'linkshere', $this->target->getPrefixedText() ); $prevnext = $this->getPrevNext( $prevId, $nextId ); - $wgOut->addHTML( $prevnext ); + $out->addHTML( $prevnext ); } - $wgOut->addHTML( $this->listStart( $level ) ); + $out->addHTML( $this->listStart( $level ) ); foreach ( $rows as $row ) { $nt = Title::makeTitle( $row->page_namespace, $row->page_title ); if ( $row->page_is_redirect && $level < 2 ) { - $wgOut->addHTML( $this->listItem( $row, $nt, true ) ); + $out->addHTML( $this->listItem( $row, $nt, true ) ); $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved ); - $wgOut->addHTML( Xml::closeElement( 'li' ) ); + $out->addHTML( Xml::closeElement( 'li' ) ); } else { - $wgOut->addHTML( $this->listItem( $row, $nt ) ); + $out->addHTML( $this->listItem( $row, $nt ) ); } } - $wgOut->addHTML( $this->listEnd() ); + $out->addHTML( $this->listEnd() ); if( $level == 0 ) { - $wgOut->addHTML( $prevnext ); + $out->addHTML( $prevnext ); } } @@ -281,7 +277,7 @@ class SpecialWhatLinksHere extends SpecialPage { $query = array(); } - $link = $this->skin->linkKnown( + $link = Linker::linkKnown( $nt, null, array(), @@ -320,7 +316,7 @@ class SpecialWhatLinksHere extends SpecialPage { if ( $title === null ) $title = $this->getTitle(); - return $this->skin->linkKnown( + return Linker::linkKnown( $title, $text, array(), @@ -329,7 +325,7 @@ class SpecialWhatLinksHere extends SpecialPage { } function makeSelfLink( $text, $query ) { - return $this->skin->linkKnown( + return Linker::linkKnown( $this->selfTitle, $text, array(), -- 2.20.1