Merge "New hook for filters on Special:Contributions form"
[lhc/web/wiklou.git] / includes / specials / SpecialMediaStatistics.php
index 7a7979c..fb78a40 100644 (file)
  */
 class MediaStatisticsPage extends QueryPage {
        protected $totalCount = 0, $totalBytes = 0;
+       /**
+       * @var integer $totalPerType Combined file size of all files in a section
+       */
+       protected $totalPerType = 0;
+       /**
+       * @var integer $totalSize Combined file size of all files
+       */
+       protected $totalSize = 0;
 
        function __construct( $name = 'MediaStatistics' ) {
                parent::__construct( $name );
@@ -36,7 +44,7 @@ class MediaStatisticsPage extends QueryPage {
                $this->shownavigation = false;
        }
 
-       function isExpensive() {
+       public function isExpensive() {
                return true;
        }
 
@@ -123,6 +131,7 @@ class MediaStatisticsPage extends QueryPage {
                                        $this->outputTableEnd();
                                }
                                $this->outputMediaType( $mediaType );
+                               $this->totalPerType = 0;
                                $this->outputTableStart( $mediaType );
                                $prevMediaType = $mediaType;
                        }
@@ -130,6 +139,14 @@ class MediaStatisticsPage extends QueryPage {
                }
                if ( $prevMediaType !== null ) {
                        $this->outputTableEnd();
+                       // add total size of all files
+                       $this->outputMediaType( 'total' );
+                       $this->getOutput()->addWikiText(
+                               $this->msg( 'mediastatistics-allbytes' )
+                                       ->numParams( $this->totalSize )
+                                       ->sizeParams( $this->totalSize )
+                                       ->text()
+                       );
                }
        }
 
@@ -138,6 +155,14 @@ class MediaStatisticsPage extends QueryPage {
         */
        protected function outputTableEnd() {
                $this->getOutput()->addHtml( Html::closeElement( 'table' ) );
+               $this->getOutput()->addWikiText(
+                               $this->msg( 'mediastatistics-bytespertype' )
+                                       ->numParams( $this->totalPerType )
+                                       ->sizeParams( $this->totalPerType )
+                                       ->numParams( $this->makePercentPretty( $this->totalPerType / $this->totalBytes ) )
+                                       ->text()
+               );
+               $this->totalSize += $this->totalPerType;
        }
 
        /**
@@ -180,7 +205,7 @@ class MediaStatisticsPage extends QueryPage {
                                ->numParams( $this->makePercentPretty( $bytes / $this->totalBytes ) )
                                ->parse()
                );
-
+               $this->totalPerType += $bytes;
                $this->getOutput()->addHTML( Html::rawElement( 'tr', array(), $row ) );
        }