*/
/**
- * Show the special page
- *
- * @param mixed $par (not used)
+ * Some statistics about the wiki
*/
class SpecialStatistics extends SpecialPage {
}
public function execute( $par ) {
- global $wgOut, $wgRequest, $wgMessageCache;
+ global $wgOut, $wgRequest, $wgMessageCache, $wgMemc;
global $wgDisableCounters, $wgMiserMode;
- $wgMessageCache->loadAllMessages();
$this->setHeaders();
$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' );
/**
* Format a row
- * @param string $text description of the row
- * @param float $number a number
- * @param array $trExtraParams
- * @param string $descMsg
- * @param string $descMsgParam
+ * @param $text String: description of the row
+ * @param $number Float: a statistical number
+ * @param $trExtraParams Array: params to table row, see Html::elememt
+ * @param $descMsg String: message key
+ * @param $descMsgParam Array: message params
* @return string table row in HTML format
*/
private function formatRow( $text, $number, $trExtraParams = array(), $descMsg = '', $descMsgParam = '' ) {
$descriptionText );
}
}
- return Xml::openElement( 'tr', $trExtraParams ) .
- Xml::openElement( 'td' ) . $text . Xml::closeElement( 'td' ) .
- Xml::openElement( 'td', array( 'class' => 'mw-statistics-numbers' ) ) . $number . Xml::closeElement( 'td' ) .
- Xml::closeElement( 'tr' );
+ return
+ Html::rawElement( 'tr', $trExtraParams,
+ Html::rawElement( 'td', array(), $text ) .
+ Html::rawElement( 'td', array( 'class' => 'mw-statistics-numbers' ), $number )
+ );
}
/**
array( 'class' => 'mw-statistics-edits' ) ) .
$this->formatRow( wfMsgExt( 'statistics-edits-average', array( 'parseinline' ) ),
$wgLang->formatNum( sprintf( '%.2f', $this->total ? $this->edits / $this->total : 0 ) ),
- array( 'class' => 'mw-statistics-edits-average' ) ) .
- $this->formatRow( wfMsgExt( 'statistics-jobqueue', array( 'parseinline' ) ),
- $wgLang->formatNum( $this->numJobs ),
- array( 'class' => 'mw-statistics-jobqueue' ) );
+ array( 'class' => 'mw-statistics-edits-average' ) );
}
+
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',
)
);
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