From 96afd9a1018a16c36e236e645c56f2c31ff740a8 Mon Sep 17 00:00:00 2001 From: Jan Luca Naumann Date: Thu, 6 Aug 2009 10:01:08 +0000 Subject: [PATCH] Add interface for adding own statistics with $wgStatsOther: * Enable/Disable this with $wgAllowStatsOther * Use $wgStatsOther[''] = for adding the statistic --- includes/DefaultSettings.php | 12 ++++++++++++ includes/specials/SpecialStatistics.php | 25 +++++++++++++++++++++++++ languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 39 insertions(+) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4fff02d4ca..73e80be62f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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[''] = ; + * Example: $wgStatsOther['Time since 01.01.1970'] = time(); + */ +$wgStatsOther = array(); + diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index 9b2462e420..81542b3e83 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5b0327ab3d..afbb1fa5ac 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 43e11d88e0..ad12a19cdc 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', -- 2.20.1