Add interface for adding own statistics with $wgStatsOther:
authorJan Luca Naumann <jan@users.mediawiki.org>
Thu, 6 Aug 2009 10:01:08 +0000 (10:01 +0000)
committerJan Luca Naumann <jan@users.mediawiki.org>
Thu, 6 Aug 2009 10:01:08 +0000 (10:01 +0000)
* Enable/Disable this with $wgAllowStatsOther
* Use $wgStatsOther['<name of statistic>'] = <value (number)> for adding the statistic

includes/DefaultSettings.php
includes/specials/SpecialStatistics.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 4fff02d..73e80be 100644 (file)
@@ -4156,3 +4156,15 @@ $wgCrossSiteAJAXdomainsRegex = false;
  */
 $wgMemoryLimit = "50M";
 
+/**
+ * Allow extensions to add Statistics at the end of Special:Statistics.
+ */
+$wgAllowStatsOther = true;
+
+/**
+ * Statistics which add at the end of Special:Statistics. 
+ * Use: $wgStatsOther['<name of statistic>'] = <value>; 
+ * Example: $wgStatsOther['Time since 01.01.1970'] = time();
+ */
+$wgStatsOther = array();
+
index 9b2462e..81542b3 100644 (file)
@@ -38,6 +38,7 @@ class SpecialStatistics extends SpecialPage {
                $this->activeUsers = SiteStats::activeUsers();
                $this->admins = SiteStats::numberingroup('sysop');
                $this->numJobs = SiteStats::jobs();
+               $this->hook = '';
        
                # Staticic - views
                $viewsStats = '';
@@ -75,6 +76,9 @@ class SpecialStatistics extends SpecialPage {
                if( !$wgDisableCounters && !$wgMiserMode ) {
                        $text .= $this->getMostViewedPages();
                }
+               
+               # Statistic - other
+               $text .= $this->getOtherStats();
 
                $text .= Xml::closeElement( 'table' );
 
@@ -258,6 +262,27 @@ class SpecialStatistics extends SpecialPage {
                return $text;
        }
        
+       private function getOtherStats() {
+               global $wgLang, $wgAllowStatsOther, $wgStatsOther;
+               
+               if( !$wgAllowStatsOther ) return;
+               
+               if ( count( $wgStatsOther ) < 1 ) return;
+               
+               $return = Xml::openElement( 'tr' ) .
+                       Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-hooks', array( 'parseinline' ) ) ) .
+                       Xml::closeElement( 'tr' );
+                       
+               foreach( $wgStatsOther as $name => $number ) {
+                       $name = htmlspecialchars( $name );
+                       $number = htmlspecialchars( $number );
+                       
+                       $return .= $this->formatRow( $name, $wgLang->formatNum( $number ), array( 'class' => 'mw-statistics-hook' ) );
+               }
+               
+               return $return;
+       }
+       
        /**
         * Do the action=raw output for this page. Legacy, but we support
         * it for backwards compatibility
index 5b0327a..afbb1fa 100644 (file)
@@ -2278,6 +2278,7 @@ Remember to check for other links to the templates before deleting them.',
 'statistics-header-edits'      => 'Edit statistics',
 'statistics-header-views'      => 'View statistics',
 'statistics-header-users'      => 'User statistics',
+'statistics-header-hooks'      => 'Other statistics',
 'statistics-articles'          => 'Content pages',
 'statistics-pages'             => 'Pages',
 'statistics-pages-desc'        => 'All pages in the wiki, including talk pages, redirects, etc.',
index 43e11d8..ad12a19 100644 (file)
@@ -1404,6 +1404,7 @@ $wgMessageStructure = array(
                'statistics-header-edits',
                'statistics-header-views',
                'statistics-header-users',
+               'statistics-header-hooks',
                'statistics-articles',
                'statistics-pages',
                'statistics-pages-desc',