* Use local context instead of global variables
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 27 Sep 2011 15:13:37 +0000 (15:13 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 27 Sep 2011 15:13:37 +0000 (15:13 +0000)
* 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
includes/specials/SpecialMostimages.php
includes/specials/SpecialMostlinked.php
includes/specials/SpecialMostlinkedcategories.php
includes/specials/SpecialMostlinkedtemplates.php

index 2e43719..cc8e492 100644 (file)
@@ -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 );
        }
 }
index ac2b520..7805e53 100644 (file)
@@ -50,9 +50,7 @@ class MostimagesPage extends ImageQueryPage {
        }
 
        function getCellHtml( $row ) {
-               global $wgLang;
-               return wfMsgExt( 'nimagelinks',  array( 'parsemag', 'escape' ),
-                       $wgLang->formatNum( $row->value ) ) . '<br />';
+               return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '<br />';
        }
 
 }
index 58f686e..6707d6a 100644 (file)
@@ -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 '<!-- ' . htmlspecialchars( "Invalid title: [[$title]]" ) . ' -->';
                }
-               $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 );
        }
 }
index 195282f..4cc7c04 100644 (file)
@@ -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 );
        }
 }
index 73a60a0..239a2d7 100644 (file)
@@ -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 );
        }
 }