From ffcac0f56cd5ec28657ac928c00e49d71636224f Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 27 Sep 2011 15:13:37 +0000 Subject: [PATCH] * Use local context instead of global variables * Call Linker methods statically * Changed link to Special:Whatlinkshere on Special:Mostlinkedtemplates to pass the page in the subpage parameter instead of "target" to match Special:Mostlinked's behaviour --- includes/specials/SpecialMostcategories.php | 5 ++--- includes/specials/SpecialMostimages.php | 4 +--- includes/specials/SpecialMostlinked.php | 11 ++++------- includes/specials/SpecialMostlinkedcategories.php | 7 +++---- includes/specials/SpecialMostlinkedtemplates.php | 15 ++++++--------- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/includes/specials/SpecialMostcategories.php b/includes/specials/SpecialMostcategories.php index 2e43719673..cc8e492540 100644 --- a/includes/specials/SpecialMostcategories.php +++ b/includes/specials/SpecialMostcategories.php @@ -58,11 +58,10 @@ class MostcategoriesPage extends QueryPage { * @return string */ function formatResult( $skin, $result ) { - global $wgLang; $title = Title::makeTitleSafe( $result->namespace, $result->title ); - $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) ); - $link = $skin->link( $title ); + $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped(); + $link = Linker::link( $title ); return wfSpecialList( $link, $count ); } } diff --git a/includes/specials/SpecialMostimages.php b/includes/specials/SpecialMostimages.php index ac2b5206f0..7805e53e73 100644 --- a/includes/specials/SpecialMostimages.php +++ b/includes/specials/SpecialMostimages.php @@ -50,9 +50,7 @@ class MostimagesPage extends ImageQueryPage { } function getCellHtml( $row ) { - global $wgLang; - return wfMsgExt( 'nimagelinks', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $row->value ) ) . '
'; + return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '
'; } } diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index 58f686e8e4..6707d6a9e1 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -77,12 +77,11 @@ class MostlinkedPage extends QueryPage { * * @param $title Title being queried * @param $caption String: text to display on the link - * @param $skin Skin to use * @return String */ - function makeWlhLink( &$title, $caption, &$skin ) { + function makeWlhLink( $title, $caption ) { $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() ); - return $skin->linkKnown( $wlh, $caption ); + return Linker::linkKnown( $wlh, $caption ); } /** @@ -93,15 +92,13 @@ class MostlinkedPage extends QueryPage { * @return string */ function formatResult( $skin, $result ) { - global $wgLang; $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { return ''; } - $link = $skin->link( $title ); + $link = Linker::link( $title ); $wlh = $this->makeWlhLink( $title, - wfMsgExt( 'nlinks', array( 'parsemag', 'escape'), - $wgLang->formatNum( $result->value ) ), $skin ); + $this->msg( 'nlinks' )->numParams( $result->value )->escaped() ); return wfSpecialList( $link, $wlh ); } } diff --git a/includes/specials/SpecialMostlinkedcategories.php b/includes/specials/SpecialMostlinkedcategories.php index 195282f7d9..4cc7c0447b 100644 --- a/includes/specials/SpecialMostlinkedcategories.php +++ b/includes/specials/SpecialMostlinkedcategories.php @@ -76,15 +76,14 @@ class MostlinkedCategoriesPage extends QueryPage { * @return string */ function formatResult( $skin, $result ) { - global $wgLang, $wgContLang; + global $wgContLang; $nt = Title::makeTitle( NS_CATEGORY, $result->title ); $text = $wgContLang->convert( $nt->getText() ); - $plink = $skin->link( $nt, htmlspecialchars( $text ) ); + $plink = Linker::link( $nt, htmlspecialchars( $text ) ); - $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $result->value ) ); + $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); return wfSpecialList( $plink, $nlinks ); } } diff --git a/includes/specials/SpecialMostlinkedtemplates.php b/includes/specials/SpecialMostlinkedtemplates.php index 73a60a049c..239a2d7f44 100644 --- a/includes/specials/SpecialMostlinkedtemplates.php +++ b/includes/specials/SpecialMostlinkedtemplates.php @@ -99,8 +99,8 @@ class MostlinkedTemplatesPage extends QueryPage { $title = Title::makeTitle( $result->namespace, $result->title ); return wfSpecialList( - $skin->link( $title ), - $this->makeWlhLink( $title, $skin, $result ) + Linker::link( $title ), + $this->makeWlhLink( $title, $result ) ); } @@ -108,16 +108,13 @@ class MostlinkedTemplatesPage extends QueryPage { * Make a "what links here" link for a given title * * @param $title Title to make the link for - * @param $skin Skin to use * @param $result Result row * @return String */ - private function makeWlhLink( $title, $skin, $result ) { - global $wgLang; - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); - $label = wfMsgExt( 'ntransclusions', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $result->value ) ); - return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); + private function makeWlhLink( $title, $result ) { + $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ); + $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->escaped(); + return Linker::link( $wlh, $label ); } } -- 2.20.1