}
public function execute( $par ) {
- global $wgOut, $wgRequest, $wgMessageCache;
+ global $wgOut, $wgRequest, $wgMessageCache, $wgMemc;
global $wgDisableCounters, $wgMiserMode;
$wgMessageCache->loadAllMessages();
$this->activeUsers = SiteStats::activeUsers();
$this->admins = SiteStats::numberingroup('sysop');
$this->numJobs = SiteStats::jobs();
+ $this->hook = '';
# Staticic - views
$viewsStats = '';
# 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
$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();
if( !$wgDisableCounters && !$wgMiserMode ) {
$text .= $this->getMostViewedPages();
}
+
+ # Statistic - other
+ $extraStats = array();
+ if( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+ $text .= $this->getOtherStats( $extraStats );
+ }
$text .= Xml::closeElement( 'table' );
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',
} 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 ) {
)
);
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 ) {
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