Merge "Add IContextSource as parameter to ChangeTags::formatSummaryRow"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 12 Feb 2016 22:39:02 +0000 (22:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Feb 2016 22:39:02 +0000 (22:39 +0000)
includes/actions/HistoryAction.php
includes/changes/ChangesList.php
includes/changetags/ChangeTags.php
includes/changetags/ChangeTagsLogItem.php
includes/changetags/ChangeTagsRevisionItem.php
includes/diff/DifferenceEngine.php
includes/logging/LogEventsList.php
includes/revisiondelete/RevDelRevisionItem.php
includes/specials/SpecialContributions.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialUndelete.php

index 43260d0..33a69fb 100644 (file)
@@ -744,7 +744,11 @@ class HistoryPager extends ReverseChronologicalPager {
                }
 
                # Tags
-               list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
+               list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
+                       $row->ts_tags,
+                       'history',
+                       $this->getContext()
+               );
                $classes = array_merge( $classes, $newClasses );
                if ( $tagSummary !== '' ) {
                        $s2 .= " $tagSummary";
index 73c7548..1c7d4f0 100644 (file)
@@ -589,7 +589,8 @@ class ChangesList extends ContextSource {
 
                list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
                        $rc->mAttribs['ts_tags'],
-                       'changeslist'
+                       'changeslist',
+                       $this->getContext()
                );
                $classes = array_merge( $classes, $newClasses );
                $s .= ' ' . $tagSummary;
index a8c9f7b..305eeab 100644 (file)
@@ -35,16 +35,20 @@ class ChangeTags {
         * @param string $tags Comma-separated list of tags
         * @param string $page A label for the type of action which is being displayed,
         *   for example: 'history', 'contributions' or 'newpages'
+        * @param IContextSource|null $context
+        * @note Even though it takes null as a valid argument, an IContextSource is preferred
+        *       in a new code, as the null value is subject to change in the future
         * @return array Array with two items: (html, classes)
         *   - html: String: HTML for displaying the tags (empty string when param $tags is empty)
         *   - classes: Array of strings: CSS classes used in the generated html, one class for each tag
         */
-       public static function formatSummaryRow( $tags, $page ) {
-               global $wgLang;
-
+       public static function formatSummaryRow( $tags, $page, IContextSource $context = null ) {
                if ( !$tags ) {
                        return array( '', array() );
                }
+               if ( !$context ) {
+                       $context = RequestContext::getMain();
+               }
 
                $classes = array();
 
@@ -71,9 +75,9 @@ class ChangeTags {
                        return array( '', array() );
                }
 
-               $markers = wfMessage( 'tag-list-wrapper' )
+               $markers = $context->msg( 'tag-list-wrapper' )
                        ->numParams( count( $displayTags ) )
-                       ->rawParams( $wgLang->commaList( $displayTags ) )
+                       ->rawParams( $context->getLanguage()->commaList( $displayTags ) )
                        ->parse();
                $markers = Xml::tags( 'span', array( 'class' => 'mw-tag-markers' ), $markers );
 
index 565d159..24bded7 100644 (file)
@@ -91,7 +91,11 @@ class ChangeTagsLogItem extends RevisionItemBase {
                $attribs = array();
                $tags = $this->getTags();
                if ( $tags ) {
-                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $tags, 'edittags' );
+                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
+                               $tags,
+                               'edittags',
+                               $this->list->getContext()
+                       );
                        $content .= " $tagSummary";
                        $attribs['class'] = implode( ' ', $classes );
                }
index e90a1b4..37d6a1a 100644 (file)
@@ -49,7 +49,11 @@ class ChangeTagsRevisionItem extends RevisionItem {
                $attribs = array();
                $tags = $this->getTags();
                if ( $tags ) {
-                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $tags, 'edittags' );
+                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
+                               $tags,
+                               'edittags',
+                               $this->list->getContext()
+                       );
                        $content .= " $tagSummary";
                        $attribs['class'] = implode( ' ', $classes );
                }
index d588d51..f59fd61 100644 (file)
@@ -342,7 +342,7 @@ class DifferenceEngine extends ContextSource {
 
                        $ldel = $this->revisionDeleteLink( $this->mOldRev );
                        $oldRevisionHeader = $this->getRevisionHeader( $this->mOldRev, 'complete' );
-                       $oldChangeTags = ChangeTags::formatSummaryRow( $this->mOldTags, 'diff' );
+                       $oldChangeTags = ChangeTags::formatSummaryRow( $this->mOldTags, 'diff', $this->getContext() );
 
                        $oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' .
                                '<div id="mw-diff-otitle2">' .
@@ -403,7 +403,7 @@ class DifferenceEngine extends ContextSource {
                }
                $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) .
                        ' ' . implode( ' ', $formattedRevisionTools );
-               $newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff' );
+               $newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff', $this->getContext() );
 
                $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
                        '<div id="mw-diff-ntitle2">' . Linker::revUserTools( $this->mNewRev, !$this->unhide ) .
index dcd7a45..e93030f 100644 (file)
@@ -331,7 +331,11 @@ class LogEventsList extends ContextSource {
                $del = $this->getShowHideLinks( $row );
 
                // Any tags...
-               list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
+               list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
+                       $row->ts_tags,
+                       'logevent',
+                       $this->getContext()
+               );
                $classes = array_merge(
                        array( 'mw-logline-' . $entry->getType() ),
                        $newClasses
index e52d07c..754e68f 100644 (file)
@@ -164,7 +164,11 @@ class RevDelRevisionItem extends RevDelItem {
                $attribs = array();
                $tags = $this->getTags();
                if ( $tags ) {
-                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $tags, 'revisiondelete' );
+                       list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
+                               $tags,
+                               'revisiondelete',
+                               $this->list->getContext()
+                       );
                        $content .= " $tagSummary";
                        $attribs['class'] = implode( ' ', $classes );
                }
index 1a1b490..0e3c9aa 100644 (file)
@@ -1128,7 +1128,8 @@ class ContribsPager extends ReverseChronologicalPager {
                        # Tags, if any.
                        list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
                                $row->ts_tags,
-                               'contributions'
+                               'contributions',
+                               $this->getContext()
                        );
                        $classes = array_merge( $classes, $newClasses );
                        $ret .= " $tagSummary";
index 5d3700d..e24764a 100644 (file)
@@ -359,7 +359,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                if ( isset( $result->ts_tags ) ) {
                        list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow(
                                $result->ts_tags,
-                               'newpages'
+                               'newpages',
+                               $this->getContext()
                        );
                        $classes = array_merge( $classes, $newClasses );
                } else {
index 5e08e51..f488d3c 100644 (file)
@@ -1173,7 +1173,7 @@ class SpecialUndelete extends SpecialPage {
                        array( 'ts_rev_id' => $rev->getId() ),
                        __METHOD__
                );
-               $tagSummary = ChangeTags::formatSummaryRow( $tags, 'deleteddiff' );
+               $tagSummary = ChangeTags::formatSummaryRow( $tags, 'deleteddiff', $this->getContext() );
 
                // FIXME This is reimplementing DifferenceEngine#getRevisionHeader
                // and partially #showDiffPage, but worse
@@ -1505,7 +1505,11 @@ class SpecialUndelete extends SpecialPage {
 
                // Tags
                $attribs = array();
-               list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'deletedhistory' );
+               list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
+                       $row->ts_tags,
+                       'deletedhistory',
+                       $this->getContext()
+               );
                if ( $classes ) {
                        $attribs['class'] = implode( ' ', $classes );
                }