r99678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99677‎ | r99678 | r99679 >
Date:11:46, 13 October 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Moved wfSpecialList() to Language::specialList() so that it can be used in the context of special pages instead of relying unconditionally of $wgLang. Updated all calls in core and added a @deprecated comment to wfSpecialList() but not a wfDeprecated() call since it's still used in SiteMatrix and StalePages extensions.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/QueryPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialActiveusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAncientpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialCategories.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialFewestrevisions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMostcategories.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)
  • /trunk/phase3/includes/specials/SpecialPopularpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialProtectedpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialProtectedtitles.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnusedtemplates.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnwatchedpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWantedcategories.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2619,13 +2619,11 @@
26202620 * @param $oppositedm Boolean Add the direction mark opposite to your
26212621 * language, to display text properly
26222622 * @return String
 2623+ * @deprecated since 1.19; use Language::specialList() instead
26232624 */
26242625 function wfSpecialList( $page, $details, $oppositedm = true ) {
26252626 global $wgLang;
2626 - $dirmark = ( $oppositedm ? $wgLang->getDirMark( true ) : '' ) .
2627 - $wgLang->getDirMark();
2628 - $details = $details ? $dirmark . " ($details)" : '';
2629 - return $page . $details;
 2627+ return $wgLang->specialList( $page, $details, $oppositedm );
26302628 }
26312629
26322630 /**
Index: trunk/phase3/includes/specials/SpecialFewestrevisions.php
@@ -90,6 +90,6 @@
9191 array( 'action' => 'history' )
9292 ) . $redirect;
9393
94 - return wfSpecialList( $plink, $nlink );
 94+ return $this->getLang()->specialList( $plink, $nlink );
9595 }
9696 }
Index: trunk/phase3/includes/specials/SpecialCategories.php
@@ -114,9 +114,10 @@
115115 function formatRow($result) {
116116 $title = Title::makeTitle( NS_CATEGORY, $result->cat_title );
117117 $titleText = Linker::link( $title, htmlspecialchars( $title->getText() ) );
 118+ $lang = $this->getLang();
118119 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
119 - $this->getLang()->formatNum( $result->cat_pages ) );
120 - return Xml::tags('li', null, wfSpecialList( $titleText, $count ) ) . "\n";
 120+ $lang->formatNum( $result->cat_pages ) );
 121+ return Xml::tags('li', null, $lang->specialList( $titleText, $count ) ) . "\n";
121122 }
122123
123124 public function getStartForm( $from ) {
Index: trunk/phase3/includes/specials/SpecialMostcategories.php
@@ -62,6 +62,6 @@
6363
6464 $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped();
6565 $link = Linker::link( $title );
66 - return wfSpecialList( $link, $count );
 66+ return $this->getLang()->specialList( $link, $count );
6767 }
6868 }
Index: trunk/phase3/includes/specials/SpecialPopularpages.php
@@ -62,6 +62,6 @@
6363 htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
6464 );
6565 $nv = $this->msg( 'nviews' )->numParams( $result->value )->escaped();
66 - return wfSpecialList($link, $nv );
 66+ return $this->getLang()->specialList( $link, $nv );
6767 }
6868 }
Index: trunk/phase3/includes/specials/SpecialUnwatchedpages.php
@@ -83,6 +83,6 @@
8484 array( 'action' => 'watch', 'token' => $token )
8585 );
8686
87 - return wfSpecialList( $plink, $wlink );
 87+ return $this->getLang()->specialList( $plink, $wlink );
8888 }
8989 }
Index: trunk/phase3/includes/specials/SpecialProtectedtitles.php
@@ -105,7 +105,7 @@
106106
107107 wfProfileOut( __METHOD__ );
108108
109 - return '<li>' . wfSpecialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
 109+ return '<li>' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
110110 }
111111
112112 /**
Index: trunk/phase3/includes/specials/SpecialMostlinkedtemplates.php
@@ -98,7 +98,7 @@
9999 public function formatResult( $skin, $result ) {
100100 $title = Title::makeTitle( $result->namespace, $result->title );
101101
102 - return wfSpecialList(
 102+ return $this->getLang()->specialList(
103103 Linker::link( $title ),
104104 $this->makeWlhLink( $title, $result )
105105 );
Index: trunk/phase3/includes/specials/SpecialUnusedtemplates.php
@@ -61,19 +61,19 @@
6262 */
6363 function formatResult( $skin, $result ) {
6464 $title = Title::makeTitle( NS_TEMPLATE, $result->title );
65 - $pageLink = $skin->linkKnown(
 65+ $pageLink = Linker::linkKnown(
6666 $title,
6767 null,
6868 array(),
6969 array( 'redirect' => 'no' )
7070 );
71 - $wlhLink = $skin->linkKnown(
 71+ $wlhLink = Linker::linkKnown(
7272 SpecialPage::getTitleFor( 'Whatlinkshere' ),
7373 wfMsgHtml( 'unusedtemplateswlh' ),
7474 array(),
7575 array( 'target' => $title->getPrefixedText() )
7676 );
77 - return wfSpecialList( $pageLink, $wlhLink );
 77+ return $this->getLang()->specialList( $pageLink, $wlhLink );
7878 }
7979
8080 function getPageHeader() {
Index: trunk/phase3/includes/specials/SpecialWantedcategories.php
@@ -69,8 +69,9 @@
7070 array( 'broken' )
7171 );
7272
 73+ $lang = $this->getLang();
7374 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
74 - $this->getLang()->formatNum( $result->value ) );
75 - return wfSpecialList( $plink, $nlinks );
 75+ $lang->formatNum( $result->value ) );
 76+ return $lang->specialList( $plink, $nlinks );
