Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / specials / SpecialStatistics.php
index 8de6f8b..c352927 100644 (file)
@@ -36,8 +36,6 @@ class SpecialStatistics extends SpecialPage {
        }
 
        public function execute( $par ) {
-               global $wgMemc;
-
                $miserMode = $this->getConfig()->get( 'MiserMode' );
 
                $this->setHeaders();
@@ -51,18 +49,7 @@ class SpecialStatistics extends SpecialPage {
                $this->activeUsers = SiteStats::activeUsers();
                $this->hook = '';
 
-               # Set active user count
-               if ( !$miserMode ) {
-                       $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
-                       }
-               }
-
-               $text = Xml::openElement( 'table', array( 'class' => 'wikitable mw-statistics-table' ) );
+               $text = Xml::openElement( 'table', [ 'class' => 'wikitable mw-statistics-table' ] );
 
                # Statistic - pages
                $text .= $this->getPageStats();
@@ -77,8 +64,8 @@ class SpecialStatistics extends SpecialPage {
                $text .= $this->getGroupStats();
 
                # Statistic - other
-               $extraStats = array();
-               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats, $this->getContext() ) ) ) {
+               $extraStats = [];
+               if ( Hooks::run( 'SpecialStatsAddExtra', [ &$extraStats, $this->getContext() ] ) ) {
                        $text .= $this->getOtherStats( $extraStats );
                }
 
@@ -102,7 +89,7 @@ class SpecialStatistics extends SpecialPage {
         * @param array|string $descMsgParam Message parameters
         * @return string Table row in HTML format
         */
-       private function formatRow( $text, $number, $trExtraParams = array(),
+       private function formatRow( $text, $number, $trExtraParams = [],
                $descMsg = '', $descMsgParam = ''
        ) {
                if ( $descMsg ) {
@@ -110,14 +97,14 @@ class SpecialStatistics extends SpecialPage {
                        if ( !$msg->isDisabled() ) {
                                $descriptionHtml = $this->msg( 'parentheses' )->rawParams( $msg->parse() )
                                        ->escaped();
-                               $text .= "<br />" . Html::rawElement( 'small', array( 'class' => 'mw-statistic-desc' ),
+                               $text .= "<br />" . Html::rawElement( 'small', [ 'class' => 'mw-statistic-desc' ],
                                        " $descriptionHtml" );
                        }
                }
 
                return Html::rawElement( 'tr', $trExtraParams,
-                       Html::rawElement( 'td', array(), $text ) .
-                       Html::rawElement( 'td', array( 'class' => 'mw-statistics-numbers' ), $number )
+                       Html::rawElement( 'td', [], $text ) .
+                       Html::rawElement( 'td', [ 'class' => 'mw-statistics-numbers' ], $number )
                );
        }
 
@@ -127,18 +114,20 @@ class SpecialStatistics extends SpecialPage {
         * @return string
         */
        private function getPageStats() {
+               $specialAllPagesTitle = SpecialPage::getTitleFor( 'Allpages' );
                $pageStatsHtml = Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-pages' )
+                       Xml::tags( 'th', [ 'colspan' => '2' ], $this->msg( 'statistics-header-pages' )
                                ->parse() ) .
                        Xml::closeElement( 'tr' ) .
-                               $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'Allpages' ),
-                                       $this->msg( 'statistics-articles' )->parse() ),
+                               $this->formatRow( Linker::linkKnown( $specialAllPagesTitle,
+                                       $this->msg( 'statistics-articles' )->parse(), [], [ 'hideredirects' => 1 ] ),
                                        $this->getLanguage()->formatNum( $this->good ),
-                                       array( 'class' => 'mw-statistics-articles' ),
+                                       [ 'class' => 'mw-statistics-articles' ],
                                        'statistics-articles-desc' ) .
-                               $this->formatRow( $this->msg( 'statistics-pages' )->parse(),
+                               $this->formatRow( Linker::linkKnown( $specialAllPagesTitle,
+                                       $this->msg( 'statistics-pages' )->parse() ),
                                        $this->getLanguage()->formatNum( $this->total ),
-                                       array( 'class' => 'mw-statistics-pages' ),
+                                       [ 'class' => 'mw-statistics-pages' ],
                                        'statistics-pages-desc' );
 
                // Show the image row only, when there are files or upload is possible
@@ -147,7 +136,7 @@ class SpecialStatistics extends SpecialPage {
                                Linker::linkKnown( SpecialPage::getTitleFor( 'MediaStatistics' ),
                                $this->msg( 'statistics-files' )->parse() ),
                                $this->getLanguage()->formatNum( $this->images ),
-                               array( 'class' => 'mw-statistics-files' ) );
+                               [ 'class' => 'mw-statistics-files' ] );
                }
 
                return $pageStatsHtml;
@@ -155,28 +144,28 @@ class SpecialStatistics extends SpecialPage {
 
        private function getEditStats() {
                return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ),
+                       Xml::tags( 'th', [ 'colspan' => '2' ],
                                $this->msg( 'statistics-header-edits' )->parse() ) .
                        Xml::closeElement( 'tr' ) .
                        $this->formatRow( $this->msg( 'statistics-edits' )->parse(),
                                $this->getLanguage()->formatNum( $this->edits ),
-                               array( 'class' => 'mw-statistics-edits' )
+                               [ 'class' => 'mw-statistics-edits' ]
                        ) .
                        $this->formatRow( $this->msg( 'statistics-edits-average' )->parse(),
                                $this->getLanguage()
                                        ->formatNum( sprintf( '%.2f', $this->total ? $this->edits / $this->total : 0 ) ),
-                               array( 'class' => 'mw-statistics-edits-average' )
+                               [ 'class' => 'mw-statistics-edits-average' ]
                        );
        }
 
        private function getUserStats() {
                return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ),
+                       Xml::tags( 'th', [ 'colspan' => '2' ],
                                $this->msg( 'statistics-header-users' )->parse() ) .
                        Xml::closeElement( 'tr' ) .
                        $this->formatRow( $this->msg( 'statistics-users' )->parse(),
                                $this->getLanguage()->formatNum( $this->users ),
-                               array( 'class' => 'mw-statistics-users' )
+                               [ 'class' => 'mw-statistics-users' ]
                        ) .
                        $this->formatRow( $this->msg( 'statistics-users-active' )->parse() . ' ' .
                                Linker::linkKnown(
@@ -184,7 +173,7 @@ class SpecialStatistics extends SpecialPage {
                                        $this->msg( 'listgrouprights-members' )->escaped()
                                ),
                                $this->getLanguage()->formatNum( $this->activeUsers ),
-                               array( 'class' => 'mw-statistics-users-active' ),
+                               [ 'class' => 'mw-statistics-users-active' ],
                                'statistics-users-active-desc',
                                $this->getLanguage()->formatNum( $this->getConfig()->get( 'ActiveUserDays' ) )
                        );
@@ -224,8 +213,8 @@ class SpecialStatistics extends SpecialPage {
                        $grouplink = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Listusers' ),
                                $this->msg( 'listgrouprights-members' )->escaped(),
-                               array(),
-                               array( 'group' => $group )
+                               [],
+                               [ 'group' => $group ]
                        );
                        # Add a class when a usergroup contains no members to allow hiding these rows
                        $classZero = '';
@@ -235,8 +224,8 @@ class SpecialStatistics extends SpecialPage {
                        }
                        $text .= $this->formatRow( $grouppage . ' ' . $grouplink,
                                $this->getLanguage()->formatNum( $countUsers ),
-                               array( 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) .
-                                       $classZero ) );
+                               [ 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) .
+                                       $classZero ] );
                }
 
                return $text;
@@ -274,7 +263,7 @@ class SpecialStatistics extends SpecialPage {
                                        $return .= $this->formatRow(
                                                $name,
                                                $this->getLanguage()->formatNum( htmlspecialchars( $number ) ),
-                                               array( 'class' => 'mw-statistics-hook', 'id' => 'mw-' . $key )
+                                               [ 'class' => 'mw-statistics-hook', 'id' => 'mw-' . $key ]
                                        );
                                }
                        } else {
@@ -284,8 +273,8 @@ class SpecialStatistics extends SpecialPage {
                                }
 
                                // Recursively remap the legacy structure
-                               $return .= $this->getOtherStats( array( 'statistics-header-hooks' =>
-                                       array( $header => $items ) ) );
+                               $return .= $this->getOtherStats( [ 'statistics-header-hooks' =>
+                                       [ $header => $items ] ] );
                        }
                }
 
@@ -300,7 +289,7 @@ class SpecialStatistics extends SpecialPage {
         */
        private function formatRowHeader( $header ) {
                return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( $header )->parse() ) .
+                       Xml::tags( 'th', [ 'colspan' => '2' ], $this->msg( $header )->parse() ) .
                        Xml::closeElement( 'tr' );
        }