summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialStatistics.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
commit222b01f5169f1c7e69762e0e8904c24f78f71882 (patch)
tree8e932e12546bb991357ec48eb1638d1770be7a35 /includes/specials/SpecialStatistics.php
parent00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff)
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/specials/SpecialStatistics.php')
-rw-r--r--includes/specials/SpecialStatistics.php70
1 files changed, 59 insertions, 11 deletions
diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php
index 109c5c30..2e785b8b 100644
--- a/includes/specials/SpecialStatistics.php
+++ b/includes/specials/SpecialStatistics.php
@@ -23,7 +23,7 @@ class SpecialStatistics extends SpecialPage {
}
public function execute( $par ) {
- global $wgOut, $wgRequest, $wgMessageCache;
+ global $wgOut, $wgRequest, $wgMessageCache, $wgMemc;
global $wgDisableCounters, $wgMiserMode;
$wgMessageCache->loadAllMessages();
@@ -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 = '';
@@ -47,8 +48,13 @@ class SpecialStatistics extends SpecialPage {
# Set active user count
if( !$wgMiserMode ) {
- $dbw = wfGetDB( DB_MASTER );
- SiteStatsUpdate::cacheUpdate( $dbw );
+ $key = wfMemcKey( 'sitestats', 'activeusers-updated' );
+ // Re-calculate the count if the last tally is old...
+ if( !$wgMemc->get($key) ) {
+ $dbw = wfGetDB( DB_MASTER );
+ SiteStatsUpdate::cacheUpdate( $dbw );
+ $wgMemc->set( $key, '1', 24*3600 ); // don't update for 1 day
+ }
}
# Do raw output
@@ -56,10 +62,10 @@ class SpecialStatistics extends SpecialPage {
$this->doRawOutput();
}
- $text = Xml::openElement( 'table', array( 'class' => 'mw-statistics-table' ) );
+ $text = Xml::openElement( 'table', array( 'class' => 'wikitable mw-statistics-table' ) );
# Statistic - pages
- $text .= $this->getPageStats();
+ $text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
@@ -75,6 +81,12 @@ class SpecialStatistics extends SpecialPage {
if( !$wgDisableCounters && !$wgMiserMode ) {
$text .= $this->getMostViewedPages();
}
+
+ # Statistic - other
+ $extraStats = array();
+ if( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+ $text .= $this->getOtherStats( $extraStats );
+ }
$text .= Xml::closeElement( 'table' );
@@ -149,14 +161,22 @@ class SpecialStatistics extends SpecialPage {
array( 'class' => 'mw-statistics-jobqueue' ) );
}
private function getUserStats() {
- global $wgLang, $wgRCMaxAge;
+ global $wgLang, $wgUser, $wgRCMaxAge;
+ $sk = $wgUser->getSkin();
return Xml::openElement( 'tr' ) .
Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-users', array( 'parseinline' ) ) ) .
Xml::closeElement( 'tr' ) .
$this->formatRow( wfMsgExt( 'statistics-users', array( 'parseinline' ) ),
$wgLang->formatNum( $this->users ),
array( 'class' => 'mw-statistics-users' ) ) .
- $this->formatRow( wfMsgExt( 'statistics-users-active', array( 'parseinline' ) ),
+ $this->formatRow( wfMsgExt( 'statistics-users-active', array( 'parseinline' ) ) . ' ' .
+ $sk->link(
+ SpecialPage::getTitleFor( 'Activeusers' ),
+ wfMsgHtml( 'listgrouprights-members' ),
+ array(),
+ array(),
+ 'known'
+ ),
$wgLang->formatNum( $this->activeUsers ),
array( 'class' => 'mw-statistics-users-active' ),
'statistics-users-active-desc',
@@ -184,13 +204,19 @@ class SpecialStatistics extends SpecialPage {
} else {
$grouppageLocalized = $msg;
}
- $grouppage = $sk->makeLink( $grouppageLocalized, htmlspecialchars( $groupnameLocalized ) );
- $grouplink = $sk->link( SpecialPage::getTitleFor( 'Listusers' ),
+ $linkTarget = Title::newFromText( $grouppageLocalized );
+ $grouppage = $sk->link(
+ $linkTarget,
+ htmlspecialchars( $groupnameLocalized )
+ );
+ $grouplink = $sk->link(
+ SpecialPage::getTitleFor( 'Listusers' ),
wfMsgHtml( 'listgrouprights-members' ),
array(),
array( 'group' => $group ),
- 'known' );
- # Add a class when a usergroup contains no members to allow hiding these rows
+ 'known'
+ );
+ # Add a class when a usergroup contains no members to allow hiding these rows
$classZero = '';
$countUsers = SiteStats::numberingroup( $groupname );
if( $countUsers == 0 ) {
@@ -238,7 +264,9 @@ class SpecialStatistics extends SpecialPage {
)
);
if( $res->numRows() > 0 ) {
+ $text .= Xml::openElement( 'tr' );
$text .= Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-mostpopular', array( 'parseinline' ) ) );
+ $text .= Xml::closeElement( 'tr' );
while( $row = $res->fetchObject() ) {
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
if( $title instanceof Title ) {
@@ -252,6 +280,26 @@ class SpecialStatistics extends SpecialPage {
return $text;
}
+ private function getOtherStats( $stats ) {
+ global $wgLang;
+
+ if ( !count( $stats ) )
+ return '';
+
+ $return = Xml::openElement( 'tr' ) .
+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-hooks', array( 'parseinline' ) ) ) .
+ Xml::closeElement( 'tr' );
+
+ foreach( $stats 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