* @ingroup SpecialPage
*/
class SpecialStatistics extends SpecialPage {
- private $views, $edits, $good, $images, $total, $users,
+ private $edits, $good, $images, $total, $users,
$activeUsers = 0;
public function __construct() {
public function execute( $par ) {
global $wgMemc;
- $disableCounters = $this->getConfig()->get( 'DisableCounters' );
$miserMode = $this->getConfig()->get( 'MiserMode' );
$this->setHeaders();
$this->getOutput()->addModuleStyles( 'mediawiki.special' );
- $this->views = SiteStats::views();
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->activeUsers = SiteStats::activeUsers();
$this->hook = '';
- # Staticic - views
- $viewsStats = '';
- if ( !$disableCounters ) {
- $viewsStats = $this->getViewsStats();
- }
-
# Set active user count
if ( !$miserMode ) {
$key = wfMemcKey( 'sitestats', 'activeusers-updated' );
# Statistic - usergroups
$text .= $this->getGroupStats();
- $text .= $viewsStats;
-
- # Statistic - popular pages
- if ( !$disableCounters && !$miserMode ) {
- $text .= $this->getMostViewedPages();
- }
# Statistic - other
$extraStats = array();
- if ( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+ if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
$text .= $this->getOtherStats( $extraStats );
}
$grouppageLocalized = $msg->text();
}
$linkTarget = Title::newFromText( $grouppageLocalized );
- $grouppage = Linker::link(
- $linkTarget,
- htmlspecialchars( $groupnameLocalized )
- );
+
+ if ( $linkTarget ) {
+ $grouppage = Linker::link(
+ $linkTarget,
+ htmlspecialchars( $groupnameLocalized )
+ );
+ } else {
+ $grouppage = htmlspecialchars( $groupnameLocalized );
+ }
+
$grouplink = Linker::linkKnown(
SpecialPage::getTitleFor( 'Listusers' ),
$this->msg( 'listgrouprights-members' )->escaped(),
return $text;
}
- private function getViewsStats() {
- return Xml::openElement( 'tr' ) .
- Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-views' )->parse() ) .
- Xml::closeElement( 'tr' ) .
- $this->formatRow( $this->msg( 'statistics-views-total' )->parse(),
- $this->getLanguage()->formatNum( $this->views ),
- array( 'class' => 'mw-statistics-views-total' ), 'statistics-views-total-desc' ) .
- $this->formatRow( $this->msg( 'statistics-views-peredit' )->parse(),
- $this->getLanguage()->formatNum( sprintf( '%.2f', $this->edits ?
- $this->views / $this->edits : 0 ) ),
- array( 'class' => 'mw-statistics-views-peredit' ) );
- }
-
- private function getMostViewedPages() {
- $text = '';
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select(
- 'page',
- array(
- 'page_namespace',
- 'page_title',
- 'page_counter',
- ),
- array(
- 'page_is_redirect' => 0,
- 'page_counter > 0',
- ),
- __METHOD__,
- array(
- 'ORDER BY' => 'page_counter DESC',
- 'LIMIT' => 10,
- )
- );
-
- if ( $res->numRows() > 0 ) {
- $text .= Xml::openElement( 'tr' );
- $text .= Xml::tags(
- 'th',
- array( 'colspan' => '2' ),
- $this->msg( 'statistics-mostpopular' )->parse()
- );
- $text .= Xml::closeElement( 'tr' );
-
- foreach ( $res as $row ) {
- $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
-
- if ( $title instanceof Title ) {
- $text .= $this->formatRow( Linker::link( $title ),
- $this->getLanguage()->formatNum( $row->page_counter ) );
- }
- }
- $res->free();
- }
-
- return $text;
- }
-
/**
* Conversion of external statistics into an internal representation
* Following a ([<header-message>][<item-message>] = number) pattern