Merge "SpecialStatsAddExtra: Format column label with msg"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 23 May 2015 13:23:52 +0000 (13:23 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 23 May 2015 13:23:52 +0000 (13:23 +0000)
docs/hooks.txt
includes/specials/SpecialStatistics.php

index f03e38d..a14199f 100644 (file)
@@ -2787,7 +2787,13 @@ $term: string of search term
 
 '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.
index 3e3a2ab..652ea82 100644 (file)
@@ -78,7 +78,7 @@ class SpecialStatistics extends SpecialPage {
 
                # Statistic - other
                $extraStats = array();
-               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats, $this->getContext() ) ) ) {
                        $text .= $this->getOtherStats( $extraStats );
                }
 
@@ -262,12 +262,17 @@ class SpecialStatistics extends SpecialPage {
 
                                // 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 )
                                        );
                                }