summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialStatistics.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/specials/SpecialStatistics.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/specials/SpecialStatistics.php')
-rw-r--r--includes/specials/SpecialStatistics.php100
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 )
);
}