From 4148b2512b02eb8d4dd8f5427ce082fb4b0194d2 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 13 Oct 2011 11:46:21 +0000 Subject: [PATCH] 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. --- includes/GlobalFunctions.php | 6 ++---- includes/QueryPage.php | 2 +- includes/specials/SpecialActiveusers.php | 10 ++++++---- includes/specials/SpecialAncientpages.php | 2 +- includes/specials/SpecialCategories.php | 5 +++-- includes/specials/SpecialFewestrevisions.php | 2 +- includes/specials/SpecialListusers.php | 12 +++++++----- includes/specials/SpecialMostcategories.php | 2 +- includes/specials/SpecialMostlinked.php | 2 +- .../specials/SpecialMostlinkedcategories.php | 2 +- includes/specials/SpecialMostlinkedtemplates.php | 2 +- includes/specials/SpecialPopularpages.php | 2 +- includes/specials/SpecialProtectedpages.php | 2 +- includes/specials/SpecialProtectedtitles.php | 2 +- includes/specials/SpecialUnusedtemplates.php | 6 +++--- includes/specials/SpecialUnwatchedpages.php | 2 +- includes/specials/SpecialWantedcategories.php | 5 +++-- languages/Language.php | 16 ++++++++++++++++ 18 files changed, 51 insertions(+), 31 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index ade1298009..d0e381a40d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2619,13 +2619,11 @@ function in_string( $needle, $str, $insensitive = false ) { * @param $oppositedm Boolean Add the direction mark opposite to your * language, to display text properly * @return String + * @deprecated since 1.19; use Language::specialList() instead */ function wfSpecialList( $page, $details, $oppositedm = true ) { global $wgLang; - $dirmark = ( $oppositedm ? $wgLang->getDirMark( true ) : '' ) . - $wgLang->getDirMark(); - $details = $details ? $dirmark . " ($details)" : ''; - return $page . $details; + return $wgLang->specialList( $page, $details, $oppositedm ); } /** diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 5691881f1b..c3c96dc23c 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -777,7 +777,7 @@ abstract class WantedQueryPage extends QueryPage { array( 'broken' ) ); } - return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) ); + return $this->getLang()->specialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) ); } else { $tsafe = htmlspecialchars( $result->title ); return wfMsgHtml( 'wantedpages-badtitle', $tsafe ); diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 7e337306b5..17f4a8b83d 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -119,6 +119,8 @@ class ActiveUsersPager extends UsersPager { $ulinks = Linker::userLink( $row->user_id, $userName ); $ulinks .= Linker::userToolLinks( $row->user_id, $userName ); + $lang = $this->getLang(); + $list = array(); foreach( self::getGroups( $row->user_id ) as $group ) { if ( isset( $this->groups[$group] ) ) { @@ -126,14 +128,14 @@ class ActiveUsersPager extends UsersPager { } $list[] = self::buildGroupLink( $group, $userName ); } - $groups = $this->getLang()->commaList( $list ); + $groups = $lang->commaList( $list ); - $item = wfSpecialList( $ulinks, $groups ); + $item = $lang->specialList( $ulinks, $groups ); $count = wfMsgExt( 'activeusers-count', array( 'parsemag' ), - $this->getLang()->formatNum( $row->recentedits ), + $lang->formatNum( $row->recentedits ), $userName, - $this->getLang()->formatNum( $this->RCMaxAge ) + $lang->formatNum( $this->RCMaxAge ) ); $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : ''; diff --git a/includes/specials/SpecialAncientpages.php b/includes/specials/SpecialAncientpages.php index 680a948205..7f037cd59b 100644 --- a/includes/specials/SpecialAncientpages.php +++ b/includes/specials/SpecialAncientpages.php @@ -67,6 +67,6 @@ class AncientPagesPage extends QueryPage { $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); - return wfSpecialList( $link, htmlspecialchars( $d ) ); + return $this->getLang()->specialList( $link, htmlspecialchars( $d ) ); } } diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 896f8e7721..16ca322565 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -114,9 +114,10 @@ class CategoryPager extends AlphabeticPager { function formatRow($result) { $title = Title::makeTitle( NS_CATEGORY, $result->cat_title ); $titleText = Linker::link( $title, htmlspecialchars( $title->getText() ) ); + $lang = $this->getLang(); $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), - $this->getLang()->formatNum( $result->cat_pages ) ); - return Xml::tags('li', null, wfSpecialList( $titleText, $count ) ) . "\n"; + $lang->formatNum( $result->cat_pages ) ); + return Xml::tags('li', null, $lang->specialList( $titleText, $count ) ) . "\n"; } public function getStartForm( $from ) { diff --git a/includes/specials/SpecialFewestrevisions.php b/includes/specials/SpecialFewestrevisions.php index bbeceae7a0..a59f78f94e 100644 --- a/includes/specials/SpecialFewestrevisions.php +++ b/includes/specials/SpecialFewestrevisions.php @@ -90,6 +90,6 @@ class FewestrevisionsPage extends QueryPage { array( 'action' => 'history' ) ) . $redirect; - return wfSpecialList( $plink, $nlink ); + return $this->getLang()->specialList( $plink, $nlink ); } } diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index 672ac5bce8..eb3a006c33 100644 --- a/includes/specials/SpecialListusers.php +++ b/includes/specials/SpecialListusers.php @@ -131,24 +131,26 @@ class UsersPager extends AlphabeticPager { $userPage = Title::makeTitle( NS_USER, $row->user_name ); $name = Linker::link( $userPage, htmlspecialchars( $userPage->getText() ) ); + $lang = $this->getLang(); + $groups_list = self::getGroups( $row->user_id ); if( count( $groups_list ) > 0 ) { $list = array(); foreach( $groups_list as $group ) $list[] = self::buildGroupLink( $group, $userPage->getText() ); - $groups = $this->getLang()->commaList( $list ); + $groups = $lang->commaList( $list ); } else { $groups = ''; } - $item = wfSpecialList( $name, $groups ); + $item = $lang->specialList( $name, $groups ); if( $row->ipb_deleted ) { $item = "$item"; } global $wgEdititis; if ( $wgEdititis ) { - $editCount = $this->getLang()->formatNum( $row->edits ); + $editCount = $lang->formatNum( $row->edits ); $edits = ' [' . wfMsgExt( 'usereditcount', array( 'parsemag', 'escape' ), $editCount ) . ']'; } else { $edits = ''; @@ -157,8 +159,8 @@ class UsersPager extends AlphabeticPager { $created = ''; # Some rows may be NULL if( $row->creation ) { - $d = $this->getLang()->date( wfTimestamp( TS_MW, $row->creation ), true ); - $t = $this->getLang()->time( wfTimestamp( TS_MW, $row->creation ), true ); + $d = $lang->date( wfTimestamp( TS_MW, $row->creation ), true ); + $t = $lang->time( wfTimestamp( TS_MW, $row->creation ), true ); $created = ' (' . wfMsg( 'usercreated', $d, $t ) . ')'; $created = htmlspecialchars( $created ); } diff --git a/includes/specials/SpecialMostcategories.php b/includes/specials/SpecialMostcategories.php index cc8e492540..f75b5212b0 100644 --- a/includes/specials/SpecialMostcategories.php +++ b/includes/specials/SpecialMostcategories.php @@ -62,6 +62,6 @@ class MostcategoriesPage extends QueryPage { $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped(); $link = Linker::link( $title ); - return wfSpecialList( $link, $count ); + return $this->getLang()->specialList( $link, $count ); } } diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index 6707d6a9e1..390049fd8f 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -99,6 +99,6 @@ class MostlinkedPage extends QueryPage { $link = Linker::link( $title ); $wlh = $this->makeWlhLink( $title, $this->msg( 'nlinks' )->numParams( $result->value )->escaped() ); - return wfSpecialList( $link, $wlh ); + return $this->getLang()->specialList( $link, $wlh ); } } diff --git a/includes/specials/SpecialMostlinkedcategories.php b/includes/specials/SpecialMostlinkedcategories.php index 4cc7c0447b..6b36d5a496 100644 --- a/includes/specials/SpecialMostlinkedcategories.php +++ b/includes/specials/SpecialMostlinkedcategories.php @@ -84,6 +84,6 @@ class MostlinkedCategoriesPage extends QueryPage { $plink = Linker::link( $nt, htmlspecialchars( $text ) ); $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); - return wfSpecialList( $plink, $nlinks ); + return $this->getLang()->specialList( $plink, $nlinks ); } } diff --git a/includes/specials/SpecialMostlinkedtemplates.php b/includes/specials/SpecialMostlinkedtemplates.php index 239a2d7f44..ab9e152739 100644 --- a/includes/specials/SpecialMostlinkedtemplates.php +++ b/includes/specials/SpecialMostlinkedtemplates.php @@ -98,7 +98,7 @@ class MostlinkedTemplatesPage extends QueryPage { public function formatResult( $skin, $result ) { $title = Title::makeTitle( $result->namespace, $result->title ); - return wfSpecialList( + return $this->getLang()->specialList( Linker::link( $title ), $this->makeWlhLink( $title, $result ) ); diff --git a/includes/specials/SpecialPopularpages.php b/includes/specials/SpecialPopularpages.php index 74e6268aaf..63a3267b55 100644 --- a/includes/specials/SpecialPopularpages.php +++ b/includes/specials/SpecialPopularpages.php @@ -62,6 +62,6 @@ class PopularPagesPage extends QueryPage { htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); $nv = $this->msg( 'nviews' )->numParams( $result->value )->escaped(); - return wfSpecialList($link, $nv ); + return $this->getLang()->specialList( $link, $nv ); } } diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index fd6026ae50..7c96faa902 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -142,7 +142,7 @@ class SpecialProtectedpages extends SpecialPage { return Html::rawElement( 'li', array(), - wfSpecialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; + $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; } /** diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index 0b77755585..59792dd339 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -105,7 +105,7 @@ class SpecialProtectedtitles extends SpecialPage { wfProfileOut( __METHOD__ ); - return '
  • ' . wfSpecialList( $link, implode( $description_items, ', ' ) ) . "
  • \n"; + return '
  • ' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "
  • \n"; } /** diff --git a/includes/specials/SpecialUnusedtemplates.php b/includes/specials/SpecialUnusedtemplates.php index da501605d6..de6f6c7385 100644 --- a/includes/specials/SpecialUnusedtemplates.php +++ b/includes/specials/SpecialUnusedtemplates.php @@ -61,19 +61,19 @@ class UnusedtemplatesPage extends QueryPage { */ function formatResult( $skin, $result ) { $title = Title::makeTitle( NS_TEMPLATE, $result->title ); - $pageLink = $skin->linkKnown( + $pageLink = Linker::linkKnown( $title, null, array(), array( 'redirect' => 'no' ) ); - $wlhLink = $skin->linkKnown( + $wlhLink = Linker::linkKnown( SpecialPage::getTitleFor( 'Whatlinkshere' ), wfMsgHtml( 'unusedtemplateswlh' ), array(), array( 'target' => $title->getPrefixedText() ) ); - return wfSpecialList( $pageLink, $wlhLink ); + return $this->getLang()->specialList( $pageLink, $wlhLink ); } function getPageHeader() { diff --git a/includes/specials/SpecialUnwatchedpages.php b/includes/specials/SpecialUnwatchedpages.php index 0f11140b2d..9754b750e7 100644 --- a/includes/specials/SpecialUnwatchedpages.php +++ b/includes/specials/SpecialUnwatchedpages.php @@ -83,6 +83,6 @@ class UnwatchedpagesPage extends QueryPage { array( 'action' => 'watch', 'token' => $token ) ); - return wfSpecialList( $plink, $wlink ); + return $this->getLang()->specialList( $plink, $wlink ); } } diff --git a/includes/specials/SpecialWantedcategories.php b/includes/specials/SpecialWantedcategories.php index 9a17adc9dd..212bd5b3f3 100644 --- a/includes/specials/SpecialWantedcategories.php +++ b/includes/specials/SpecialWantedcategories.php @@ -69,8 +69,9 @@ class WantedCategoriesPage extends WantedQueryPage { array( 'broken' ) ); + $lang = $this->getLang(); $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), - $this->getLang()->formatNum( $result->value ) ); - return wfSpecialList( $plink, $nlinks ); + $lang->formatNum( $result->value ) ); + return $lang->specialList( $plink, $nlinks ); } } diff --git a/languages/Language.php b/languages/Language.php index 5833f929f0..1e69eda488 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -3701,6 +3701,22 @@ class Language { return str_replace( '$1', $this->formatNum( $size ), $text ); } + /** + * Make a list item, used by various special pages + * + * @param $page String Page link + * @param $details String Text between brackets + * @param $oppositedm Boolean Add the direction mark opposite to your + * language, to display text properly + * @return String + */ + function specialList( $page, $details, $oppositedm = true ) { + $dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) . + $this->getDirMark(); + $details = $details ? $dirmark . " ($details)" : ''; + return $page . $details; + } + /** * Get the conversion rule title, if any. * -- 2.20.1