r54516 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54515‎ | r54516 | r54517 >
Date:13:40, 6 August 2009
Author:jan
Status:resolved (Comments)
Tags:
Comment:
(r54511) Replace global array with hook
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialStatistics.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1394,6 +1394,10 @@
13951395 no matches
13961396 $term: string of search term
13971397
 1398+'SpecialStatsAddExtra': add extra statistic at the end of Special:Statistics
 1399+&$extraStats: Array to save the new stats
 1400+ ( $extraStats['<name of statistic>'] => <value>; )
 1401+
13981402 'SpecialUploadComplete': Called after successfully uploading a file from
13991403 Special:Upload
14001404 $form: The UploadForm object
Index: trunk/phase3/includes/specials/SpecialStatistics.php
@@ -78,7 +78,10 @@
7979 }
8080
8181 # Statistic - other
82 - $text .= $this->getOtherStats();
 82+ $extraStats = array();
 83+ if( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
 84+ $text .= $this->getOtherStats( $extraStats );
 85+ }
8386
8487 $text .= Xml::closeElement( 'table' );
8588
@@ -262,18 +265,14 @@
263266 return $text;
264267 }
265268
266 - private function getOtherStats() {
 269+ private function getOtherStats( $stats ) {
267270 global $wgLang, $wgAllowStatsOther, $wgStatsOther;
268271
269 - if( !$wgAllowStatsOther ) return;
270 -
271 - if ( count( $wgStatsOther ) < 1 ) return;
272 -
273272 $return = Xml::openElement( 'tr' ) .
274273 Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-hooks', array( 'parseinline' ) ) ) .
275274 Xml::closeElement( 'tr' );
276275
277 - foreach( $wgStatsOther as $name => $number ) {
 276+ foreach( $stats as $name => $number ) {
278277 $name = htmlspecialchars( $name );
279278 $number = htmlspecialchars( $number );
280279

Follow-up revisions

RevisionCommit summaryAuthorDate
r54517(fix for r54516) Update RELEASE-NOTESjan13:46, 6 August 2009
r54545Followup r54516, remove globals entirely.demon22:35, 6 August 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54511Add interface for adding own statistics with $wgStatsOther:...jan10:01, 6 August 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   18:23, 14 October 2009

per bug 21113 this is showing the extra header even when there's nothing additional to show.

#Comment by Jan Luca (talk | contribs)   09:10, 16 October 2009

Fixed in r57723.

Status & tagging log