r98223 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98222‎ | r98223 | r98224 >
Date:15:13, 27 September 2011
Author:ialex
Status:ok
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/includes/specials/SpecialMostcategories.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMostimages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMostlinked.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMostlinkedcategories.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMostlinkedtemplates.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialMostcategories.php
@@ -58,11 +58,10 @@
5959 * @return string
6060 */
6161 function formatResult( $skin, $result ) {
62 - global $wgLang;
6362 $title = Title::makeTitleSafe( $result->namespace, $result->title );
6463
65 - $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
66 - $link = $skin->link( $title );
 64+ $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped();
 65+ $link = Linker::link( $title );
6766 return wfSpecialList( $link, $count );
6867 }
6968 }
Index: trunk/phase3/includes/specials/SpecialMostimages.php
@@ -50,9 +50,7 @@
5151 }
5252
5353 function getCellHtml( $row ) {
54 - global $wgLang;
55 - return wfMsgExt( 'nimagelinks', array( 'parsemag', 'escape' ),
56 - $wgLang->formatNum( $row->value ) ) . '<br />';
 54+ return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '<br />';
5755 }
5856
5957 }
Index: trunk/phase3/includes/specials/SpecialMostlinkedtemplates.php
@@ -99,8 +99,8 @@
100100 $title = Title::makeTitle( $result->namespace, $result->title );
101101
102102 return wfSpecialList(
103 - $skin->link( $title ),
104 - $this->makeWlhLink( $title, $skin, $result )
 103+ Linker::link( $title ),
 104+ $this->makeWlhLink( $title, $result )
105105 );
106106 }
107107
@@ -108,16 +108,13 @@
109109 * Make a "what links here" link for a given title
110110 *
111111 * @param $title Title to make the link for
112 - * @param $skin Skin to use
113112 * @param $result Result row
114113 * @return String
115114 */
116 - private function makeWlhLink( $title, $skin, $result ) {
117 - global $wgLang;
118 - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
119 - $label = wfMsgExt( 'ntransclusions', array( 'parsemag', 'escape' ),
120 - $wgLang->formatNum( $result->value ) );
121 - return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
 115+ private function makeWlhLink( $title, $result ) {
 116+ $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
 117+ $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->escaped();
 118+ return Linker::link( $wlh, $label );
122119 }
123120 }
124121
Index: trunk/phase3/includes/specials/SpecialMostlinked.php
@@ -77,12 +77,11 @@
7878 *
7979 * @param $title Title being queried
8080 * @param $caption String: text to display on the link
81 - * @param $skin Skin to use
8281 * @return String
8382 */
84 - function makeWlhLink( &$title, $caption, &$skin ) {
 83+ function makeWlhLink( $title, $caption ) {
8584 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
86 - return $skin->linkKnown( $wlh, $caption );
 85+ return Linker::linkKnown( $wlh, $caption );
8786 }
8887
8988 /**
@@ -93,15 +92,13 @@
9493 * @return string
9594 */
9695 function formatResult( $skin, $result ) {
97 - global $wgLang;
9896 $title = Title::makeTitleSafe( $result->namespace, $result->title );
9997 if ( !$title ) {
10098 return '<!-- ' . htmlspecialchars( "Invalid title: [[$title]]" ) . ' -->';
10199 }
102 - $link = $skin->link( $title );
 100+ $link = Linker::link( $title );
103101 $wlh = $this->makeWlhLink( $title,
104 - wfMsgExt( 'nlinks', array( 'parsemag', 'escape'),
105 - $wgLang->formatNum( $result->value ) ), $skin );
 102+ $this->msg( 'nlinks' )->numParams( $result->value )->escaped() );
106103 return wfSpecialList( $link, $wlh );
107104 }
108105 }
Index: trunk/phase3/includes/specials/SpecialMostlinkedcategories.php
@@ -76,15 +76,14 @@
7777 * @return string
7878 */
7979 function formatResult( $skin, $result ) {
80 - global $wgLang, $wgContLang;
 80+ global $wgContLang;
8181
8282 $nt = Title::makeTitle( NS_CATEGORY, $result->title );
8383 $text = $wgContLang->convert( $nt->getText() );
8484
85 - $plink = $skin->link( $nt, htmlspecialchars( $text ) );
 85+ $plink = Linker::link( $nt, htmlspecialchars( $text ) );
8686
87 - $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
88 - $wgLang->formatNum( $result->value ) );
 87+ $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
8988 return wfSpecialList( $plink, $nlinks );
9089 }
9190 }

Status & tagging log