diff options
Diffstat (limited to 'includes/specials/SpecialStatistics.php')
-rw-r--r-- | includes/specials/SpecialStatistics.php | 100 |
1 files changed, 20 insertions, 80 deletions
diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index f0e360e8..c35de241 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -28,7 +28,7 @@ * @ingroup SpecialPage */ class SpecialStatistics extends SpecialPage { - private $views, $edits, $good, $images, $total, $users, + private $edits, $good, $images, $total, $users, $activeUsers = 0; public function __construct() { @@ -38,13 +38,11 @@ class SpecialStatistics extends SpecialPage { 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(); @@ -53,12 +51,6 @@ class SpecialStatistics extends SpecialPage { $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' ); @@ -83,16 +75,10 @@ class SpecialStatistics extends SpecialPage { # 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, $this->getContext() ) ) ) { $text .= $this->getOtherStats( $extraStats ); } @@ -213,10 +199,16 @@ class SpecialStatistics extends SpecialPage { $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(), @@ -237,63 +229,6 @@ class SpecialStatistics extends SpecialPage { 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 @@ -315,12 +250,17 @@ class SpecialStatistics extends SpecialPage { // Collect all items that belong to the same header foreach ( $items as $key => $value ) { - $name = $this->msg( $key )->parse(); - $number = htmlspecialchars( $value ); + if ( is_array( $value ) ) { + $name = $value['name']; + $number = $value['number']; + } else { + $name = $this->msg( $key )->parse(); + $number = $value; + } $return .= $this->formatRow( $name, - $this->getLanguage()->formatNum( $number ), + $this->getLanguage()->formatNum( htmlspecialchars( $number ) ), array( 'class' => 'mw-statistics-hook', 'id' => 'mw-' . $key ) ); } |