7677 }
7778 }
Index: trunk/phase3/includes/specials/SpecialListusers.php
@@ -131,24 +131,26 @@
132132 $userPage = Title::makeTitle( NS_USER, $row->user_name );
133133 $name = Linker::link( $userPage, htmlspecialchars( $userPage->getText() ) );
134134
 135+ $lang = $this->getLang();
 136+
135137 $groups_list = self::getGroups( $row->user_id );
136138 if( count( $groups_list ) > 0 ) {
137139 $list = array();
138140 foreach( $groups_list as $group )
139141 $list[] = self::buildGroupLink( $group, $userPage->getText() );
140 - $groups = $this->getLang()->commaList( $list );
 142+ $groups = $lang->commaList( $list );
141143 } else {
142144 $groups = '';
143145 }
144146
145 - $item = wfSpecialList( $name, $groups );
 147+ $item = $lang->specialList( $name, $groups );
146148 if( $row->ipb_deleted ) {
147149 $item = "<span class=\"deleted\">$item</span>";
148150 }
149151
150152 global $wgEdititis;
151153 if ( $wgEdititis ) {
152 - $editCount = $this->getLang()->formatNum( $row->edits );
 154+ $editCount = $lang->formatNum( $row->edits );
153155 $edits = ' [' . wfMsgExt( 'usereditcount', array( 'parsemag', 'escape' ), $editCount ) . ']';
154156 } else {
155157 $edits = '';
@@ -157,8 +159,8 @@
158160 $created = '';
159161 # Some rows may be NULL
160162 if( $row->creation ) {
161 - $d = $this->getLang()->date( wfTimestamp( TS_MW, $row->creation ), true );
162 - $t = $this->getLang()->time( wfTimestamp( TS_MW, $row->creation ), true );
 163+ $d = $lang->date( wfTimestamp( TS_MW, $row->creation ), true );
 164+ $t = $lang->time( wfTimestamp( TS_MW, $row->creation ), true );
163165 $created = ' (' . wfMsg( 'usercreated', $d, $t ) . ')';
164166 $created = htmlspecialchars( $created );
165167 }
Index: trunk/phase3/includes/specials/SpecialActiveusers.php
@@ -119,6 +119,8 @@
120120 $ulinks = Linker::userLink( $row->user_id, $userName );
121121 $ulinks .= Linker::userToolLinks( $row->user_id, $userName );
122122
 123+ $lang = $this->getLang();
 124+
123125 $list = array();
124126 foreach( self::getGroups( $row->user_id ) as $group ) {
125127 if ( isset( $this->groups[$group] ) ) {
@@ -126,14 +128,14 @@
127129 }
128130 $list[] = self::buildGroupLink( $group, $userName );
129131 }
130 - $groups = $this->getLang()->commaList( $list );
 132+ $groups = $lang->commaList( $list );
131133
132 - $item = wfSpecialList( $ulinks, $groups );
 134+ $item = $lang->specialList( $ulinks, $groups );
133135 $count = wfMsgExt( 'activeusers-count',
134136 array( 'parsemag' ),
135 - $this->getLang()->formatNum( $row->recentedits ),
 137+ $lang->formatNum( $row->recentedits ),
136138 $userName,
137 - $this->getLang()->formatNum( $this->RCMaxAge )
 139+ $lang->formatNum( $this->RCMaxAge )
138140 );
139141 $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : '';
140142
Index: trunk/phase3/includes/specials/SpecialAncientpages.php
@@ -67,6 +67,6 @@
6868 $title,
6969 htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
7070 );
71 - return wfSpecialList( $link, htmlspecialchars( $d ) );
 71+ return $this->getLang()->specialList( $link, htmlspecialchars( $d ) );
