Skip file count on Special:Statistics when no files and no upload
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 7 Feb 2015 18:18:45 +0000 (19:18 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Sun, 5 Apr 2015 07:34:34 +0000 (07:34 +0000)
There is no need to show the number of zero files on Special:Statistics
when it is not possible to upload files, but it is needed, when some
files already uploaded even if the upload is disabled later.

Change-Id: I4431166ebc8e952e5d926d874b56c743bebcbef1

includes/specials/SpecialStatistics.php

index 1f339d1..0acbf95 100644 (file)
@@ -126,7 +126,7 @@ class SpecialStatistics extends SpecialPage {
         * @return string
         */
        private function getPageStats() {
-               return Xml::openElement( 'tr' ) .
+               $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' ),
@@ -136,11 +136,17 @@ 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() {