jenkins-bot has submitted this change and it was merged.

Change subject: SpecialStatsAddExtra: Format column label with msg
......................................................................


SpecialStatsAddExtra: Format column label with msg

This allows the user of the SpecialStatsAddExtra hook to provide
formatting for the row label using an i18n message key.  If given, the
message is given the row key as a parameter.  To maintain backward
compatibility, the key is used as-is as was done previously if a message
key is not provided.

Bug: T97623
Change-Id: I43c522b24372e115ed78adf69848bf50cbab8295
---
M docs/hooks.txt
M includes/specials/SpecialStatistics.php
2 files changed, 16 insertions(+), 5 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 6f59b2d..d15f66d 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -2775,7 +2775,13 @@
 
 'SpecialStatsAddExtra': Add extra statistic at the end of Special:Statistics.
 &$extraStats: Array to save the new stats
-  ( $extraStats['<name of statistic>'] => <value>; )
+  ( $extraStats['<name of statistic>'] => <value>;
+    <value> can be an array with the keys "name" and "number":
+    "name" is the HTML to be displayed in the name column
+    "number" is the number to be displayed.
+    or, <value> can be the number to be displayed and <name> is the
+    message key to use in the name column,
+$context: IContextSource object
 
 'SpecialUploadComplete': Called after successfully uploading a file from
 Special:Upload.
diff --git a/includes/specials/SpecialStatistics.php 
b/includes/specials/SpecialStatistics.php
index 0acbf95..9d6b341 100644
--- a/includes/specials/SpecialStatistics.php
+++ b/includes/specials/SpecialStatistics.php
@@ -78,7 +78,7 @@
 
                # Statistic - other
                $extraStats = array();
-               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats ) 
) ) {
+               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats, 
$this->getContext() ) ) ) {
                        $text .= $this->getOtherStats( $extraStats );
                }
 
@@ -256,12 +256,17 @@
 
                                // Collect all items that belong to the same 
header
                                foreach ( $items as $key => $value ) {
-                                       $name = $this->msg( $key )->parse();
-                                       $number = htmlspecialchars( $value );
+                                       if ( is_array( $value ) ) {
+                                               $name = $value['name'];
+                                               $number = $value['number'];
+                                       } else {
+                                               $name = $this->msg( $key 
)->parse();
+                                               $number = $value;
+                                       }
 
                                        $return .= $this->formatRow(
                                                $name,
-                                               
$this->getLanguage()->formatNum( $number ),
+                                               
$this->getLanguage()->formatNum( htmlspecialchars( $number ) ),
                                                array( 'class' => 
'mw-statistics-hook', 'id' => 'mw-' . $key )
                                        );
                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/207722
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I43c522b24372e115ed78adf69848bf50cbab8295
Gerrit-PatchSet: 13
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to