7272 }
7373 }
Index: trunk/phase3/includes/specials/SpecialProtectedpages.php
@@ -142,7 +142,7 @@
143143 return Html::rawElement(
144144 'li',
145145 array(),
146 - wfSpecialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n";
 146+ $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n";
147147 }
148148
149149 /**
Index: trunk/phase3/includes/specials/SpecialMostlinked.php
@@ -99,6 +99,6 @@
100100 $link = Linker::link( $title );
101101 $wlh = $this->makeWlhLink( $title,
102102 $this->msg( 'nlinks' )->numParams( $result->value )->escaped() );
103 - return wfSpecialList( $link, $wlh );
 103+ return $this->getLang()->specialList( $link, $wlh );
104104 }
105105 }
Index: trunk/phase3/includes/specials/SpecialMostlinkedcategories.php
@@ -84,6 +84,6 @@
8585 $plink = Linker::link( $nt, htmlspecialchars( $text ) );
8686
8787 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
88 - return wfSpecialList( $plink, $nlinks );
 88+ return $this->getLang()->specialList( $plink, $nlinks );
8989 }
9090 }
Index: trunk/phase3/includes/QueryPage.php
@@ -777,7 +777,7 @@
778778 array( 'broken' )
779779 );
780780 }
781 - return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) );
 781+ return $this->getLang()->specialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) );
782782 } else {
783783 $tsafe = htmlspecialchars( $result->title );
784784 return wfMsgHtml( 'wantedpages-badtitle', $tsafe );
Index: trunk/phase3/languages/Language.php
@@ -3702,6 +3702,22 @@
37033703 }
37043704
37053705 /**
 3706+ * Make a list item, used by various special pages
 3707+ *
 3708+ * @param $page String Page link
 3709+ * @param $details String Text between brackets
 3710+ * @param $oppositedm Boolean Add the direction mark opposite to your
 3711+ * language, to display text properly
 3712+ * @return String
 3713+ */
 3714+ function specialList( $page, $details, $oppositedm = true ) {
 3715+ $dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) .
 3716+ $this->getDirMark();
 3717+ $details = $details ? $dirmark . " ($details)" : '';
 3718+ return $page . $details;
 3719+ }
 3720+
 3721+ /**
37063722 * Get the conversion rule title, if any.
37073723 *
37083724 * @return string

Follow-up revisions

RevisionCommit summaryAuthorDate
r99778Per Siebrand, fix for r99678: use word-separator and parentheses messagesialex16:01, 14 October 2011

Comments

#Comment by Siebrand (talk | contribs)   18:39, 13 October 2011

+ $details = $details ? $dirmark . " ($details)" : ;

No i18n. Should probably use the word-separator and parentheses messages here.

#Comment by IAlex (talk | contribs)   16:02, 14 October 2011

Done in r99778.

Status & tagging log