Merge "Remove unused 'XMPGetInfo' and 'XMPGetResults' hooks"
[lhc/web/wiklou.git] / includes / specials / SpecialStatistics.php
index 4429022..652ea82 100644 (file)
@@ -78,7 +78,7 @@ class SpecialStatistics extends SpecialPage {
 
                # Statistic - other
                $extraStats = array();
-               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+               if ( Hooks::run( 'SpecialStatsAddExtra', array( &$extraStats, $this->getContext() ) ) ) {
                        $text .= $this->getOtherStats( $extraStats );
                }
 
@@ -108,7 +108,8 @@ class SpecialStatistics extends SpecialPage {
                if ( $descMsg ) {
                        $msg = $this->msg( $descMsg, $descMsgParam );
                        if ( $msg->exists() ) {
-                               $descriptionText = $this->msg( 'parentheses' )->rawParams( $msg->parse() )->escaped();
+                               $descriptionText = $this->msg( 'parentheses' )->rawParams( $msg->parse() )
+                                       ->escaped();
                                $text .= "<br />" . Xml::element( 'small', array( 'class' => 'mw-statistic-desc' ),
                                        " $descriptionText" );
                        }
@@ -126,8 +127,9 @@ class SpecialStatistics extends SpecialPage {
         * @return string
         */
        private function getPageStats() {
-               return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-pages' )->parse() ) .
+               $pageStatsHtml = Xml::openElement( 'tr' ) .
+                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-pages' )
+                               ->parse() ) .
                        Xml::closeElement( 'tr' ) .
                                $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'Allpages' ),
                                        $this->msg( 'statistics-articles' )->parse() ),
@@ -136,16 +138,24 @@ class SpecialStatistics extends SpecialPage {
                                $this->formatRow( $this->msg( 'statistics-pages' )->parse(),
                                        $this->getLanguage()->formatNum( $this->total ),
                                        array( 'class' => 'mw-statistics-pages' ),
-                                       'statistics-pages-desc' ) .
-                               $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'MediaStatistics' ),
-                                       $this->msg( 'statistics-files' )->parse() ),
-                                       $this->getLanguage()->formatNum( $this->images ),
-                                       array( 'class' => 'mw-statistics-files' ) );
+                                       'statistics-pages-desc' );
+
+               // Show the image row only, when there are files or upload is possible
+               if ( $this->images !== 0 || $this->getConfig()->get( 'EnableUploads' ) ) {
+                       $pageStatsHtml .= $this->formatRow(
+                               Linker::linkKnown( SpecialPage::getTitleFor( 'MediaStatistics' ),
+                               $this->msg( 'statistics-files' )->parse() ),
+                               $this->getLanguage()->formatNum( $this->images ),
+                               array( 'class' => 'mw-statistics-files' ) );
+               }
+
+               return $pageStatsHtml;
        }
 
        private function getEditStats() {
                return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-edits' )->parse() ) .
+                       Xml::tags( 'th', array( 'colspan' => '2' ),
+                               $this->msg( 'statistics-header-edits' )->parse() ) .
                        Xml::closeElement( 'tr' ) .
                        $this->formatRow( $this->msg( 'statistics-edits' )->parse(),
                                $this->getLanguage()->formatNum( $this->edits ),
@@ -160,7 +170,8 @@ class SpecialStatistics extends SpecialPage {
 
        private function getUserStats() {
                return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-users' )->parse() ) .
+                       Xml::tags( 'th', array( 'colspan' => '2' ),
+                               $this->msg( 'statistics-header-users' )->parse() ) .
                        Xml::closeElement( 'tr' ) .
                        $this->formatRow( $this->msg( 'statistics-users' )->parse(),
                                $this->getLanguage()->formatNum( $this->users ),
@@ -199,10 +210,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(),
@@ -217,7 +234,8 @@ class SpecialStatistics extends SpecialPage {
                        }
                        $text .= $this->formatRow( $grouppage . ' ' . $grouplink,
                                $this->getLanguage()->formatNum( $countUsers ),
-                               array( 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) . $classZero ) );
+                               array( 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) .
+                                       $classZero ) );
                }
 
                return $text;
@@ -244,12 +262,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 )
                                        );
                                }